mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Ibrahim Elshahed" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Roman Kagan <rkagan@amazon.de>,
	Ibrahim Elshahed <lshahed@amazon.de>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	stable@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: [tip: sched/urgent] sched/core: Clear a stale rq->core_pick after dequeue
Date: Mon, 23 Nov 2026 09:44:26 -0000	[thread overview]
Message-ID: <179542706629.92412.731576680350374623.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261120105822.7770-2-lshahed@amazon.de>

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     b704f052aa943903be7140fa8bd805b1de9d5afb
Gitweb:        https://git.kernel.org/tip/b704f052aa943903be7140fa8bd805b1de9d5afb
Author:        Ibrahim Elshahed <lshahed@amazon.de>
AuthorDate:    Fri, 20 Nov 2026 10:58:20 
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 23 Nov 2026 10:38:26 +01:00

sched/core: Clear a stale rq->core_pick after dequeue

A core-wide selection leaves the task chosen for each sibling in that
sibling's rq->core_pick until pick_next_task() on the sibling consumes
it. If the task is dequeued before the sibling consumes it, for example
migrated away, the pointer stays until the sibling's next
pick_next_task() overwrites it. Until then
__sched_core_account_forceidle() keeps charging forced idle time to a
task that no longer runs there and, with schedstats enabled, to its
cgroup, even after the task has exited.

Clear rq->core_pick and rq->core_dl_server in sched_core_dequeue() once
the pending pick is dequeued, and don't wait for pick_next_task() to
overwrite them.

Fixes: 4feee7d12603 ("sched/core: Forced idle accounting")
Co-developed-by: Roman Kagan <rkagan@amazon.de>
Signed-off-by: Roman Kagan <rkagan@amazon.de>
Signed-off-by: Ibrahim Elshahed <lshahed@amazon.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261120105822.7770-2-lshahed@amazon.de
---
 kernel/sched/core.c |  9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 42b99be..4b1d36c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -329,6 +329,15 @@ void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags)
 	}
 
 	/*
+	 * @p left this rq, so it can no longer be the pick a sibling made.
+	 * This also avoids forced idle accounting charging it once it is gone.
+	 */
+	if (rq->core_pick == p) {
+		rq->core_pick = NULL;
+		rq->core_dl_server = NULL;
+	}
+
+	/*
 	 * Migrating the last task off the cpu, with the cpu in forced idle
 	 * state. Reschedule to create an accounting edge for forced idle,
 	 * and re-examine whether the core is still in forced idle state.

  parent reply	other threads:[~2026-11-23  9:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:58 [PATCH v2 0/3] sched/core: Fix stale core_pick and forced idle after SM_IDLE fast path Ibrahim Elshahed
2026-11-20 10:58 ` [PATCH v2 1/3] sched/core: Clear a stale rq->core_pick after dequeue Ibrahim Elshahed
2026-11-22 22:49   ` [tip: sched/urgent] " tip-bot2 for Ibrahim Elshahed
2026-11-23  9:44   ` tip-bot2 for Ibrahim Elshahed [this message]
2026-11-20 10:58 ` [PATCH v2 2/3] sched/core: Don't take the idle fast path while the core is forced idle Ibrahim Elshahed
2026-11-22 22:49   ` [tip: sched/urgent] " tip-bot2 for Ibrahim Elshahed
2026-11-23  9:44   ` tip-bot2 for Ibrahim Elshahed
2026-11-20 10:58 ` [PATCH v2 3/3] selftests/sched: Add a test for stuck forced idle under core scheduling Ibrahim Elshahed
2026-11-23  9:55   ` [tip: sched/core] " tip-bot2 for Ibrahim Elshahed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179542706629.92412.731576680350374623.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lshahed@amazon.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rkagan@amazon.de \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®