From nobody Fri Jun 12 14:00:01 2026 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 0B5CE3E559A for ; Thu, 14 May 2026 13:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778766455; cv=none; b=bbgNZ7Lol1w6IZYVpg2sFFdi2tO1oNHL/z71+s9uSm4IvVQsUUMnORwTywEldvPFQthSunaDYDN85Qke83cG1Ge20sedLqsf2jyHIfNgMBZYigR9tJertmksJKO/8jGfw7Ysb0yMXt+XKqRu4HhpJjSIA1rzWUiCd4tj3ffP4FA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778766455; c=relaxed/simple; bh=d/ONMRlXdbwshELbnvXw502e/YliCZ6V69D8MZsCzYQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bThH2trSL2DnAjzcZFfZDkde7abIwUVE7LU5oTvjhxXkreVkgriMCbp0hgXY1Xi8fvafj55g1WcrDMxkWPHx4/5rWUg18rVMlLSN59M1nVMVARhBTFj8rn+VjAZNMbnZPCwV1ho3HuHYhB+EhFan/DNzwBHvFcGveNNRcmEHeyI= 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=NykJi2Uq; arc=none smtp.client-ip=113.46.200.225 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="NykJi2Uq" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=812dag3r7rR1KFbsr9N2FErMYi8aOujlYg+exFtTtXk=; b=NykJi2UqikmvSDkdBzEsuC4FIWcQxN4/LoCsCsW0lGQP+wNyCyoY50Jwu6wNSTM4bb5nkO4x+ wjzhcEHzcjJ2FEFErkdGi7l5SZJvgbcizseb5hXcIKB9FuPJbduRrAMcbCtnf8uacOWHj9RicXM yosT3qfuOKxk6P1zPFfy9Aw= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4gGWfH4tRBz1K9cJ; Thu, 14 May 2026 21:39:51 +0800 (CST) Received: from kwepemr500016.china.huawei.com (unknown [7.202.195.68]) by mail.maildlp.com (Postfix) with ESMTPS id 2650540539; Thu, 14 May 2026 21:47:28 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemr500016.china.huawei.com (7.202.195.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 14 May 2026 21:47:27 +0800 From: Chen Jinghuang To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Subject: [PATCH] [QUESTION] sched/fair: Potential vruntime underflow and unconstrained vlag scaling in rescale_entity() Date: Thu, 14 May 2026 13:25:15 +0000 Message-ID: <20260514132515.4009200-1-chenjinghuang2@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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemr500016.china.huawei.com (7.202.195.68) Content-Type: text/plain; charset="utf-8" Hi all, While analyzing cgroup weight adjustment scenarios in EEVDF, I observed a potential vruntime underflow issue caused by unconstrained vlag scaling in rescale_entity(). I would like to consult the community on whether this behavior is expected or if it represents a bug in the current implementatio= n. I notice this my trace in a multi-level cgroup environment: CPU 3 CURRENT: PID: 12485 TASK: ffff003027f49440 COMMAND: "cpu_sim" ROOT_TASK_GROUP: ffffd714095439c0 CFS_RQ: ffff002fbfa3d140 TASK_GROUP: ffff00211fdfe800 CFS_RQ: ffff00213f2c9800 TASK_GROUP: ffff20300f2e7000 CFS_RQ: ffff0021190ca000 TASK_GROUP: ffff203016880c00 CFS_RQ: ffff00211ece4c00 [120] PID: 12485 TASK: ffff003027f49440 COMMAND: "cpu_sim" = [CURRENT] TASK_GROUP: ffff203016884000 CFS_RQ: ffff002156835c00 [120] PID: 12649 TASK: ffff003027f4e540 COMMAND: "cpu_sim" Trace Metrics (Before/After rescale_entity and update_load_set): Before: weight: 209715, avruntime: 7738112562, vlag: 3638691801, vruntime: = 4099420761 After: weight: 614, avruntime: 7738112562, vlag: 1242814741118, vruntime: 4= 099420761, limit: 724001488558 (vruntime/avruntime stay unchanged; the scaling only touches vlag, deadline= , and vprot) Weight drop (209715->614) during __sched_group_set_shares() causes se->vlag to explode in rescale_entity(), surged from 3638691801 to 1242814741118. When the entity's vruntime is subsequently updated via se->vruntime =3D avruntime - se->vlag, the massive vlag value leads to a underflow of se->vruntime. Furthermore, I noticed that while entity_lag() typically applies a limit (c= alculated as 724001488558 in this instance) to constrain se->vlag, rescale_entity() p= erforms the scaling without any such boundary checks. This allows se->vlag to excee= d the theoretical limits expected by the EEVDF algorithm. Questions: 1. Is this se->vruntime underflow during drastic weight reduction considere= d acceptable within the current EEVDF design? 2. Should rescale_entity() apply a limit check (similar to entity_lag()) im= mediately after scaling the vlag to prevent it from escaping reasonable bounds? Something like this? Signed-off-by: Chen Jinghuang --- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3ebec186f982..351e2f7b4b28 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4046,6 +4046,15 @@ rescale_entity(struct sched_entity *se, unsigned lon= g weight, bool rel_vprot) */ se->vlag =3D div64_long(se->vlag * old_weight, weight); =20 + { + u64 max_slice =3D cfs_rq_max_slice(cfs_rq_of(se)) + TICK_NSEC; + s64 limit; + + limit =3D calc_delta_fair(max_slice, se); + + se->vlag =3D clamp(se->vlag, -limit, limit); + } + /* * DEADLINE * -------- --=20 2.34.1