Add THREAD_PID_OFFSET to tracepoint arguments that pass a TID to userland.
authormpi <mpi@openbsd.org>
Thu, 9 Sep 2021 18:41:39 +0000 (18:41 +0000)
committermpi <mpi@openbsd.org>
Thu, 9 Sep 2021 18:41:39 +0000 (18:41 +0000)
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@

sys/kern/kern_sched.c
sys/kern/kern_synch.c
sys/kern/sched_bsd.c

index 5510108..6f8bf76 100644 (file)
@@ -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 <art@openbsd.org>
  *
@@ -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])) {
index 3b40311..511cfa8 100644 (file)
@@ -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);
        }
 }
 
index 3b0a0b2..956ea24 100644 (file)
@@ -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);