mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched: hoist ASSERT_EXCLUSIVE_WRITER(p->on_rq) above WRITE_ONCE
@ 2024-11-14 16:53 Jon Kohler
  2024-11-14 18:57 ` Phil Auld
  0 siblings, 1 reply; 7+ messages in thread
From: Jon Kohler @ 2024-11-14 16:53 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: Jon Kohler

In {activate|deactivate}_task(), hoist ASSERT_EXCLUSIVE_WRITER() to be
above WRITE_ONCE(p->on_rq), which matches the ordering listed in the
KCSAN documentation, kcsan-checks.h code comments, and the usage
pattern we already have in __block_task().

Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a1c353a62c56..80a04c36b495 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2066,16 +2066,16 @@ void activate_task(struct rq *rq, struct task_struct *p, int flags)
 
 	enqueue_task(rq, p, flags);
 
-	WRITE_ONCE(p->on_rq, TASK_ON_RQ_QUEUED);
 	ASSERT_EXCLUSIVE_WRITER(p->on_rq);
+	WRITE_ONCE(p->on_rq, TASK_ON_RQ_QUEUED);
 }
 
 void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
 {
 	SCHED_WARN_ON(flags & DEQUEUE_SLEEP);
 
-	WRITE_ONCE(p->on_rq, TASK_ON_RQ_MIGRATING);
 	ASSERT_EXCLUSIVE_WRITER(p->on_rq);
+	WRITE_ONCE(p->on_rq, TASK_ON_RQ_MIGRATING);
 
 	/*
 	 * Code explicitly relies on TASK_ON_RQ_MIGRATING begin set *before*
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-15 17:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14 16:53 [PATCH] sched: hoist ASSERT_EXCLUSIVE_WRITER(p->on_rq) above WRITE_ONCE Jon Kohler
2024-11-14 18:57 ` Phil Auld
2024-11-14 19:01   ` Jon Kohler
2024-11-14 19:20     ` Phil Auld
2024-11-15  9:58       ` Peter Zijlstra
2024-11-15 14:26         ` Phil Auld
2024-11-15 17:28           ` Peter Zijlstra

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®