On 03/06/2018 05:29 PM, Peter Zijlstra wrote: > On Wed, Feb 28, 2018 at 01:23:44PM +0530, Ravi Bangoria wrote: >> Userspace Statically Defined Tracepoints[1] are dtrace style markers >> inside userspace applications. These markers are added by developer at >> important places in the code. Each marker source expands to a single >> nop instruction in the compiled code but there may be additional >> overhead for computing the marker arguments which expands to couple of >> instructions. If this computaion is quite more, execution of it can be >> ommited by runtime if() condition when no one is tracing on the marker: >> >> if (semaphore > 0) { >> Execute marker instructions; >> } >> >> Default value of semaphore is 0. Tracer has to increment the semaphore >> before recording on a marker and decrement it at the end of tracing. >> >> Implement the semaphore flip logic in trace_uprobe, leaving core uprobe >> infrastructure as is, except one new callback from uprobe_mmap() to >> trace_uprobe. > W.T.H. is that called a semaphore? afaict its just a usage-counter.
I totally agree with you. But it's not me who named it semaphore :) Please refer to "Semaphore Handling" section at: https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation We can surly name it differently in the kernel code and document it properly in the Documents/tracing/ > There is no blocking, no releasing, nothing that would make it an actual > semaphore. > > So please, remove all mention of semaphore from this code, because it, > most emphatically, is not one. > > Also, would it not be much better to do userspace jump-labels for this? > That completely avoids the dynamic branch at the SDT site. > Userspace jump-label is a good idea but... Semaphore logic has already became a kinda ABI now. Tools like bcc, gdb, systemtap etc. flip the semaphore while probing the marker. Thanks, Ravi