mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Phil Auld <pauld@redhat.com>
To: Jon Kohler <jon@nutanix.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: hoist ASSERT_EXCLUSIVE_WRITER(p->on_rq) above WRITE_ONCE
Date: Thu, 14 Nov 2024 13:57:55 -0500	[thread overview]
Message-ID: <20241114185755.GG471026@pauld.westford.csb> (raw)
In-Reply-To: <20241114165352.1824956-1-jon@nutanix.com>

On Thu, Nov 14, 2024 at 09:53:52AM -0700 Jon Kohler wrote:
> 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
> 
> 

This looks fine to me and it makes sense to have the assert before the
write.  A quick grep showed that this is by no means a universal pattern
at the moment.


Reviewed-by: Phil Auld <pauld@redhat.com>


Cheers,
Phil

-- 


  reply	other threads:[~2024-11-14 18:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14 16:53 Jon Kohler
2024-11-14 18:57 ` Phil Auld [this message]
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

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=20241114185755.GG471026@pauld.westford.csb \
    --to=pauld@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jon@nutanix.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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®