summaryrefslogtreecommitdiff
path: root/sys/src/libdtracy
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2019-03-30 09:17:46 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2019-03-30 09:17:46 +0100
commit4f0bfe0fb8dc608a94fe429c5ddb12e58997e1ce (patch)
treefc81407d959370278dfdb53da69c5ab8b3fef55c /sys/src/libdtracy
parentac3147a9c58f339f9b978ab087464912c16bc8f8 (diff)
dtracy: avoid dmachlock() race
between being commited to a machno and having acquired the lock, the scheduler could come in an schedule us on a different processor. the solution is to have dtmachlock() take a special -1 argument to mean "current mach" and return the actual mach number after the lock has been acquired and interrupts being disabled.
Diffstat (limited to 'sys/src/libdtracy')
-rw-r--r--sys/src/libdtracy/prog.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/src/libdtracy/prog.c b/sys/src/libdtracy/prog.c
index 402638f13..831a94b5e 100644
--- a/sys/src/libdtracy/prog.c
+++ b/sys/src/libdtracy/prog.c
@@ -336,13 +336,12 @@ dtgexec(DTActGr *g, DTTrigInfo *info)
}
void
-dtptrigger(DTProbe *p, int machno, DTTrigInfo *info)
+dtptrigger(DTProbe *p, DTTrigInfo *info)
{
DTEnab *e;
info->ts = dttime();
- dtmachlock(machno);
- info->machno = machno;
+ info->machno = dtmachlock(-1);
for(e = p->enablist.probnext; e != &p->enablist; e = e->probnext)
if(e->gr->chan->state == DTCGO){
info->ch = e->gr->chan;
@@ -350,5 +349,5 @@ dtptrigger(DTProbe *p, int machno, DTTrigInfo *info)
if(dtgexec(e->gr, info) < 0)
e->gr->chan->state = DTCFAULT;
}
- dtmachunlock(machno);
+ dtmachunlock(info->machno);
}