Hi, I would like to show the time spent in userland also when analyzing kernel stack in flame graph. Here are examples when building a bsd kernel on a 4 core machine.
kernel only http://bluhm.genua.de/perform/results/2021-06-21T09%3A44%3A18Z/2021-06-21T00%3A00%3A00Z/btrace/time_-lp_make_-CGENERIC.MP_-j4_-s-btrace-kstack.1.svg kernel + userland http://bluhm.genua.de/perform/results/2021-06-21T09%3A44%3A18Z/2021-06-21T00%3A00%3A00Z/btrace/time_-lp_make_-CGENERIC.MP_-j4_-s-btrace-kstack.2.svg To evaluate the performance of the system you have to compare time spent in kernel with activity in userland. Only when you see both, you get the whole picture. Goal is to optimize the kernel to spend more time in userland tasks. No information is lost. Wenn you click on the kernel field in the kernel + userland graph, you get that same information as in kernel only. In the old graph you see one @[ field. This is a parsing bug as @[]: 87353 is not a valid line for flame graph generation. This is the time spent in userland and my diff makes it explicit. ok? bluhm Index: usr.sbin/btrace/btrace.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/btrace/btrace.c,v retrieving revision 1.37 diff -u -p -r1.37 btrace.c --- usr.sbin/btrace/btrace.c 23 Jun 2021 11:24:01 -0000 1.37 +++ usr.sbin/btrace/btrace.c 25 Jun 2021 22:44:15 -0000 @@ -638,8 +638,10 @@ builtin_stack(struct dt_evt *dtev, int k size_t i; int sz; - if (!kernel || st->st_count == 0) + if (!kernel) return ""; + if (st->st_count == 0) + return "\nuserland\n"; buf[0] = '\0'; bp = buf; @@ -658,7 +660,7 @@ builtin_stack(struct dt_evt *dtev, int k bp += l; sz -= l; } - snprintf(bp, sz, "\n"); + snprintf(bp, sz, "\nkernel\n"); return buf; }
