diff options
author | Ori Bernstein <ori@eigenstate.org> | 2022-08-13 22:27:52 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2022-08-13 22:27:52 +0000 |
commit | ea3dec6c60c1aac7ff37b0aa4a5130c49ecd480d (patch) | |
tree | d24503c346e4896bee3d8002738bcab5b46fb4db /sys/src/9/port | |
parent | f332cf05579e82b213944a331c7b4f37f88f2587 (diff) |
dtracy: make timer probes run in interrupt context
When probing a timer, we were running in our own kproc,
and not in an interrupt context, which meant that we didn't
have any access to anything worth sampling, so we didn't
give any data back.
This moves the probe to the hzclock interrupt, and returns
the pc in the probe.
Diffstat (limited to 'sys/src/9/port')
-rw-r--r-- | sys/src/9/port/dtracytimer.c | 26 | ||||
-rw-r--r-- | sys/src/9/port/portclock.c | 1 | ||||
-rw-r--r-- | sys/src/9/port/portfns.h | 1 |
3 files changed, 15 insertions, 13 deletions
diff --git a/sys/src/9/port/dtracytimer.c b/sys/src/9/port/dtracytimer.c index 7ca89c1a6..44e63bd52 100644 --- a/sys/src/9/port/dtracytimer.c +++ b/sys/src/9/port/dtracytimer.c @@ -4,44 +4,44 @@ #include "dat.h" #include "fns.h" #include "../port/error.h" +#include "ureg.h" #include <dtracy.h> static DTProbe *timerprobe; +static int running; -static void -dtracytimer(void *) +void +dtracytick(Ureg *ur) { DTTrigInfo info; + if(!running) + return; memset(&info, 0, sizeof(info)); - for(;;){ - tsleep(&up->sleep, return0, nil, 1000); - dtptrigger(timerprobe, &info); - } + info.arg[0] = ur->pc; + info.arg[1] = userureg(ur); + dtptrigger(timerprobe, &info); } static void timerprovide(DTProvider *prov) { - timerprobe = dtpnew("timer::1s", prov, nil); + if(timerprobe == nil) + timerprobe = dtpnew("timer::1tk", prov, nil); } static int timerenable(DTProbe *) { - static int gotkproc; - - if(!gotkproc){ - kproc("dtracytimer", dtracytimer, nil); - gotkproc=1; - } + running = 1; return 0; } static void timerdisable(DTProbe *) { + running = 0; } DTProvider dtracytimerprov = { diff --git a/sys/src/9/port/portclock.c b/sys/src/9/port/portclock.c index 6711815ff..e12938bc3 100644 --- a/sys/src/9/port/portclock.c +++ b/sys/src/9/port/portclock.c @@ -154,6 +154,7 @@ hzclock(Ureg *ur) } accounttime(); + dtracytick(ur); kmapinval(); if(kproftimer != nil) diff --git a/sys/src/9/port/portfns.h b/sys/src/9/port/portfns.h index 13666ef30..5fe9fd437 100644 --- a/sys/src/9/port/portfns.h +++ b/sys/src/9/port/portfns.h @@ -82,6 +82,7 @@ int devwstat(Chan*, uchar*, int); Dir* dirchanstat(Chan *); void drawactive(int); void drawcmap(void); +void dtracytick(Ureg*); void dumpaproc(Proc*); void dumpregs(Ureg*); void dumpstack(void); |