lkml.org 
[lkml]   [2012]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] x86: Remove cmpxchg from i386 NMI nesting code
From
Date
On Fri, 2012-06-08 at 10:28 -0700, H. Peter Anvin wrote:
> On 06/08/2012 09:41 AM, Steven Rostedt wrote:
>
> >>
> >> #define nmi_nesting_postprocess() \
> >> do { \
> >> - if (cmpxchg(&__get_cpu_var(nmi_state), \
> >> - NMI_EXECUTING, NMI_NOT_RUNNING) != NMI_EXECUTING) \
> >> + if (!local_dec_and_test(&__get_cpu_var(nmi_state))) \
> >
> > Now this is where I think the patch helps. I'm almost certain that
> > local_dec_and_test is faster than a cmpxchg by many cycles. Especially
> > on i386.
> >
>
> On i386 it's infinite, but again, I don't think the code will ever be
> exercised on i386. I'm much more concerned about performance on current
> processors.

I'm not worried about non i386 here. Some context missing from the patch
is that this code is surrounded by:

#ifdef CONFIG_X86_32

[...]

#else

The '#else' part does something completely different, as this work is
done in the assembly handler on x86_64.

And yes, this code is executed on i386 (well when I boot my x86_64 into
an i386 kernel it does).


>
> But yes, local_dec_and_test should at least not be more expensive. Even
> better, use this_cpu_dec_return().

Oh! That would make this much better! I'll update the patch set.

Thanks!

-- Steve






\
 
 \ /
  Last update: 2012-06-08 20:21    [W:0.188 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site