Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf trace: Move perf_flags beautifier to tools/perf/trace/beauty/

To reduce the size of builtin-trace.c.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-8r3gmymyn3r0ynt4yuzspp9g@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+44 -44
+1 -44
tools/perf/builtin-trace.c
··· 56 56 # define MSG_CMSG_CLOEXEC 0x40000000 57 57 #endif 58 58 59 - #ifndef PERF_FLAG_FD_NO_GROUP 60 - # define PERF_FLAG_FD_NO_GROUP (1UL << 0) 61 - #endif 62 - 63 - #ifndef PERF_FLAG_FD_OUTPUT 64 - # define PERF_FLAG_FD_OUTPUT (1UL << 1) 65 - #endif 66 - 67 - #ifndef PERF_FLAG_PID_CGROUP 68 - # define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */ 69 - #endif 70 - 71 - #ifndef PERF_FLAG_FD_CLOEXEC 72 - # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ 73 - #endif 74 - 75 59 struct trace { 76 60 struct perf_tool tool; 77 61 struct syscalltbl *sctbl; ··· 658 674 659 675 #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags 660 676 661 - static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, 662 - struct syscall_arg *arg) 663 - { 664 - int printed = 0, flags = arg->val; 665 - 666 - if (flags == 0) 667 - return 0; 668 - 669 - #define P_FLAG(n) \ 670 - if (flags & PERF_FLAG_##n) { \ 671 - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 672 - flags &= ~PERF_FLAG_##n; \ 673 - } 674 - 675 - P_FLAG(FD_NO_GROUP); 676 - P_FLAG(FD_OUTPUT); 677 - P_FLAG(PID_CGROUP); 678 - P_FLAG(FD_CLOEXEC); 679 - #undef P_FLAG 680 - 681 - if (flags) 682 - printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 683 - 684 - return printed; 685 - } 686 - 687 - #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags 688 - 689 677 static size_t syscall_arg__scnprintf_pipe_flags(char *bf, size_t size, 690 678 struct syscall_arg *arg) 691 679 { ··· 850 894 #include "trace/beauty/pid.c" 851 895 #include "trace/beauty/mmap.c" 852 896 #include "trace/beauty/mode_t.c" 897 + #include "trace/beauty/perf_event_open.c" 853 898 #include "trace/beauty/sched_policy.c" 854 899 #include "trace/beauty/socket_type.c" 855 900 #include "trace/beauty/waitid_options.c"
+43
tools/perf/trace/beauty/perf_event_open.c
··· 1 + #ifndef PERF_FLAG_FD_NO_GROUP 2 + # define PERF_FLAG_FD_NO_GROUP (1UL << 0) 3 + #endif 4 + 5 + #ifndef PERF_FLAG_FD_OUTPUT 6 + # define PERF_FLAG_FD_OUTPUT (1UL << 1) 7 + #endif 8 + 9 + #ifndef PERF_FLAG_PID_CGROUP 10 + # define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */ 11 + #endif 12 + 13 + #ifndef PERF_FLAG_FD_CLOEXEC 14 + # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ 15 + #endif 16 + 17 + static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, 18 + struct syscall_arg *arg) 19 + { 20 + int printed = 0, flags = arg->val; 21 + 22 + if (flags == 0) 23 + return 0; 24 + 25 + #define P_FLAG(n) \ 26 + if (flags & PERF_FLAG_##n) { \ 27 + printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 28 + flags &= ~PERF_FLAG_##n; \ 29 + } 30 + 31 + P_FLAG(FD_NO_GROUP); 32 + P_FLAG(FD_OUTPUT); 33 + P_FLAG(PID_CGROUP); 34 + P_FLAG(FD_CLOEXEC); 35 + #undef P_FLAG 36 + 37 + if (flags) 38 + printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 39 + 40 + return printed; 41 + } 42 + 43 + #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags