From: Dmitry V. Levin Date: Fri, 5 Jul 2019 11:09:37 +0000 (+0000) Subject: numa: enhance decoding of mode argument of mbind and set_mempolicy syscalls X-Git-Tag: v5.2~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ff53be435d3618a60443ab663103c191b557919;p=strace numa: enhance decoding of mode argument of mbind and set_mempolicy syscalls Implement decoding of memory policy mode flags introduced by Linux kernel commits v2.6.26-rc1~990 and v2.6.26-rc1~988. * xlat/mpol_mode_flags.in: New file. * numa.c: Include "xlat/mpol_mode_flags.h". (print_mode): Print MPOL_MODE_FLAGS part of mode argument as flags. * NEWS: Mention this. --- diff --git a/NEWS b/NEWS index 543e9e83..ddca2b2b 100644 --- a/NEWS +++ b/NEWS @@ -8,7 +8,7 @@ Noteworthy changes in release ?.? (????-??-??) * Improvements * Implemented decoding of open_tree, move_mount, fsopen, fsconfig, fsmount, and fspick syscalls. - * Enhanced decoding of bpf and clone syscalls. + * Enhanced decoding of bpf, clone, mbind, and set_mempolicy syscalls. * Updated lists of AT_*, AUDIT_*, BPF_*, CLONE_*, ETH_*, KEY_*, KVM_*, MPOL_*, TIPC_*, and V4L2_* constants. * Updated lists of ioctl commands from Linux 5.2. diff --git a/numa.c b/numa.c index f43f6115..4b39b1cd 100644 --- a/numa.c +++ b/numa.c @@ -53,12 +53,43 @@ SYS_FUNC(migrate_pages) } #include "xlat/mpol_modes.h" +#include "xlat/mpol_mode_flags.h" #include "xlat/mbind_flags.h" static void print_mode(struct tcb *const tcp, const kernel_ulong_t mode_arg) { - printxval64(mpol_modes, mode_arg, "MPOL_???"); + const kernel_ulong_t flags_mask = + MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES; + const kernel_ulong_t mode = mode_arg & ~flags_mask; + const unsigned int flags = mode_arg & flags_mask; + + if (!flags) { + printxval64(mpol_modes, mode, "MPOL_???"); + return; + } + + const char *mode_str = xlookup(mpol_modes, mode); + if (!mode_str) { + printflags64(mpol_mode_flags, mode_arg, "MPOL_???"); + return; + } + + if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) + tprintf("%#" PRI_klx, mode_arg); + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) + return; + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprints(" /* "); + + tprints(mode_str); + tprints("|"); + printflags_ex(flags, NULL, XLAT_STYLE_ABBREV, mpol_mode_flags, NULL); + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprints(" */"); } SYS_FUNC(mbind) diff --git a/xlat/mpol_mode_flags.in b/xlat/mpol_mode_flags.in new file mode 100644 index 00000000..eeef9534 --- /dev/null +++ b/xlat/mpol_mode_flags.in @@ -0,0 +1,2 @@ +MPOL_F_STATIC_NODES (1U << 15) +MPOL_F_RELATIVE_NODES (1U << 14)