lkml.org 
[lkml]   [2010]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH -tip 2/2] x86: Issue at least one memory barrier in stop_machine_text_poke().
    * Masami Hiramatsu (mhiramat@redhat.com) wrote:
    > Fix stop_machine_text_poke() to issue smp_mb() before exiting waiting
    > loop. Also, use ACCESS_ONCE() to check a flag according to Mathieu's
    > comment.
    >
    > Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
    > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    > Cc: Ingo Molnar <mingo@elte.hu>
    > Cc: Jason Baron <jbaron@redhat.com>
    > ---
    >
    > arch/x86/kernel/alternative.c | 6 +++---
    > 1 files changed, 3 insertions(+), 3 deletions(-)
    >
    > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
    > index 635e4f4..3236a11 100644
    > --- a/arch/x86/kernel/alternative.c
    > +++ b/arch/x86/kernel/alternative.c
    > @@ -596,9 +596,9 @@ static int __kprobes stop_machine_text_poke(void *data)
    > smp_wmb(); /* Make sure other cpus see that this has run */
    > wrote_text = 1;
    > } else {
    > - while (!wrote_text)
    > - smp_rmb();
    > - sync_core();
    > + while (!ACCESS_ONCE(wrote_text))

    Well, cpu_relax() has a "memory" clobber, so the access once is not required to
    ensure the variable is re-read. And, sorry to contradict my previous statement
    somewhat, but given that we don't care if the compiler fetches wrote_text in
    chunks or not, ACCESS_ONCE() is not required here. So rather than leaving people
    wondering why we put an ACCESS_ONCE() here, it's probably better to leave it
    out.

    Thanks,

    Mathieu

    > + cpu_relax();
    > + smp_mb(); /* Load wrote_text before following execution */
    > }
    >
    > flush_icache_range((unsigned long)tpp->addr,
    >
    >
    > --
    > Masami Hiramatsu
    >
    > Software Engineer
    > Hitachi Computer Products (America), Inc.
    > Software Solutions Division
    >
    > e-mail: mhiramat@redhat.com

    --
    Mathieu Desnoyers
    Operating System Efficiency Consultant
    EfficiOS Inc.
    http://www.efficios.com


    \
     
     \ /
      Last update: 2010-03-03 22:39    [W:0.025 / U:1.248 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site