From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: 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>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH 2/2] sched: membarrier: cover kthread_use_mm
Date: Wed, 5 Aug 2020 11:22:36 -0400 (EDT) [thread overview]
Message-ID: <498869868.209.1596640956570.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20200805105920.GB35926@hirez.programming.kicks-ass.net>
----- On Aug 5, 2020, at 6:59 AM, Peter Zijlstra peterz@infradead.org wrote:
> On Tue, Aug 04, 2020 at 07:01:53PM +0200, peterz@infradead.org wrote:
>> On Tue, Aug 04, 2020 at 10:59:33AM -0400, Mathieu Desnoyers wrote:
>> > ----- On Aug 4, 2020, at 10:51 AM, Peter Zijlstra peterz@infradead.org wrote:
>> > > On Tue, Jul 28, 2020 at 12:00:10PM -0400, Mathieu Desnoyers wrote:
>>
>> > >> task_lock(tsk);
>> > >> + /*
>> > >> + * When a kthread stops operating on an address space, the loop
>> > >> + * in membarrier_{private,global}_expedited() may not observe
>> > >> + * that tsk->mm, and not issue an IPI. Membarrier requires a
>> > >> + * memory barrier after accessing user-space memory, before
>> > >> + * clearing tsk->mm.
>> > >> + */
>> > >> + smp_mb();
>> > >> sync_mm_rss(mm);
>> > >> local_irq_disable();
>> > >
>> > > Would it make sense to put the smp_mb() inside the IRQ disable region?
>> >
>> > I've initially placed it right after task_lock so we could eventually
>> > have a smp_mb__after_non_raw_spinlock or something with a much better naming,
>> > which would allow removing the extra barrier when it is implied by the
>> > spinlock.
>>
>> Oh, right, fair enough. I'll go think about if smp_mb__after_spinlock()
>> will work for mutexes too.
>>
>> It basically needs to upgrade atomic*_acquire() to smp_mb(). So that's
>> all architectures that have their own _acquire() and an actual
>> smp_mb__after_atomic().
>>
>> Which, from the top of my head are only arm64, power and possibly riscv.
>> And if I then git-grep smp_mb__after_spinlock, all those seem to be
>> covered.
>>
>> But let me do a better audit..
>
> All I could find is csky, which, afaict, defines a superfluous
> smp_mb__after_spinlock.
>
> The relevant architectures are indeed power, arm64 and riscv, they all
> have custom acquire/release and all define smp_mb__after_spinlock()
> appropriately.
>
> Should we rename it to smp_mb__after_acquire() ?
As discussed over IRC, smp_mb__after_atomic_acquire() would be better, because
load_acquire and spin_lock have different semantic.
We could keep a define of smp_mb__after_spinlock to smp_mb__after_atomic_acquire
to make the transition simpler.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2020-08-05 19:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 16:00 [RFC PATCH 1/2] sched: Fix exit_mm vs membarrier Mathieu Desnoyers
2020-07-28 16:00 ` [RFC PATCH 2/2] sched: membarrier: cover kthread_use_mm Mathieu Desnoyers
2020-08-04 14:51 ` peterz
2020-08-04 14:59 ` Mathieu Desnoyers
2020-08-04 17:01 ` peterz
2020-08-05 10:59 ` peterz
2020-08-05 15:22 ` Mathieu Desnoyers [this message]
2020-08-06 12:13 ` Will Deacon
2020-08-06 12:48 ` peterz
2020-08-06 12:57 ` Mathieu Desnoyers
2020-08-04 14:34 ` [RFC PATCH 1/2] sched: Fix exit_mm vs membarrier peterz
2020-08-04 14:48 ` Mathieu Desnoyers
2020-08-04 16:51 ` peterz
2020-08-04 17:25 ` Mathieu Desnoyers
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=498869868.209.1596640956570.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=npiggin@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.