From: Andrea Parri <parri.andrea@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
dipankar <dipankar@in.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Josh Triplett <josh@joshtriplett.org>,
Thomas Gleixner <tglx@linutronix.de>,
rostedt <rostedt@goodmis.org>,
David Howells <dhowells@redhat.com>,
Eric Dumazet <edumazet@google.com>, fweisbec <fweisbec@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>, Andrew Hunter <ahh@google.com>,
maged michael <maged.michael@gmail.com>,
gromer <gromer@google.com>, Avi Kivity <avi@scylladb.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>Paul
Subject: Re: [PATCH tip/core/rcu 1/3] membarrier: Provide register expedited private command
Date: Fri, 6 Oct 2017 00:02:14 +0200 [thread overview]
Message-ID: <20171005220214.GA7140@andrea> (raw)
In-Reply-To: <312162.31738.1507219326334.JavaMail.zimbra@efficios.com>
On Thu, Oct 05, 2017 at 04:02:06PM +0000, Mathieu Desnoyers wrote:
> ----- On Oct 5, 2017, at 8:12 AM, Peter Zijlstra peterz@infradead.org wrote:
>
> > On Wed, Oct 04, 2017 at 02:37:53PM -0700, Paul E. McKenney wrote:
> >> diff --git a/arch/powerpc/kernel/membarrier.c b/arch/powerpc/kernel/membarrier.c
> >> new file mode 100644
> >> index 000000000000..b0d79a5f5981
> >> --- /dev/null
> >> +++ b/arch/powerpc/kernel/membarrier.c
> >> @@ -0,0 +1,45 @@
> >
> >> +void membarrier_arch_register_private_expedited(struct task_struct *p)
> >> +{
> >> + struct task_struct *t;
> >> +
> >> + if (get_nr_threads(p) == 1) {
> >> + set_thread_flag(TIF_MEMBARRIER_PRIVATE_EXPEDITED);
> >> + return;
> >> + }
> >> + /*
> >> + * Coherence of TIF_MEMBARRIER_PRIVATE_EXPEDITED against thread
> >> + * fork is protected by siglock.
> >> + */
> >> + spin_lock(&p->sighand->siglock);
> >> + for_each_thread(p, t)
> >> + set_ti_thread_flag(task_thread_info(t),
> >> + TIF_MEMBARRIER_PRIVATE_EXPEDITED);
> >
> > I'm not sure this works correctly vs CLONE_VM without CLONE_THREAD.
>
> The intent here is to hold the sighand siglock to provide mutual
> exclusion against invocation of membarrier_fork(p, clone_flags)
> by copy_process().
>
> copy_process() grabs spin_lock(¤t->sighand->siglock) for both
> CLONE_THREAD and not CLONE_THREAD flags.
>
> What am I missing here ?
>
> >
> >> + spin_unlock(&p->sighand->siglock);
> >> + /*
> >> + * Ensure all future scheduler executions will observe the new
> >> + * thread flag state for this process.
> >> + */
> >> + synchronize_sched();
> >
> > This relies on the flag being read inside rq->lock, right?
>
> Yes. The flag is read by membarrier_arch_switch_mm(), invoked
> within switch_mm_irqs_off(), called by context_switch() before
> finish_task_switch() releases the rq lock.
I fail to graps the relation between this synchronize_sched() and rq->lock.
(Besides, we made no reference to rq->lock while discussing:
https://github.com/paulmckrcu/litmus/commit/47039df324b60ace0cf7b2403299580be730119b
replace membarrier_arch_sched_in with switch_mm_irqs_off )
Could you elaborate?
Andrea
>
> Is the comment clear enough, or do you have suggestions for
> improvements ?
>
> Thanks,
>
> Mathieu
>
> >
> > > +}
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
WARNING: multiple messages have this Message-ID (diff)
From: Andrea Parri <parri.andrea@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
dipankar <dipankar@in.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Josh Triplett <josh@joshtriplett.org>,
Thomas Gleixner <tglx@linutronix.de>,
rostedt <rostedt@goodmis.org>,
David Howells <dhowells@redhat.com>,
Eric Dumazet <edumazet@google.com>, fweisbec <fweisbec@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>, Andrew Hunter <ahh@google.com>,
maged michael <maged.michael@gmail.com>,
gromer <gromer@google.com>, Avi Kivity <avi@scylladb.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Dave Watson <davejwatson@fb.com>,
Alan Stern <stern@rowland.harvard.edu>,
Will Deacon <will.deacon@arm.com>,
Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Nicholas Piggin <npiggin@gmail.com>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [PATCH tip/core/rcu 1/3] membarrier: Provide register expedited private command
Date: Fri, 6 Oct 2017 00:02:14 +0200 [thread overview]
Message-ID: <20171005220214.GA7140@andrea> (raw)
Message-ID: <20171005220214.KQr5eyeEiPdFb35MYUiRYwEV9WPNjrH3ty4gWWbltAo@z> (raw)
In-Reply-To: <312162.31738.1507219326334.JavaMail.zimbra@efficios.com>
On Thu, Oct 05, 2017 at 04:02:06PM +0000, Mathieu Desnoyers wrote:
> ----- On Oct 5, 2017, at 8:12 AM, Peter Zijlstra peterz@infradead.org wrote:
>
> > On Wed, Oct 04, 2017 at 02:37:53PM -0700, Paul E. McKenney wrote:
> >> diff --git a/arch/powerpc/kernel/membarrier.c b/arch/powerpc/kernel/membarrier.c
> >> new file mode 100644
> >> index 000000000000..b0d79a5f5981
> >> --- /dev/null
> >> +++ b/arch/powerpc/kernel/membarrier.c
> >> @@ -0,0 +1,45 @@
> >
> >> +void membarrier_arch_register_private_expedited(struct task_struct *p)
> >> +{
> >> + struct task_struct *t;
> >> +
> >> + if (get_nr_threads(p) == 1) {
> >> + set_thread_flag(TIF_MEMBARRIER_PRIVATE_EXPEDITED);
> >> + return;
> >> + }
> >> + /*
> >> + * Coherence of TIF_MEMBARRIER_PRIVATE_EXPEDITED against thread
> >> + * fork is protected by siglock.
> >> + */
> >> + spin_lock(&p->sighand->siglock);
> >> + for_each_thread(p, t)
> >> + set_ti_thread_flag(task_thread_info(t),
> >> + TIF_MEMBARRIER_PRIVATE_EXPEDITED);
> >
> > I'm not sure this works correctly vs CLONE_VM without CLONE_THREAD.
>
> The intent here is to hold the sighand siglock to provide mutual
> exclusion against invocation of membarrier_fork(p, clone_flags)
> by copy_process().
>
> copy_process() grabs spin_lock(¤t->sighand->siglock) for both
> CLONE_THREAD and not CLONE_THREAD flags.
>
> What am I missing here ?
>
> >
> >> + spin_unlock(&p->sighand->siglock);
> >> + /*
> >> + * Ensure all future scheduler executions will observe the new
> >> + * thread flag state for this process.
> >> + */
> >> + synchronize_sched();
> >
> > This relies on the flag being read inside rq->lock, right?
>
> Yes. The flag is read by membarrier_arch_switch_mm(), invoked
> within switch_mm_irqs_off(), called by context_switch() before
> finish_task_switch() releases the rq lock.
I fail to graps the relation between this synchronize_sched() and rq->lock.
(Besides, we made no reference to rq->lock while discussing:
https://github.com/paulmckrcu/litmus/commit/47039df324b60ace0cf7b2403299580be730119b
replace membarrier_arch_sched_in with switch_mm_irqs_off )
Could you elaborate?
Andrea
>
> Is the comment clear enough, or do you have suggestions for
> improvements ?
>
> Thanks,
>
> Mathieu
>
> >
> > > +}
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
next prev parent reply other threads:[~2017-10-05 22:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 21:37 [PATCH tip/core/rcu 0/3] Updates to sys_membarrier for v4.14 to add registration Paul E. McKenney
2017-10-04 21:37 ` [PATCH tip/core/rcu 1/3] membarrier: Provide register expedited private command Paul E. McKenney
2017-10-04 21:37 ` Paul E. McKenney
2017-10-05 4:23 ` Nicholas Piggin
2017-10-05 4:23 ` Nicholas Piggin
2017-10-05 12:22 ` Avi Kivity
2017-10-05 12:22 ` Avi Kivity
2017-10-05 15:54 ` Mathieu Desnoyers
2017-10-05 15:54 ` Mathieu Desnoyers
2017-10-05 15:53 ` Mathieu Desnoyers
2017-10-05 15:53 ` Mathieu Desnoyers
2017-10-05 12:12 ` Peter Zijlstra
2017-10-05 12:12 ` Peter Zijlstra
2017-10-05 12:24 ` Peter Zijlstra
2017-10-05 12:24 ` Peter Zijlstra
2017-10-05 16:05 ` Mathieu Desnoyers
2017-10-05 16:05 ` Mathieu Desnoyers
2017-10-05 16:02 ` Mathieu Desnoyers
2017-10-05 16:02 ` Mathieu Desnoyers
2017-10-05 16:21 ` Peter Zijlstra
2017-10-05 16:21 ` Peter Zijlstra
2017-10-05 21:44 ` Mathieu Desnoyers
2017-10-05 21:44 ` Mathieu Desnoyers
2017-10-05 22:02 ` Andrea Parri [this message]
2017-10-05 22:02 ` Andrea Parri
2017-10-05 22:04 ` Andrea Parri
2017-10-05 22:19 ` Mathieu Desnoyers
2017-10-05 22:19 ` Mathieu Desnoyers
2017-10-05 22:46 ` Steven Rostedt
2017-10-05 22:46 ` Steven Rostedt
2017-10-06 8:32 ` Peter Zijlstra
2017-10-06 8:32 ` Peter Zijlstra
2017-10-07 15:10 ` Andrea Parri
2017-10-07 15:10 ` Andrea Parri
2017-10-04 21:37 ` [PATCH tip/core/rcu 2/3] membarrier: selftest: Test private expedited cmd Paul E. McKenney
2017-10-04 21:37 ` Paul E. McKenney
2017-10-04 21:37 ` [PATCH tip/core/rcu 3/3] membarrier: Document scheduler barrier requirements Paul E. McKenney
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=20171005220214.GA7140@andrea \
--to=parri.andrea@gmail.com \
--cc=ahh@google.com \
--cc=akpm@linux-foundation.org \
--cc=avi@scylladb.com \
--cc=benh@kernel.crashing.org \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=gromer@google.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maged.michael@gmail.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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.