[BACK]Return to runqlat.bt CVS log [TXT][DIR] Up to [local] / src / share / btrace

Annotation of src/share/btrace/runqlat.bt, Revision 1.2

1.1       mpi         1: /*
                      2:  * runqlat.bt  Measure run queue latency (aka scheduler latency). OpenBSD.
                      3:  *
                      4:  * This measures the time from enqueue to on-cpu, for the same thread.
                      5:  *
                      6:  * WARNING: This traces scheduler functions, which can incur high overhead.
                      7:  * This is not suitable for 24x7 monitoring.
                      8:  *
                      9:  * Copyright (c) 2014 Brendan Gregg. All rights reserved.
                     10:  * Copyright (c) 2021 Martin Pieuchot. All rights reserved.
                     11:  *
1.2     ! mpi        12:  * Redistribution and use in source and binary forms, with or without
1.1       mpi        13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
1.2     ! mpi        15:  * 1. Redistributions of source code must retain the above copyright
1.1       mpi        16:  *    notice, this list of conditions and the following disclaimer.
1.2     ! mpi        17:  * 2. Redistributions in binary form must reproduce the above copyright
1.1       mpi        18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.2     ! mpi        27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.1       mpi        29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.2     ! mpi        30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.1       mpi        31:  * SUCH DAMAGE.
                     32:  *
                     33:  * 19-Jun-2014 Brendan Gregg   Created this.
                     34:  * 08-Sep-2021 Martin Pieuchot Ported this to OpenBSD's btrace(8)
                     35:  */
                     36:
                     37: /*
                     38:  * Work around multiple enqueue/dequeue cycles due to priority changes
                     39:  * before executing by registering only the first time a thread is put
                     40:  * on a scheduler queue.
                     41:  */
                     42: tracepoint:sched:enqueue
                     43: /@ts[arg0] == 0/
                     44: {
                     45:        /*
                     46:         * For the enqueue and dequeue probes, arg0 is the thread ID.
                     47:         */
                     48:        @ts[arg0] = nsecs
                     49: }
                     50:
                     51: tracepoint:sched:on__cpu
                     52: /@ts[tid]/
                     53: {
                     54:        $usec = (nsecs - @ts[tid]) / 1000;
                     55:        @max_usec[0] = max($usec);
                     56:        @dist_usec = hist($usec);
                     57:        delete(@ts[tid]);
                     58: }
                     59:
                     60: interval:hz:1
                     61: {
                     62:        time("%H:%M:%S  ");
                     63:        printf("Run queue latency (us):\n");
                     64:        print(@dist_usec);
                     65:        printf("Max run queue latency: %d ms\n", @max_usec[0] / 1000);
                     66:        clear(@dist_usec); clear(@max_usec);
                     67: }
                     68:
                     69: END
                     70: {
                     71:        clear(@ts);
                     72:        time("%H:%M:%S  ");
                     73:        printf("Run queue latency (us):\n");
                     74:        print(@dist_usec);
                     75:        printf("Max run queue latency: %d ms\n", @max_usec[0] / 1000);
                     76:        clear(@dist_usec); clear(@max_usec);
                     77: }