Re: atomic-up.h speedup : compared with irq disable/enable
Mathieu Desnoyers <[email protected]>
| Newsgroups | gmane.linux.kernel.tracing |
|---|---|
| Message-ID | <20061109195539.GA27207@Krystal> |
* Martin J. Bligh ([email protected]) wrote: > Mathieu Desnoyers wrote: > >Some more information about the non LOCKed atomic ops that I now use on > >SMP : > > > >A test ran on a 3GHz Pentium 4 shows that (20000 loops) : > > > >irq save/restore pair 210.60 ns > > > >cmpxchg 49.46 ns > > (76 % speedup) > >cmpxchg-up (no lock prefix) 9.00 ns > > (95 % speedup) > > > >Does anyone still believe that cli()/sti() is faster ? :) > > Nice, I didn't realise cli/sti was so slow ... do you have a small > canned test script for this we could run on a variety of different > hardware? > Hi Martin, It is not exactly "canned" and it is certainly not scripted, but a few lines long bash script will be enough to load these modules. The output is through printk. Results are in cycles (have to be converted to ns manually using the cpu frequency sampled by the OS, available in /proc/cpuinfo). http://ltt.polymtl.ca/svn/tests/kernel/ Makefile test-cmpxchg-nolock.c test-cmpxchg.c test-irqloop.c For test-cmpxchg-nolock.c, you will have to get include/asm-*/atomic-up.h and include/asm-*/system.h for your architecture from LTTng 0.6.29. You can also uncomment the ifdef'd cmpxchg_up in test-cmpxchg-nolock.c (for i386). Please note that these modules only test the number of cycles spent to do a particular task, they do not measure the impact of locking when the number of CPU increases. A complete comparison of "cmpxchg" with LOCK prefix would require this, but as my goal is to compare irq save/restore with per-cpu cmpxchg (without lock prefix), I excluded the scalability study, as it should likely have a very small impact on the results. Regards, Mathieu OpenPGP public key: http://krystal.dyndns.org:8080/key/compudj.gpg Key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68