From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796126588; b=mN2r/t6bqffFp69pgNET3LpUQWrb+axu9ZrYAK72LcbtWPjQpue4PvC4wafOEm9IEpsp Dc0z+HBB+On488arnNB6pfOOy1NSTUZiCIAWW9rdM8Q1ucsmiRIKrVWFJHZT2M824wpEj Jx9pKneKPwS5py9O9vXztmrd848qKJqseoMnfbjRIwssa47N5PLs+S91Hozs7O9tleYfM DeBCR+HUVM8bjYfmK1fi2P2PHoLH49rjD75IWNx6YRIdBHRJhb7zQGhqxaVBm56v0x34v kOVsb1Y+KtacjpZOpfdpcBFiVY7CGCw6A17eIcSweShZH3Z5MYqqGLEeTqCHPRmJETA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126588; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=OCrbwTSwJLnOjtYM2isspFWJXvwq0mxiwWE+R9HB6Zg=; b=I5P3FJlk1tcB4I7xz9RpRgMQ23fJd5qRe7QoaSHfLutCStmVZ1k7K0TEczxCYQK2le6t /dU41i66LxyIOwAllHJWq+IhweBctGrMRfwImaS21u0J6tkog9Cpkd1tiagVwUl5Pk+pl kZi7jepMKjCQipYkDIbz8vsEJSnd9FVzHgMq4bGJQ4dQzCr4IlerCiltpm9fZZO36keqm tf7PdhBfn5RGT1wEtiRx4774U2dLPfZ9MA234NUiv99Lt7wPz4pbPuSF9ZJFMR7oob44w 7qBFQPDka06s3Nq5MdWc2D47F24Fd9C3nThz06npaIa3IQCVTMaGSo9XovFrb+8YI+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=McwJREZm; arc=none smtp.remote-ip=209.85.221.70 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4693E606A332 for ; Tue, 1 Dec 2026 12:03:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4693E606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=McwJREZm Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48e0af48c18so7150982f8f.2 for ; Tue, 01 Dec 2026 04:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796126587; x=1796731387; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OCrbwTSwJLnOjtYM2isspFWJXvwq0mxiwWE+R9HB6Zg=; b=McwJREZm8zs4VqecygigNrnMIg5yj9FMJ14xaIDrc71vlAM9WRZHDxmk/wy9v7icXe qeqNaYxDCVdIhUt2tfMW7Aso9RsUzkD1h8bU/yB4COagFC1i60hQZ/raFVgRHjW60oYk e+nklA0mCKyz1BFC+MHGG3tli2BU/jmRpDno548dL/53HuJbZsGcT9rpoAAHFuFiFbb5 3D+PSKehmsoNDidU/dPbn731Ks3NyViJMrZyUKcaGrTHOHqbcC4EldOKqEjJYgRcHMnP iVob9/KwZ9xhuV8kPfBVPOy2/rmhtQzhL7kDZN14R9em7G99aP89glNvffsRBc/Um/fV hCiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796126587; x=1796731387; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OCrbwTSwJLnOjtYM2isspFWJXvwq0mxiwWE+R9HB6Zg=; b=KhsOcO5K/CAwTQ07D0wwjIjsL1A1qGjDXY7EubybOQqylY8Gct76LskAP1bQBQxKAb OtS6T3LKaJrCQuZ/3XiwDnOqBOyLW2iaEC6yJW1/+be/N+bVMXPJvOT8+zAZVAqgd6Yz M5Z4pr/tsT4epdL6jbm3Be+MbWxTkZo3qpDSz9RSf5axkJQGULv8nHakqWBMajXI3qp1 S7fD2CDbA2LiWDokidqTO3ytKh1Vmawb1Ywp9wZZ7PmuppRTj1NYmEaKP1k8UDYAKpTN oOjG5pHWTRRGH7TkllrU1s+cyQTcr0t921ezN0ROzjam+k+84UymSazY7ENsNFkgcvbU mvMg== X-Forwarded-Encrypted: i=1; AL+hErFQ8GGS0TzS1hwemo7sOJu0evRyliU9+ai+sk4FAdpqI+8h9AjPcdlJ1yU49ZnMXAdNtVjbfL3d9Fewa6I=@vger.kernel.org X-Gm-Message-State: APuU4Z8ZgRwB0FKlbAlj+sH7urBNNRQeEfRdofGYJcJpdyQxm8AysCEO gOc0MRlIdv9zcBVEtWkMWpAKyY2Q+ks0fueSTtKtXHEZh2Tysr01t0sFHxTZQ96MWyf1p31URIM gByB7gqLauipIUw== X-Received: from wmbz10.prod.google.com ([2002:a05:600c:c08a:b0:4b6:fd58:3209]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:34d0:b0:4bb:6a5a:7839 with SMTP id 5b1f17b1804b1-4bb889428eamr747604005e9.34.1796126586600; Tue, 01 Dec 2026 04:03:06 -0800 (PST) Date: Tue, 1 Dec 2026 12:03:03 +0000 In-Reply-To: <20261201120123.3678974-1-jpiecuch@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261201120123.3678974-1-jpiecuch@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261201120123.3678974-2-jpiecuch@google.com> Subject: [PATCH 1/2] sched/core: Don't count voluntary idle picks as forced idle From: Kuba Piecuch To: Peter Zijlstra , Tejun Heo Cc: Kuba Piecuch , Ingo Molnar , Juri Lelli , Vincent Guittot , Josh Don , David Vernet , Andrea Righi , Changwoo Min , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" In pick_next_task(), the per-sibling loop increments rq->core->core_forceidle_count whenever p == rq_i->idle and rq_i->nr_running > 0. That conflates a sibling forced idle by a cookie mismatch with a sibling whose pick_task() voluntarily returned idle while rq_i->nr_running > 0. Voluntary idle with nr_running > 0 is legitimate whenever a scheduling class keeps queued tasks off the CPU and returns NULL from pick_task(), such as sched_ext tasks parked on a non-local DSQ. Counting those voluntary idle picks as forced idle has two effects: - If all siblings pick idle (occ == 0), core_forceidle_count becomes non-zero while core_forceidle_occupation is 0, triggering WARN_ON_ONCE(!rq->core->core_forceidle_occupation) in __sched_core_account_forceidle() when schedstats is enabled. - If another sibling is running (occ > 0), the voluntary idle time is spuriously billed as forced idle to the running sibling's cgroup and triggers forced-idle-only paths (queue_core_balance(), forced_idle_rq(), sched_core_idle_needs_pick()). Increment core_forceidle_count and core_forceidle_seq only inside the !cookie_equals(p, cookie) branch when sched_core_find() returns NULL and replaces a non-idle pick with idle. Since cookie_equals() always returns true for rq_i->idle, voluntary idle picks are never counted as forced idle, and entering the mismatch branch guarantees a non-idle @max so core_forceidle_occupation is always non-zero whenever forced idle is recorded. Fixes: 4feee7d12603 ("sched/core: Forced idle accounting") Cc: stable@vger.kernel.org Signed-off-by: Kuba Piecuch --- kernel/sched/core.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c9890ed35df7..8cd30021721f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6470,8 +6470,12 @@ pick_next_task(struct rq *rq, struct rq_flags *rf) p = NULL; if (cookie) p = sched_core_find(rq_i, cookie); - if (!p) + if (!p) { p = idle_sched_class.pick_task(rq_i, rf); + rq->core->core_forceidle_count++; + if (!fi_before) + rq->core->core_forceidle_seq++; + } /* * Neither a core tree pick nor idle comes through a @@ -6482,15 +6486,8 @@ pick_next_task(struct rq *rq, struct rq_flags *rf) rq_i->core_pick = p; - if (p == rq_i->idle) { - if (rq_i->nr_running) { - rq->core->core_forceidle_count++; - if (!fi_before) - rq->core->core_forceidle_seq++; - } - } else { + if (p != rq_i->idle) occ++; - } } if (schedstat_enabled() && rq->core->core_forceidle_count) { -- 2.56.1.839.g22a8290db9-goog