perf trace beauty: Always show mmap prot even though PROT_NONE
authorChangbin Du <changbin.du@huawei.com>
Wed, 22 May 2024 03:35:42 +0000 (11:35 +0800)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 30 May 2024 05:48:23 +0000 (22:48 -0700)
PROT_NONE is also useful information, so do not omit the mmap prot even
though it is 0. syscall_arg__scnprintf_mmap_prot() could print PROT_NONE
for prot 0.

Before: PROT_NONE is not shown.
$ sudo perf trace -e syscalls:sys_enter_mmap --filter prot==0  -- ls
     0.000 ls/2979231 syscalls:sys_enter_mmap(len: 4220888, flags: PRIVATE|ANONYMOUS)

After: PROT_NONE is displayed.
$ sudo perf trace -e syscalls:sys_enter_mmap --filter prot==0  -- ls
     0.000 ls/2975708 syscalls:sys_enter_mmap(len: 4220888, prot: NONE, flags: PRIVATE|ANONYMOUS)

Signed-off-by: Changbin Du <changbin.du@huawei.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240522033542.1359421-3-changbin.du@huawei.com
tools/perf/builtin-trace.c

index a36e98c7a1c5a8e9ed66b2788d8b660d319942ed..c42bc608954ee08db86b2a25db0d653283916cd0 100644 (file)
@@ -1033,7 +1033,7 @@ static const struct syscall_fmt syscall_fmts[] = {
 #if defined(__s390x__)
        .alias = "old_mmap",
 #endif
-         .arg = { [2] = { .scnprintf = SCA_MMAP_PROT,  /* prot */ },
+         .arg = { [2] = { .scnprintf = SCA_MMAP_PROT, .show_zero = true, /* prot */ },
                   [3] = { .scnprintf = SCA_MMAP_FLAGS, /* flags */
                           .strtoul   = STUL_STRARRAY_FLAGS,
                           .parm      = &strarray__mmap_flags, },
@@ -1050,7 +1050,7 @@ static const struct syscall_fmt syscall_fmts[] = {
                   [4] = { .scnprintf = SCA_MOVE_MOUNT_FLAGS, /* flags */ }, }, },
        { .name     = "mprotect",
          .arg = { [0] = { .scnprintf = SCA_HEX,        /* start */ },
-                  [2] = { .scnprintf = SCA_MMAP_PROT,  /* prot */ }, }, },
+                  [2] = { .scnprintf = SCA_MMAP_PROT, .show_zero = true, /* prot */ }, }, },
        { .name     = "mq_unlink",
          .arg = { [0] = { .scnprintf = SCA_FILENAME, /* u_name */ }, }, },
        { .name     = "mremap",     .hexret = true,
@@ -1084,7 +1084,7 @@ static const struct syscall_fmt syscall_fmts[] = {
          .arg = { [0] = { .scnprintf = SCA_INT,        /* key */ }, }, },
        { .name     = "pkey_mprotect",
          .arg = { [0] = { .scnprintf = SCA_HEX,        /* start */ },
-                  [2] = { .scnprintf = SCA_MMAP_PROT,  /* prot */ },
+                  [2] = { .scnprintf = SCA_MMAP_PROT, .show_zero = true, /* prot */ },
                   [3] = { .scnprintf = SCA_INT,        /* pkey */ }, }, },
        { .name     = "poll", .timeout = true, },
        { .name     = "ppoll", .timeout = true, },