diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-13 11:05:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-14 07:57:53 -0400 |
commit | df4cb1678e2ea91eb66665f00c4a43d898a12697 (patch) | |
tree | df655ec90b7283f7409d5b956bdd340fcb81481b | |
parent | a355a61e43484ac02553b34b5f84ee84ca765fd6 (diff) |
perf trace: Move mmap beautifiers to trace/beauty/ directory
To better organize all these beautifiers.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-zbr27mdy9ssdhux3ib2nfa7j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 159 | ||||
-rw-r--r-- | tools/perf/trace/beauty/mmap.c | 158 |
2 files changed, 159 insertions, 158 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 653d4c7422e9..abd5a94f5dbe 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -39,7 +39,6 @@ | |||
39 | 39 | ||
40 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ | 40 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <sys/mman.h> | ||
43 | #include <linux/futex.h> | 42 | #include <linux/futex.h> |
44 | #include <linux/err.h> | 43 | #include <linux/err.h> |
45 | #include <linux/seccomp.h> | 44 | #include <linux/seccomp.h> |
@@ -49,22 +48,6 @@ | |||
49 | #include <linux/random.h> | 48 | #include <linux/random.h> |
50 | 49 | ||
51 | /* For older distros: */ | 50 | /* For older distros: */ |
52 | #ifndef MAP_STACK | ||
53 | # define MAP_STACK 0x20000 | ||
54 | #endif | ||
55 | |||
56 | #ifndef MADV_HWPOISON | ||
57 | # define MADV_HWPOISON 100 | ||
58 | |||
59 | #endif | ||
60 | |||
61 | #ifndef MADV_MERGEABLE | ||
62 | # define MADV_MERGEABLE 12 | ||
63 | #endif | ||
64 | |||
65 | #ifndef MADV_UNMERGEABLE | ||
66 | # define MADV_UNMERGEABLE 13 | ||
67 | #endif | ||
68 | 51 | ||
69 | #ifndef EFD_SEMAPHORE | 52 | #ifndef EFD_SEMAPHORE |
70 | # define EFD_SEMAPHORE 1 | 53 | # define EFD_SEMAPHORE 1 |
@@ -429,147 +412,6 @@ static size_t syscall_arg__scnprintf_int(char *bf, size_t size, | |||
429 | 412 | ||
430 | #define SCA_INT syscall_arg__scnprintf_int | 413 | #define SCA_INT syscall_arg__scnprintf_int |
431 | 414 | ||
432 | static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, | ||
433 | struct syscall_arg *arg) | ||
434 | { | ||
435 | int printed = 0, prot = arg->val; | ||
436 | |||
437 | if (prot == PROT_NONE) | ||
438 | return scnprintf(bf, size, "NONE"); | ||
439 | #define P_MMAP_PROT(n) \ | ||
440 | if (prot & PROT_##n) { \ | ||
441 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
442 | prot &= ~PROT_##n; \ | ||
443 | } | ||
444 | |||
445 | P_MMAP_PROT(EXEC); | ||
446 | P_MMAP_PROT(READ); | ||
447 | P_MMAP_PROT(WRITE); | ||
448 | #ifdef PROT_SEM | ||
449 | P_MMAP_PROT(SEM); | ||
450 | #endif | ||
451 | P_MMAP_PROT(GROWSDOWN); | ||
452 | P_MMAP_PROT(GROWSUP); | ||
453 | #undef P_MMAP_PROT | ||
454 | |||
455 | if (prot) | ||
456 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", prot); | ||
457 | |||
458 | return printed; | ||
459 | } | ||
460 | |||
461 | #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot | ||
462 | |||
463 | static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, | ||
464 | struct syscall_arg *arg) | ||
465 | { | ||
466 | int printed = 0, flags = arg->val; | ||
467 | |||
468 | #define P_MMAP_FLAG(n) \ | ||
469 | if (flags & MAP_##n) { \ | ||
470 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
471 | flags &= ~MAP_##n; \ | ||
472 | } | ||
473 | |||
474 | P_MMAP_FLAG(SHARED); | ||
475 | P_MMAP_FLAG(PRIVATE); | ||
476 | #ifdef MAP_32BIT | ||
477 | P_MMAP_FLAG(32BIT); | ||
478 | #endif | ||
479 | P_MMAP_FLAG(ANONYMOUS); | ||
480 | P_MMAP_FLAG(DENYWRITE); | ||
481 | P_MMAP_FLAG(EXECUTABLE); | ||
482 | P_MMAP_FLAG(FILE); | ||
483 | P_MMAP_FLAG(FIXED); | ||
484 | P_MMAP_FLAG(GROWSDOWN); | ||
485 | #ifdef MAP_HUGETLB | ||
486 | P_MMAP_FLAG(HUGETLB); | ||
487 | #endif | ||
488 | P_MMAP_FLAG(LOCKED); | ||
489 | P_MMAP_FLAG(NONBLOCK); | ||
490 | P_MMAP_FLAG(NORESERVE); | ||
491 | P_MMAP_FLAG(POPULATE); | ||
492 | P_MMAP_FLAG(STACK); | ||
493 | #ifdef MAP_UNINITIALIZED | ||
494 | P_MMAP_FLAG(UNINITIALIZED); | ||
495 | #endif | ||
496 | #undef P_MMAP_FLAG | ||
497 | |||
498 | if (flags) | ||
499 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
500 | |||
501 | return printed; | ||
502 | } | ||
503 | |||
504 | #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags | ||
505 | |||
506 | static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, | ||
507 | struct syscall_arg *arg) | ||
508 | { | ||
509 | int printed = 0, flags = arg->val; | ||
510 | |||
511 | #define P_MREMAP_FLAG(n) \ | ||
512 | if (flags & MREMAP_##n) { \ | ||
513 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
514 | flags &= ~MREMAP_##n; \ | ||
515 | } | ||
516 | |||
517 | P_MREMAP_FLAG(MAYMOVE); | ||
518 | #ifdef MREMAP_FIXED | ||
519 | P_MREMAP_FLAG(FIXED); | ||
520 | #endif | ||
521 | #undef P_MREMAP_FLAG | ||
522 | |||
523 | if (flags) | ||
524 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
525 | |||
526 | return printed; | ||
527 | } | ||
528 | |||
529 | #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags | ||
530 | |||
531 | static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, | ||
532 | struct syscall_arg *arg) | ||
533 | { | ||
534 | int behavior = arg->val; | ||
535 | |||
536 | switch (behavior) { | ||
537 | #define P_MADV_BHV(n) case MADV_##n: return scnprintf(bf, size, #n) | ||
538 | P_MADV_BHV(NORMAL); | ||
539 | P_MADV_BHV(RANDOM); | ||
540 | P_MADV_BHV(SEQUENTIAL); | ||
541 | P_MADV_BHV(WILLNEED); | ||
542 | P_MADV_BHV(DONTNEED); | ||
543 | P_MADV_BHV(REMOVE); | ||
544 | P_MADV_BHV(DONTFORK); | ||
545 | P_MADV_BHV(DOFORK); | ||
546 | P_MADV_BHV(HWPOISON); | ||
547 | #ifdef MADV_SOFT_OFFLINE | ||
548 | P_MADV_BHV(SOFT_OFFLINE); | ||
549 | #endif | ||
550 | P_MADV_BHV(MERGEABLE); | ||
551 | P_MADV_BHV(UNMERGEABLE); | ||
552 | #ifdef MADV_HUGEPAGE | ||
553 | P_MADV_BHV(HUGEPAGE); | ||
554 | #endif | ||
555 | #ifdef MADV_NOHUGEPAGE | ||
556 | P_MADV_BHV(NOHUGEPAGE); | ||
557 | #endif | ||
558 | #ifdef MADV_DONTDUMP | ||
559 | P_MADV_BHV(DONTDUMP); | ||
560 | #endif | ||
561 | #ifdef MADV_DODUMP | ||
562 | P_MADV_BHV(DODUMP); | ||
563 | #endif | ||
564 | #undef P_MADV_PHV | ||
565 | default: break; | ||
566 | } | ||
567 | |||
568 | return scnprintf(bf, size, "%#x", behavior); | ||
569 | } | ||
570 | |||
571 | #define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior | ||
572 | |||
573 | static size_t syscall_arg__scnprintf_flock(char *bf, size_t size, | 415 | static size_t syscall_arg__scnprintf_flock(char *bf, size_t size, |
574 | struct syscall_arg *arg) | 416 | struct syscall_arg *arg) |
575 | { | 417 | { |
@@ -1145,6 +987,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, | |||
1145 | .arg_parm = { [arg] = &strarray__##array, } | 987 | .arg_parm = { [arg] = &strarray__##array, } |
1146 | 988 | ||
1147 | #include "trace/beauty/pid.c" | 989 | #include "trace/beauty/pid.c" |
990 | #include "trace/beauty/mmap.c" | ||
1148 | #include "trace/beauty/mode_t.c" | 991 | #include "trace/beauty/mode_t.c" |
1149 | #include "trace/beauty/sched_policy.c" | 992 | #include "trace/beauty/sched_policy.c" |
1150 | #include "trace/beauty/waitid_options.c" | 993 | #include "trace/beauty/waitid_options.c" |
diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c new file mode 100644 index 000000000000..3444a4d5382d --- /dev/null +++ b/tools/perf/trace/beauty/mmap.c | |||
@@ -0,0 +1,158 @@ | |||
1 | #include <sys/mman.h> | ||
2 | |||
3 | static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, | ||
4 | struct syscall_arg *arg) | ||
5 | { | ||
6 | int printed = 0, prot = arg->val; | ||
7 | |||
8 | if (prot == PROT_NONE) | ||
9 | return scnprintf(bf, size, "NONE"); | ||
10 | #define P_MMAP_PROT(n) \ | ||
11 | if (prot & PROT_##n) { \ | ||
12 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
13 | prot &= ~PROT_##n; \ | ||
14 | } | ||
15 | |||
16 | P_MMAP_PROT(EXEC); | ||
17 | P_MMAP_PROT(READ); | ||
18 | P_MMAP_PROT(WRITE); | ||
19 | #ifdef PROT_SEM | ||
20 | P_MMAP_PROT(SEM); | ||
21 | #endif | ||
22 | P_MMAP_PROT(GROWSDOWN); | ||
23 | P_MMAP_PROT(GROWSUP); | ||
24 | #undef P_MMAP_PROT | ||
25 | |||
26 | if (prot) | ||
27 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", prot); | ||
28 | |||
29 | return printed; | ||
30 | } | ||
31 | |||
32 | #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot | ||
33 | |||
34 | #ifndef MAP_STACK | ||
35 | # define MAP_STACK 0x20000 | ||
36 | #endif | ||
37 | |||
38 | static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, | ||
39 | struct syscall_arg *arg) | ||
40 | { | ||
41 | int printed = 0, flags = arg->val; | ||
42 | |||
43 | #define P_MMAP_FLAG(n) \ | ||
44 | if (flags & MAP_##n) { \ | ||
45 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
46 | flags &= ~MAP_##n; \ | ||
47 | } | ||
48 | |||
49 | P_MMAP_FLAG(SHARED); | ||
50 | P_MMAP_FLAG(PRIVATE); | ||
51 | #ifdef MAP_32BIT | ||
52 | P_MMAP_FLAG(32BIT); | ||
53 | #endif | ||
54 | P_MMAP_FLAG(ANONYMOUS); | ||
55 | P_MMAP_FLAG(DENYWRITE); | ||
56 | P_MMAP_FLAG(EXECUTABLE); | ||
57 | P_MMAP_FLAG(FILE); | ||
58 | P_MMAP_FLAG(FIXED); | ||
59 | P_MMAP_FLAG(GROWSDOWN); | ||
60 | #ifdef MAP_HUGETLB | ||
61 | P_MMAP_FLAG(HUGETLB); | ||
62 | #endif | ||
63 | P_MMAP_FLAG(LOCKED); | ||
64 | P_MMAP_FLAG(NONBLOCK); | ||
65 | P_MMAP_FLAG(NORESERVE); | ||
66 | P_MMAP_FLAG(POPULATE); | ||
67 | P_MMAP_FLAG(STACK); | ||
68 | #ifdef MAP_UNINITIALIZED | ||
69 | P_MMAP_FLAG(UNINITIALIZED); | ||
70 | #endif | ||
71 | #undef P_MMAP_FLAG | ||
72 | |||
73 | if (flags) | ||
74 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
75 | |||
76 | return printed; | ||
77 | } | ||
78 | |||
79 | #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags | ||
80 | |||
81 | static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, | ||
82 | struct syscall_arg *arg) | ||
83 | { | ||
84 | int printed = 0, flags = arg->val; | ||
85 | |||
86 | #define P_MREMAP_FLAG(n) \ | ||
87 | if (flags & MREMAP_##n) { \ | ||
88 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
89 | flags &= ~MREMAP_##n; \ | ||
90 | } | ||
91 | |||
92 | P_MREMAP_FLAG(MAYMOVE); | ||
93 | #ifdef MREMAP_FIXED | ||
94 | P_MREMAP_FLAG(FIXED); | ||
95 | #endif | ||
96 | #undef P_MREMAP_FLAG | ||
97 | |||
98 | if (flags) | ||
99 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
100 | |||
101 | return printed; | ||
102 | } | ||
103 | |||
104 | #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags | ||
105 | |||
106 | #ifndef MADV_HWPOISON | ||
107 | #define MADV_HWPOISON 100 | ||
108 | #endif | ||
109 | |||
110 | #ifndef MADV_MERGEABLE | ||
111 | #define MADV_MERGEABLE 12 | ||
112 | #endif | ||
113 | |||
114 | #ifndef MADV_UNMERGEABLE | ||
115 | #define MADV_UNMERGEABLE 13 | ||
116 | #endif | ||
117 | |||
118 | static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, | ||
119 | struct syscall_arg *arg) | ||
120 | { | ||
121 | int behavior = arg->val; | ||
122 | |||
123 | switch (behavior) { | ||
124 | #define P_MADV_BHV(n) case MADV_##n: return scnprintf(bf, size, #n) | ||
125 | P_MADV_BHV(NORMAL); | ||
126 | P_MADV_BHV(RANDOM); | ||
127 | P_MADV_BHV(SEQUENTIAL); | ||
128 | P_MADV_BHV(WILLNEED); | ||
129 | P_MADV_BHV(DONTNEED); | ||
130 | P_MADV_BHV(REMOVE); | ||
131 | P_MADV_BHV(DONTFORK); | ||
132 | P_MADV_BHV(DOFORK); | ||
133 | P_MADV_BHV(HWPOISON); | ||
134 | #ifdef MADV_SOFT_OFFLINE | ||
135 | P_MADV_BHV(SOFT_OFFLINE); | ||
136 | #endif | ||
137 | P_MADV_BHV(MERGEABLE); | ||
138 | P_MADV_BHV(UNMERGEABLE); | ||
139 | #ifdef MADV_HUGEPAGE | ||
140 | P_MADV_BHV(HUGEPAGE); | ||
141 | #endif | ||
142 | #ifdef MADV_NOHUGEPAGE | ||
143 | P_MADV_BHV(NOHUGEPAGE); | ||
144 | #endif | ||
145 | #ifdef MADV_DONTDUMP | ||
146 | P_MADV_BHV(DONTDUMP); | ||
147 | #endif | ||
148 | #ifdef MADV_DODUMP | ||
149 | P_MADV_BHV(DODUMP); | ||
150 | #endif | ||
151 | #undef P_MADV_PHV | ||
152 | default: break; | ||
153 | } | ||
154 | |||
155 | return scnprintf(bf, size, "%#x", behavior); | ||
156 | } | ||
157 | |||
158 | #define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior | ||