From nobody Sat Jul 25 05:29:25 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D1A6372661 for ; Fri, 17 Jul 2026 09:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784280339; cv=none; b=bG6f8BJ3BwQeVRKlpH34IZvQKm5UC0UJPGDdo9boqU5OVvT02ui8hZlgmZqgqzMuR1KJoQROW7mSy9l20jrRe8FKm2UpCCxtAPMLMQzhCBwtHPzNIrS5oQ5cgvpCkQdOhDg9mdDEG6F/VS8wHjysh49rQKUHaILgeRmVRFsI+zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784280339; c=relaxed/simple; bh=U5a4Y0phcMyvmX6dTHdi7Wpk+tgLAgsd+Oc+48VzkJA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TWXNGzAZoZjsV8nJzswKB8Rh9hG1WJWPcSAzyojidTAiCuw47WUbqrGzJrvv93VBgRi4G3skZt1LL9FHkJ7x59d5X9Dz0mZ8TR95q2qZ5xY0Qz51wLolNnYI1A8XW+6Zajhw7SsPQ+ZJCO7zcbJg0Oz7YUryX0gw3sFZYgJH+Yg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YCVJZYJu; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YCVJZYJu" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-848761b5897so4148433b3a.3 for ; Fri, 17 Jul 2026 02:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784280338; x=1784885138; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=IvBUUrQ77AYFSGfSo61X5jSINIl/yHk0k/G+uxcp3CY=; b=YCVJZYJuY/lB/g68kRPlLzrUG18K+Kwp3fMwN799McsB9FX42NjoAqro0B7vR+oqhe m9zihq1K5kTbuvZigt4OXIDb4Phlgvet9A/6nzWsnaGVf4RsFWDJ91ems1ycumd0A53u 2GR26fP5XfAksSNU4tzgB77e4OzgkzyxbVdgYj1Jy6jFh5YXZ0NhKRT3URh9tBzzThuc n2e0RVxhYXkQaZHvslgQ71M8M9vIoNJu2GvBBIkFgB8UAoeisLrF7NykoCaZ6w76ypcM s/pemcAYmK20RTLs+exmjNfS5pXEi2d9WZodFR4rMuyOt/dtnc52p6KLVu9eacfcY6Om 51HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784280338; x=1784885138; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IvBUUrQ77AYFSGfSo61X5jSINIl/yHk0k/G+uxcp3CY=; b=QP3yt/JTMqcdvLyAgYpEmB000X/l6H31JvN44ZfSpCeu3/qnNeK3xFiOTS1n3JKFJi ipas1KhRY6ChpKHCB9y4gksKeUlFGYF0H75aMwc/ejpquO34AEP8+Os1kY6Iz3D7bjVA JM/9BaS+VoEOcbNx5OOHapaKQvITPneW9gphDxAUQNtQFO8I/PjKAAbqZY5J98k/bnp8 4l2Ekp1WghbFUFT5o4IL6lqGrlNQoKGfhYOHf80n0aoXltfnyLKEHj8YuHf4Au0lTHJu F9JZBBrstfU/vvOyBC3BQRIpbVZgL2PCIQkJ6WP7sFblJ+z1/MNkCPab8WN8NH0e82Bh sRag== X-Forwarded-Encrypted: i=1; AHgh+Rr9uY9xaA9YAvWZnGeBe/u+QeDBy3VJR5mqhQaHtpJ1oHYFfdp1BP0uMPidHpTrhPZQZfBQfCmLSejpPdE=@vger.kernel.org X-Gm-Message-State: AOJu0YyCUK18arI7JTQ0e0E3kOXonQb65RRBmew6A7oNJjMnTtlOYSpi 8nWBNVDMa0JChNUY3K37Ltb9Dzdx3FhTLFGyIQbiA8QnRM32BC2SuqlW X-Gm-Gg: AfdE7cm8tHNWfJ2q96a2K0CIGluRx8hKOkvTKB5t43pIAla330waAyFkw824Vbg1IH6 ygYOZ1OJz/XChUeoNt8FznmKMnN9Xume0WAIywhK5uJoplWm7d8stVofv80Wk/UksfXWjOD9Myt v0iQDOHcT6KqOngdlKPG/7EQEXgHEqUyEMDWf1nwBJFEwlv/Rpf6jW/2U6DQMB8TtqcLfCmkJC3 d5q1idjzC3UM+FRUWZtjt5HTlcFu3zQWkqBsv/TavYFwLTkpiJjCWk8Ho7mYGefFh3+FmBRPpJz +niWSnXLj7Tc3pMg9Wt7xlKu0Y+fqinaJC0hIMSPTBs/3Ycy5CsgRScqwJ9mma8OL3q7Lvl8MqR j2ppEOUmjZp/qn4epKjdB9QDjTTL7RGzoisE+WDWJ47j8uG9QF63p8DyYQP1XzJfAiBI9YsBynC jqyDCe7uMdKT5P+w== X-Received: by 2002:a05:6a00:9084:b0:845:4126:222b with SMTP id d2e1a72fcca58-84c2931072dmr1948285b3a.28.1784280337772; Fri, 17 Jul 2026 02:25:37 -0700 (PDT) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84c2adcd3d1sm660561b3a.22.2026.07.17.02.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 02:25:36 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Peter Zijlstra , Ingo Molnar Cc: Vincent Guittot , Dietmar Eggemann , Yuyang Du , Juri Lelli , Ben Segall , linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH] sched/fair: Fix the util_avg_cap formula in a comment Date: Fri, 17 Jul 2026 17:25:30 +0800 Message-ID: <20260717092530.1495648-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 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 Content-Type: text/plain; charset="utf-8" The comment documents the initial util_avg cap for a new task as: util_avg_cap =3D (cpu_scale - cfs_rq->avg.util_avg) / 2^n but the code caps it at half of the remaining budget: cap =3D (long)(cpu_scale - cfs_rq->avg.util_avg) / 2; The "/ 2^n" form matches neither the code nor the comment's own worked example: for the 2nd task with a cfs_rq util_avg of 512 on a 1024-capacity CPU it would give (1024 - 512) / 2^2 =3D 128, whereas both the code and the tabulated example give (1024 - 512) / 2 =3D 256. The cpu_scale / 2^n progression shown in the example instead emerges from applying the per-task "/ 2" cap repeatedly, since cfs_rq->avg.util_avg accumulates the previously created tasks. Correct the formula to match the code and note where the 2^n series comes from. Fixes: 2b8c41daba32 ("sched/fair: Fix initial util_avg calculation") Signed-off-by: Zhan Xusheng --- kernel/sched/fair.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d78467ec6ee1..df57e32e36ad 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1299,9 +1299,11 @@ void init_entity_runnable_average(struct sched_entit= y *se) * To solve this problem, we also cap the util_avg of successive tasks to * only 1/2 of the left utilization budget: * - * util_avg_cap =3D (cpu_scale - cfs_rq->avg.util_avg) / 2^n + * util_avg_cap =3D (cpu_scale - cfs_rq->avg.util_avg) / 2 * - * where n denotes the nth task and cpu_scale the CPU capacity. + * where cpu_scale is the CPU capacity. Since cfs_rq->avg.util_avg + * accumulates the previously created tasks, applying this cap to each new + * task gives the nth task a util_avg_cap of cpu_scale / 2^n. * * For example, for a CPU with 1024 of capacity, a simplest series from * the beginning would be like: --=20 2.43.0