This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap 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: new static user probe types


So here is what I have for SW10013:

1. Given a 'dtrace' input file:
provider tstsyscall
{
probe test(short arg1, int arg2, int arg3, int arg4, struct astruct arg5)
}

2. The dtrace script produces a header file containing:
#define STAP_HAS_SEMAPHORES 1
...
/* TSTSYSCALL_TEST ( short arg1, int arg2, int arg3, int arg4, struct astruct arg5) */
#define TSTSYSCALL_TEST_ENABLED() test_semaphore
__extension__ extern long test_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
#define TSTSYSCALL_TEST(arg1,arg2,arg3,arg4,arg5) \
STAP_PROBE5(provider,test,arg1,arg2,arg3,arg4,arg5)
// these are to help kprobe and utrace access struct astruct
struct astruct {int a; int b;};
typedef struct astruct test_arg5;  test_arg5 test_arg5_v;

3. where STAP_PROBE5 is defined as:
#define STAP_PROBE5_(probe,label,parm1,parm2,parm3,parm4,parm5)
STAP_SEMAPHORE(probe)
do {
__extension__ struct {size_t arg1 __attribute__((aligned(8))); size_t arg2 __attribute__((aligned(8))); size_t arg3 __attribute__((aligned(8))); size_t arg4 __attribute__((aligned(8))); size_t arg5 __attribute__((aligned(8)));} stap_probe5_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, (size_t)parm5}; STAP_PROBE_DATA(probe,STAP_GUARD,5); syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe5_args); } while (0)


4. and STAP_SEMAPHORE is defined as (so if the dtrace script isn't
being used there is no test):
#ifdef STAP_HAS_SEMAPHORE #define STAP_SEMAPHORE(probe) if ( probe ## _semaphore ) #else
#define STAP_SEMAPHORE(probe) ;
#endif


5. and the dtrace script also produces tstsyscall_.c.  This defines
   the test value and creates a ctor where stap can set the value.
__extension__ long test_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));

_stap_constructor ()
{
 __asm__ volatile ("/* %0 */" :: "g"(test_semaphore));
}

6. this needs to be improved but currently if stap sees a test probe then it 'automatically' produces this probe which requires -g. process(EXECUTABLE).statement("_stap_constructor")
{ test_semaphore = 1 }


7. The execution time of a synthetic test not run under stap influence
is more or less equivalent with the above and when run under stap:
utrace 0.76user 4.30system 0:05.22elapsed
kprobe 1.38user 5.09system 0:06.92elapsed uprobe 0.92user 10.99system 0:12.01elapsed







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