From: mpi Date: Thu, 9 Sep 2021 18:41:39 +0000 (+0000) Subject: Add THREAD_PID_OFFSET to tracepoint arguments that pass a TID to userland. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9fde647a9e9455485604c5bf303940f9dfe358a4;p=openbsd Add THREAD_PID_OFFSET to tracepoint arguments that pass a TID to userland. Bring these values in sync with the `tid' builtin which already include the offset. This is necessary to build script comparing them, like: tracepoint:sched:enqueue { @ts[arg0] = nsecs; } tracepoint:sched:on__cpu /@ts[tid]/ { latency = nsecs - @ts[tid]; } Discussed with and ok bluhm@ --- diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 5510108a7d5..6f8bf76c084 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.72 2021/07/06 09:34:07 kettenis Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.73 2021/09/09 18:41:39 mpi Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski * @@ -258,7 +258,8 @@ setrunqueue(struct cpu_info *ci, struct proc *p, uint8_t prio) spc = &p->p_cpu->ci_schedstate; spc->spc_nrun++; - TRACEPOINT(sched, enqueue, p->p_tid, p->p_p->ps_pid); + TRACEPOINT(sched, enqueue, p->p_tid + THREAD_PID_OFFSET, + p->p_p->ps_pid); TAILQ_INSERT_TAIL(&spc->spc_qs[queue], p, p_runq); spc->spc_whichqs |= (1 << queue); @@ -280,7 +281,8 @@ remrunqueue(struct proc *p) SCHED_ASSERT_LOCKED(); spc = &p->p_cpu->ci_schedstate; spc->spc_nrun--; - TRACEPOINT(sched, dequeue, p->p_tid, p->p_p->ps_pid); + TRACEPOINT(sched, dequeue, p->p_tid + THREAD_PID_OFFSET, + p->p_p->ps_pid); TAILQ_REMOVE(&spc->spc_qs[queue], p, p_runq); if (TAILQ_EMPTY(&spc->spc_qs[queue])) { diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 3b403117ed3..511cfa875ba 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.178 2021/09/09 18:23:31 mpi Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.179 2021/09/09 18:41:39 mpi Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -537,7 +537,8 @@ unsleep(struct proc *p) if (p->p_wchan != NULL) { TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_runq); p->p_wchan = NULL; - TRACEPOINT(sched, wakeup, p->p_tid, p->p_p->ps_pid); + TRACEPOINT(sched, wakeup, p->p_tid + THREAD_PID_OFFSET, + p->p_p->ps_pid); } } diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index 3b0a0b2cfc7..956ea24ea07 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.68 2021/08/02 15:15:47 tb Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.69 2021/09/09 18:41:39 mpi Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -387,7 +387,7 @@ mi_switch(void) if (p != nextproc) { uvmexp.swtch++; - TRACEPOINT(sched, off__cpu, nextproc->p_tid, + TRACEPOINT(sched, off__cpu, nextproc->p_tid + THREAD_PID_OFFSET, nextproc->p_p->ps_pid); cpu_switchto(p, nextproc); TRACEPOINT(sched, on__cpu, NULL);