[tip: sched/core] sched: Mandate shared flags for sched_change

tip-bot2 for Peter Zijlstra
2025-10-16T09:33:27Z

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

Commit-ID: 73ec89a1ce4bce98f74b6520a95e64cd9986aae5
Gitweb: https://git.kernel.org/tip/73ec89a1ce4bce98f74b6520a95e64cd9986aae5
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 06 Oct 2025 20:12:34 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 16 Oct 2025 11:13:54 +02:00

sched: Mandate shared flags for sched_change

Shrikanth noted that sched_change pattern relies on using shared
flags.

Suggested-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/core.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3d5659f..e2199e4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10781,6 +10781,12 @@ struct sched_change_ctx *sched_change_begin(struct task_struct *p, unsigned int
struct sched_change_ctx *ctx = this_cpu_ptr(&sched_change_ctx);
struct rq *rq = task_rq(p);

+ /*
+ * Must exclusively use matched flags since this is both dequeue and
+ * enqueue.
+ */
+ WARN_ON_ONCE(flags & 0xFFFF0000);
+
lockdep_assert_rq_held(rq);

if (!(flags & DEQUEUE_NOCLOCK)) {