linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>,
	 linux-kernel <linux-kernel@vger.kernel.org>,
	 Will Deacon <will@kernel.org>, paulmck <paulmck@kernel.org>,
	 Nicholas Piggin <npiggin@gmail.com>,
	 Andy Lutomirski <luto@amacapital.net>,
	 Thomas Gleixner <tglx@linutronix.de>,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	 Alan Stern <stern@rowland.harvard.edu>,
	 linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH 1/3] sched: fix exit_mm vs membarrier (v4)
Date: Tue, 20 Oct 2020 10:59:58 -0400 (EDT)	[thread overview]
Message-ID: <1123875792.30589.1603205998119.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20201020143648.GU2628@hirez.programming.kicks-ass.net>

----- On Oct 20, 2020, at 10:36 AM, Peter Zijlstra peterz@infradead.org wrote:

> On Tue, Oct 20, 2020 at 09:47:13AM -0400, Mathieu Desnoyers wrote:
>> +void membarrier_update_current_mm(struct mm_struct *next_mm)
>> +{
>> +	struct rq *rq = this_rq();
>> +	int membarrier_state = 0;
>> +
>> +	if (next_mm)
>> +		membarrier_state = atomic_read(&next_mm->membarrier_state);
>> +	if (READ_ONCE(rq->membarrier_state) == membarrier_state)
>> +		return;
>> +	WRITE_ONCE(rq->membarrier_state, membarrier_state);
>> +}
> 
> This is suspisioucly similar to membarrier_switch_mm().
> 
> Would something like so make sense?

Very much yes. Do you want me to re-send the series, or you
want to fold this in as you merge it ?

Thanks,

Mathieu

> 
> ---
> --- a/kernel/sched/membarrier.c
> +++ b/kernel/sched/membarrier.c
> @@ -206,14 +206,7 @@ void membarrier_exec_mmap(struct mm_stru
> 
> void membarrier_update_current_mm(struct mm_struct *next_mm)
> {
> -	struct rq *rq = this_rq();
> -	int membarrier_state = 0;
> -
> -	if (next_mm)
> -		membarrier_state = atomic_read(&next_mm->membarrier_state);
> -	if (READ_ONCE(rq->membarrier_state) == membarrier_state)
> -		return;
> -	WRITE_ONCE(rq->membarrier_state, membarrier_state);
> +	membarrier_switch_mm(this_rq(), NULL, next_mm);
> }
> 
> static int membarrier_global_expedited(void)
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index d2621155393c..3d589c2ffd28 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -2645,12 +2645,14 @@ static inline void membarrier_switch_mm(struct rq *rq,
> 					struct mm_struct *prev_mm,
> 					struct mm_struct *next_mm)
> {
> -	int membarrier_state;
> +	int membarrier_state = 0;
> 
> 	if (prev_mm == next_mm)
> 		return;
> 
> -	membarrier_state = atomic_read(&next_mm->membarrier_state);
> +	if (next_mm)
> +		membarrier_state = atomic_read(&next_mm->membarrier_state);
> +
> 	if (READ_ONCE(rq->membarrier_state) == membarrier_state)
>  		return;

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


  reply	other threads:[~2020-10-20 15:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201020134715.13909-1-mathieu.desnoyers@efficios.com>
2020-10-20 13:47 ` [PATCH 1/3] sched: fix exit_mm vs membarrier (v4) Mathieu Desnoyers
2020-10-20 14:36   ` Peter Zijlstra
2020-10-20 14:59     ` Mathieu Desnoyers [this message]
2020-10-22  6:51       ` Boqun Feng

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=1123875792.30589.1603205998119.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@amacapital.net \
    --cc=npiggin@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will@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;
as well as URLs for NNTP newsgroup(s).