From: mpi Date: Thu, 21 Jan 2021 13:19:25 +0000 (+0000) Subject: Make it possible to convert map arguments to long and insert nsecs in maps. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=03b76035ea8a602fd1ac9eed3049c9dd6a28fe71;p=openbsd Make it possible to convert map arguments to long and insert nsecs in maps. Necessary to measure latency, example below to better understand the kqueue select(2) regression: syscall:select:entry { @start[pid] = nsecs; } syscall:select:return { @usecs = hist((nsecs - @start[pid]) / 1000); } --- diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 64acf9eaef6..3eda0a638fd 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.26 2020/12/07 18:28:09 bluhm Exp $ */ +/* $OpenBSD: btrace.c,v 1.27 2021/01/21 13:19:25 mpi Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot @@ -1030,6 +1030,7 @@ baexpr2long(struct bt_arg *ba, struct dt_evt *dtev) long ba2long(struct bt_arg *ba, struct dt_evt *dtev) { + struct bt_var *bv; long val; switch (ba->ba_type) { @@ -1040,6 +1041,11 @@ ba2long(struct bt_arg *ba, struct dt_evt *dtev) ba = ba_read(ba); val = (long)ba->ba_value; break; + case B_AT_MAP: + bv = ba->ba_value; + val = ba2long(map_get((struct map *)bv->bv_value, + ba2str(ba->ba_key, dtev)), dtev); + break; case B_AT_BI_NSECS: val = builtin_nsecs(dtev); break; diff --git a/usr.sbin/btrace/map.c b/usr.sbin/btrace/map.c index f50f9abdca7..85e675d94f4 100644 --- a/usr.sbin/btrace/map.c +++ b/usr.sbin/btrace/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.11 2020/09/18 19:19:38 jasper Exp $ */ +/* $OpenBSD: map.c,v 1.12 2021/01/21 13:19:25 mpi Exp $ */ /* * Copyright (c) 2020 Martin Pieuchot @@ -138,6 +138,7 @@ map_insert(struct map *map, const char *key, struct bt_arg *bval, free(mep->mval); mep->mval = bval; break; + case B_AT_BI_NSECS: case B_AT_BI_RETVAL: free(mep->mval); mep->mval = ba_new(ba2long(bval, dtev), B_AT_LONG);