public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Boqun Feng <boqun.feng@gmail.com>, Andrew Hunter <ahh@google.com>,
	Maged Michael <maged.michael@gmail.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>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Andrea Parri <parri.andrea@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Greg Hackmann <ghackmann@google.com>,
	Will Deacon <will.deacon@arm.com>,
	David Sehr <sehr@google.com>Linus Torvalds <tor>
Subject: Re: [PATCH 08/11] membarrier: Provide core serializing command (v2)
Date: Mon, 29 Jan 2018 19:04:14 +0100	[thread overview]
Message-ID: <20180129180414.GO2249@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180123155733.3404-9-mathieu.desnoyers@efficios.com>

On Tue, Jan 23, 2018 at 10:57:30AM -0500, Mathieu Desnoyers wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index f38c4c7e256a..041893128f51 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2662,9 +2662,13 @@ static struct rq *finish_task_switch(struct task_struct *prev)
>  	 * thread, mmdrop()'s implicit full barrier is required by the
>  	 * membarrier system call, because the current active_mm can
>  	 * become the current mm without going through switch_mm().
> +	 * membarrier also requires a core serializing instruction
> +	 * before going back to user-space after storing to rq->curr.
>  	 */
> -	if (mm)
> +	if (mm) {
> +		membarrier_mm_sync_core_before_usermode(mm);
>  		mmdrop(mm);
> +	}

*confused*, when we switch from process A to process B, context_switch()
will not set rq->prev_mm and the above mm will be NULL and we'll not
pass through your_function_names_are_waaay_too_long and we'll not get
cookies.

And if there's anything more complicated going on, the comment/changelog
are not adequate.

>  	if (unlikely(prev_state == TASK_DEAD)) {
>  		if (prev->sched_class->task_dead)
>  			prev->sched_class->task_dead(prev);

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Boqun Feng <boqun.feng@gmail.com>, Andrew Hunter <ahh@google.com>,
	Maged Michael <maged.michael@gmail.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>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Andrea Parri <parri.andrea@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Greg Hackmann <ghackmann@google.com>,
	Will Deacon <will.deacon@arm.com>, David Sehr <sehr@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	x86@kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 08/11] membarrier: Provide core serializing command (v2)
Date: Mon, 29 Jan 2018 19:04:14 +0100	[thread overview]
Message-ID: <20180129180414.GO2249@hirez.programming.kicks-ass.net> (raw)
Message-ID: <20180129180414.pbQWHKodNStvJCiQVx5UZqRqNBZTdl1n27hquWW4kSk@z> (raw)
In-Reply-To: <20180123155733.3404-9-mathieu.desnoyers@efficios.com>

On Tue, Jan 23, 2018 at 10:57:30AM -0500, Mathieu Desnoyers wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index f38c4c7e256a..041893128f51 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2662,9 +2662,13 @@ static struct rq *finish_task_switch(struct task_struct *prev)
>  	 * thread, mmdrop()'s implicit full barrier is required by the
>  	 * membarrier system call, because the current active_mm can
>  	 * become the current mm without going through switch_mm().
> +	 * membarrier also requires a core serializing instruction
> +	 * before going back to user-space after storing to rq->curr.
>  	 */
> -	if (mm)
> +	if (mm) {
> +		membarrier_mm_sync_core_before_usermode(mm);
>  		mmdrop(mm);
> +	}

*confused*, when we switch from process A to process B, context_switch()
will not set rq->prev_mm and the above mm will be NULL and we'll not
pass through your_function_names_are_waaay_too_long and we'll not get
cookies.

And if there's anything more complicated going on, the comment/changelog
are not adequate.

>  	if (unlikely(prev_state == TASK_DEAD)) {
>  		if (prev->sched_class->task_dead)
>  			prev->sched_class->task_dead(prev);

  parent reply	other threads:[~2018-01-29 18:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180123155733.3404-1-mathieu.desnoyers@efficios.com>
2018-01-23 15:57 ` [PATCH 01/11] membarrier: selftest: Test private expedited cmd (v2) Mathieu Desnoyers
2018-01-23 15:57   ` Mathieu Desnoyers
     [not found] ` <20180123155733.3404-1-mathieu.desnoyers-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org>
2018-01-23 15:57   ` [PATCH 02/11] powerpc: membarrier: Skip memory barrier in switch_mm() (v7) Mathieu Desnoyers
2018-01-23 15:57     ` Mathieu Desnoyers
2018-01-23 15:57   ` [PATCH 05/11] membarrier: selftest: Test global expedited cmd (v2) Mathieu Desnoyers
2018-01-23 15:57     ` Mathieu Desnoyers
2018-01-23 15:57   ` [PATCH 07/11] x86: Implement sync_core_before_usermode (v3) Mathieu Desnoyers
2018-01-23 15:57     ` Mathieu Desnoyers
2018-01-23 15:57   ` [PATCH 09/11] membarrier: x86: Provide core serializing command (v4) Mathieu Desnoyers
2018-01-23 15:57     ` Mathieu Desnoyers
2018-01-23 15:57 ` [PATCH 06/11] Introduce sync_core_before_usermode (v2) Mathieu Desnoyers
2018-01-23 15:57   ` Mathieu Desnoyers
2018-01-23 15:57 ` [PATCH 08/11] membarrier: Provide core serializing command (v2) Mathieu Desnoyers
2018-01-23 15:57   ` Mathieu Desnoyers
2018-01-29 18:04   ` Peter Zijlstra [this message]
2018-01-29 18:04     ` Peter Zijlstra
     [not found]     ` <20180129180414.GO2249-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2018-01-29 18:15       ` Peter Zijlstra
2018-01-29 18:15         ` Peter Zijlstra
     [not found]         ` <20180129181529.GG2295-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2018-01-29 18:36           ` Mathieu Desnoyers
2018-01-29 18:36             ` Mathieu Desnoyers
     [not found]             ` <485936677.11601.1517250965043.JavaMail.zimbra-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org>
2018-01-29 19:09               ` Peter Zijlstra
2018-01-29 19:09                 ` Peter Zijlstra
     [not found]                 ` <20180129190923.GP2249-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2018-01-29 19:20                   ` Mathieu Desnoyers
2018-01-29 19:20                     ` Mathieu Desnoyers
2018-01-23 15:57 ` [PATCH 10/11] membarrier: arm64: Provide core serializing command Mathieu Desnoyers
2018-01-23 15:57   ` Mathieu Desnoyers
2018-01-23 15:57 ` [PATCH 11/11] membarrier: selftest: Test private expedited sync core cmd Mathieu Desnoyers
2018-01-23 15:57   ` 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=20180129180414.GO2249@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ahh@google.com \
    --cc=avi@scylladb.com \
    --cc=benh@kernel.crashing.org \
    --cc=boqun.feng@gmail.com \
    --cc=davejwatson@fb.com \
    --cc=ghackmann@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luto@kernel.org \
    --cc=maged.michael@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=sehr@google.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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