From nobody Mon Apr 6 10:45:03 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0235221FC6 for ; Thu, 19 Mar 2026 11:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773920601; cv=none; b=Vg1b8/BXDAsIrX+ZOelZ/4Qn2JtrqUsiuNfw61idFpMqJOs1P5hZ3ilW9TCydMTBM3Jd3vXzjROjk9n6SUHRcVExKWC7AzNnOCR64MFllpDJWTmpXCRjdybFTA4ZYvSUrajyUSY5y+/1S8UkEa4l483sFICAy+vEXxFONS6A2JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773920601; c=relaxed/simple; bh=NPu/Erd6+/ih0sPOYz9YH3JAyh8vLUwv5QHEx29LdgA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=t90hyIztGhNAYAalRKChAWmAUWzkIY42XDzbJ2tHxkQ+g98C/W4LY+42NSh9idAuKTVU4WeQz1ynEgm15vXzHGjFBDIyO5uvloevknEJy6RqI2wMPpOuqRk+5hm6Dx9jvt+Lo8v+fz2fOnOT21PvdkdT3bviio+AOPKVk2VZ7xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=JZjkcLeQ; arc=none smtp.client-ip=113.46.200.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="JZjkcLeQ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=lqq9c48V9I7y5gzJJaFBOOyJaCiCqfoT0ooT2lwkiog=; b=JZjkcLeQ+j/AYBXMj/R8BP5Dn67PVBWe0H2sgZJxMyjAJfvUz6gE4Jf257UT87oyfH15srROF y9OZYDNGikZSP/JKm9dUNnZ9SZuzdC9ICFnNuCtI1PEEwOvIuhjW4BNfX+UvQwPLrBBS0Um3fkT CE2cSZclnjdJ2f6BMUN4x28= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4fc3bP1d8Vz1T4G6; Thu, 19 Mar 2026 19:37:53 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 070C04056E; Thu, 19 Mar 2026 19:43:16 +0800 (CST) Received: from kwepemq100012.china.huawei.com (7.202.195.195) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Mar 2026 19:43:15 +0800 Received: from huawei.com (10.67.175.84) by kwepemq100012.china.huawei.com (7.202.195.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Mar 2026 19:43:15 +0800 From: Zicheng Qu To: , , , , , , , , , CC: , , Subject: [PATCH] sched/fair: Update zero_vruntime after clearing on_rq in dequeue_entity() Date: Thu, 19 Mar 2026 11:21:46 +0000 Message-ID: <20260319112146.2319561-1-quzicheng@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq100012.china.huawei.com (7.202.195.195) Content-Type: text/plain; charset="utf-8" When dequeuing the current entity (cfs_rq->curr) in dequeue_entity(), the cfs_rq->zero_vruntime is updated via update_entity_lag() -> avg_vruntime() -> update_zero_vruntime() while curr->on_rq is still 1. This means the current entity is still included in the zero_vruntime calculation. However, immediately after this, curr->on_rq is set to 0, which should change the avg_vruntime() result. Without re-updating zero_vruntime, the stale value may be used in subsequent task selection paths: schedule() -> ... -> pick_task_fair() -> pick_next_entity() -> pick_eevdf() -> vruntime_eligible() If entity_tick() -> avg_vruntime() -> update_zero_vruntime() is not triggered in time between dequeue and the next pick, vruntime_eligible() may use an inaccurate cfs_rq->zero_vruntime. This can potentially cause all tasks to appear ineligible, leading to NULL pointer dereference. Add an explicit avg_vruntime(cfs_rq) call after clearing curr->on_rq to ensure cfs_rq->zero_vruntime is properly updated before the next pick. Fixes: 147f3efaa241 ("sched/fair: Implement an EEVDF-like scheduling policy= ") Signed-off-by: Zicheng Qu Signed-off-by: Zhang Qiao --- kernel/sched/fair.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bf948db905ed..f8070767c2f4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5461,6 +5461,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_en= tity *se, int flags) if (se !=3D cfs_rq->curr) __dequeue_entity(cfs_rq, se); se->on_rq =3D 0; + /* update the cfs_rq->zero_vruntime again after curr->on_rq =3D 0 */ + if (se =3D=3D cfs_rq->curr) + avg_vruntime(cfs_rq); account_entity_dequeue(cfs_rq, se); =20 /* return excess runtime on last dequeue */ --=20 2.34.1