This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Avoid "anonymous" code in pthread_spin_lock


On Saturday, April 28, 2012 02:21:47 Paul Pluzhnikov wrote:
> On Wed, Apr 25, 2012 at 4:10 PM, Paul Pluzhnikov <ppluzhnikov@google.com> 
wrote:
> > Attached patch introduces a local label, changing above picture to:
> > 
> > (gdb) x/11i 0xcb00
> >   0xcb00 <pthread_spin_lock>:  lock decl (%rdi)
> >   0xcb03 <pthread_spin_lock+3>:        jne    0xcb10
> > <_L_pthread_spin_lock> 0xcb05 <pthread_spin_lock+5>:        xor  
> >  %eax,%eax
> >   0xcb07 <pthread_spin_lock+7>:        retq
> >   0xcb08:      nopl   0x0(%rax,%rax,1)
> >   0xcb10 <_L_pthread_spin_lock>:       pause
> >   0xcb12 <_L_pthread_spin_lock+2>:     cmpl   $0x0,(%rdi)
> >   0xcb15 <_L_pthread_spin_lock+5>:     jg     0xcb00
> > <pthread_spin_lock> 0xcb17 <_L_pthread_spin_lock+7>:     jmp  
> >  0xcb10 <_L_pthread_spin_lock> 0xcb19:      nopl   0x0(%rax)
> >   0xcb20 <pthread_spin_trylock>:       mov    $0x1,%eax
> 
> As Andrew pointed out, this is still quite undesirable from profiling
> perspective: in a profile, we would see something like:
> 
>    8069  30.0%  30.0%     8069  30.0% SomeClass::SomeFunc
>    3992  14.8%  44.9%     3992  14.8% _L_pthread_spin_lock
>    3212  11.9%  56.8%     3212  11.9% syscall
>    1867   6.9%  63.8%     1867   6.9% mlx4_post_send
>    1446   5.4%  69.1%     1446   5.4% pthread_spin_lock
> 
> but we'd like to see pthread_spin_lock taking the 20.2% that it actually
> does.
> 
> There appears to be very little value in writing pthread_spin_lock in C:
> it only contains a single "return".
> 
> I therefore would like to propose attached patch, which re-implements
> exact same code in straight ASM.
> 
> This is also slightly faster on i386, since we don't need frame pointer.
> 
> Tested on Linux/x86_64 and Linux/i686.
> 
> Thanks,

Please remove the "Contributed by Paul Pluzhnikov 
<ppluzhnikov@google.com>", we'd like to avoid these in future and in this 
specific case, I see really nothing new in the code.

The patch itself is fine,

Thanks,
Andreas
-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]