lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 29 Jan 2018 19:20:52 +0000 (UTC)
From:   Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        linux-api <linux-api@...r.kernel.org>,
        Andy Lutomirski <luto@...nel.org>,
        "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Andrew Hunter <ahh@...gle.com>,
        maged michael <maged.michael@...il.com>,
        Avi Kivity <avi@...lladb.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Dave Watson <davejwatson@...com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andrea Parri <parri.andrea@...il.com>,
        "Russell King, ARM Linux" <linux@...linux.org.uk>,
        Greg Hackmann <ghackmann@...gle.com>,
        Will Deacon <will.deacon@....com>,
        David Sehr <sehr@...gle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        x86 <x86@...nel.org>, linux-arch <linux-arch@...r.kernel.org>
Subject: Re: [PATCH 08/11] membarrier: Provide core serializing command (v2)

----- On Jan 29, 2018, at 2:09 PM, Peter Zijlstra peterz@...radead.org wrote:

> On Mon, Jan 29, 2018 at 06:36:05PM +0000, Mathieu Desnoyers wrote:
>> ----- On Jan 29, 2018, at 1:15 PM, Peter Zijlstra peterz@...radead.org wrote:
> 
>> > Aaah, its the case where we do not pass through switch_mm(), the partial
>> > comment got to me. I only realized after reading the next patch.
>> 
>> Indeed, if we read the entire comment, it's made clear that this case is for
>> when switch_mm is not invoked, where the current mm is changed without going
>> through switch_mm(), when scheduling between uthread->kthread->uthread for
>> instance.
>> 
>>         /*
>>          * When transitioning from a kernel thread to a userspace
>>          * 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.
>>          */
>> 
>> Is there something I should improve in the wording of this added
>> sentence to make it clearer ?
> 
> Can be improved I think, its got two unqualified "membarrier"s in and
> its a bit mixed up. I'm having a major case of the mondays (brain just
> won't start today), but maybe something like:
> 
>	When we switched through a kernel thread, the loop in
>	membarrier_{private,global}_expedited() can have observed that
>	kernel thread and not issued an IPI. We will also not pass
>	through switch_mm(). Membarrier requires a barrier after writing
>	rq->curr and returning to userspace, so provide them here:
> 
>	  - a full memory barrier for {PRIVATE,GLOBAL}_EXPEDITED
>	  - a sync_core for SYNC_CORE

Editing to remove use of "we" and clarify, which ends up as:

        /*
         * When switching through a kernel thread, the loop in
         * membarrier_{private,global}_expedited() may have observed that
         * kernel thread and not issued an IPI. It is therefore possible to
         * schedule between user->kernel->user threads without passing though
         * switch_mm(). Membarrier requires a barrier after storing to
         * rq->curr, before returning to userspace, so provide them here:
         *
         * - a full memory barrier for {PRIVATE,GLOBAL}_EXPEDITED, implicitly
         *   provided by mmdrop(),
         * - a sync_core for SYNC_CORE.
         */

> 
> Also I think changing the changlog to state where we need core-sync
> would be good. Currently the x86 patch does that, but not this one,
> while this introduces the feature.

Planning to add this:

Architectures selecting this feature need to either document that
they issue core serializing instructions when returning to user-space,
or implement their architecture-specific sync_core_before_usermode().

Thanks,

Mathieu

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ