perf trace: Beautify the 'level' argument of setsockopt
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 8 Nov 2021 18:29:10 +0000 (15:29 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 12 Nov 2021 13:40:34 +0000 (10:40 -0300)
  # perf trace -e setsockopt
     0.000 ( 0.019 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 50, optval: 0x7ffee2c0c134, optlen: 4) = 0
     0.022 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 11, optval: 0x7ffee2c0c114, optlen: 4) = 0
     0.027 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 8, optval: 0x7ffee2c0c134, optlen: 4) = 0
     0.032 ( 0.002 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 10, optval: 0x7ffee2c0c134, optlen: 4) = 0
     0.036 ( 0.002 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 25, optval: 0x7ffee2c0c114, optlen: 4) = 0
     0.043 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: 1, optname: 62, optval: 0x7ffee2c0c0fc, optlen: 4) = 0
     0.055 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: 1, optname: 25)
  ^C#

So the simple straight STRARRAY method is not enough as SOL_SOCKET is
'1' in most architectures but some use 0xffff (alpha, mips, parisc and
sparc), so a followup patch will create a specialized scnprintf to cover
that.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index aa5d220..0b52e08 100644 (file)
@@ -1123,6 +1123,8 @@ static struct syscall_fmt syscall_fmts[] = {
          .arg = { [0] = STRARRAY(which, itimers), }, },
        { .name     = "setrlimit",
          .arg = { [0] = STRARRAY(resource, rlimit_resources), }, },
+       { .name     = "setsockopt",
+         .arg = { [1] = STRARRAY(level, socket_level), }, },
        { .name     = "socket",
          .arg = { [0] = STRARRAY(family, socket_families),
                   [1] = { .scnprintf = SCA_SK_TYPE, /* type */ },