File: semop-watch.stp

package info (click to toggle)
systemtap 4.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 38,260 kB
  • sloc: cpp: 77,147; ansic: 61,828; xml: 49,277; exp: 42,244; sh: 11,046; python: 2,772; perl: 2,252; tcl: 1,305; makefile: 1,086; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (32 lines) | stat: -rwxr-xr-x 822 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
global threads;
global times;

probe syscall.{semop,semtimedop}
{
  sembuf_sz = @cast_module_sizeof("kernel", "struct sembuf");
  res = sprintf("set %d sems", semid)

  %( systemtap_v < "2.3" %? 
     if (tsops_uaddr != 0) sops_uaddr = tsops_uaddr;
     /* ignore warning for semtimedop's 'tsops_uaddr never-assigned'. */
  %)

  for(i = 0; i < nsops; i++) {
    offset = i * sembuf_sz;
    pointer = sops_uaddr + offset;
    num_addr = & @cast(pointer, "struct sembuf", "kernel")->sem_num;
    num = user_short(num_addr);

    res = sprintf("%s %d", res, num);
  }
  res = sprintf("%s\n", res);

  threads[tid()] = res;
  times[tid()] = gettimeofday_us();
}

probe syscall.{semop,semtimedop}.return
{
  printf("Thread %d took %dus to operate on %s\n", tid(),
         gettimeofday_us() - times[tid()], threads[tid()]);
}