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] |
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, -- Paul Pluzhnikov nptl/ChangeLog: 2012-04-27 Paul Pluzhnikov <ppluzhnikov@google.com> * sysdeps/i386/pthread_spin_lock.S: New. * sysdeps/i386/pthread_spin_lock.c: Delete. * sysdeps/x86_64/pthread_spin_lock.S: New. * sysdeps/x86_64/pthread_spin_lock.c: Delete.
Attachment:
glibc-pthread_spin_lock-20120427.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |