Skip to content

Commit 55c41f2

Browse files
Yang Jihongacmel
authored andcommitted
perf help: Use HAVE_LIBTRACEEVENT to filter out unsupported commands
Commands such as kmem, kwork, lock, sched, trace and timechart depend on libtraceevent, these commands need to be isolated using HAVE_LIBTRACEEVENT macro when cmdlist generation. The output of the generate-cmdlist.sh script is as follows: # ./util/generate-cmdlist.sh /* Automatically generated by ./util/generate-cmdlist.sh */ struct cmdname_help { char name[16]; char help[80]; }; static struct cmdname_help common_cmds[] = { {"annotate", "Read perf.data (created by perf record) and display annotated code"}, {"archive", "Create archive with object files with build-ids found in perf.data file"}, {"bench", "General framework for benchmark suites"}, {"buildid-cache", "Manage build-id cache."}, {"buildid-list", "List the buildids in a perf.data file"}, {"c2c", "Shared Data C2C/HITM Analyzer."}, {"config", "Get and set variables in a configuration file."}, {"daemon", "Run record sessions on background"}, {"data", "Data file related processing"}, {"diff", "Read perf.data files and display the differential profile"}, {"evlist", "List the event names in a perf.data file"}, {"ftrace", "simple wrapper for kernel's ftrace functionality"}, {"inject", "Filter to augment the events stream with additional information"}, {"iostat", "Show I/O performance metrics"}, {"kallsyms", "Searches running kernel for symbols"}, {"kvm", "Tool to trace/measure kvm guest os"}, {"list", "List all symbolic event types"}, {"mem", "Profile memory accesses"}, {"record", "Run a command and record its profile into perf.data"}, {"report", "Read perf.data (created by perf record) and display the profile"}, {"script", "Read perf.data (created by perf record) and display trace output"}, {"stat", "Run a command and gather performance counter statistics"}, {"test", "Runs sanity tests."}, {"top", "System profiling tool."}, {"version", "display the version of perf binary"}, #ifdef HAVE_LIBELF_SUPPORT {"probe", "Define new dynamic tracepoints"}, #endif /* HAVE_LIBELF_SUPPORT */ #if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)) {"trace", "strace inspired tool"}, #endif /* HAVE_LIBTRACEEVENT && (HAVE_LIBAUDIT_SUPPORT || HAVE_SYSCALL_TABLE_SUPPORT) */ #ifdef HAVE_LIBTRACEEVENT {"kmem", "Tool to trace/measure kernel memory properties"}, {"kwork", "Tool to trace/measure kernel work properties (latencies)"}, {"lock", "Analyze lock events"}, {"sched", "Tool to trace/measure scheduler properties (latencies)"}, {"timechart", "Tool to visualize total system behavior during a workload"}, #endif /* HAVE_LIBTRACEEVENT */ }; Fixes: 378ef0f ("perf build: Use libtraceevent from the system") Signed-off-by: Yang Jihong <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a8f54d9 commit 55c41f2

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

tools/perf/command-list.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ perf-ftrace mainporcelain common
1616
perf-inject mainporcelain common
1717
perf-iostat mainporcelain common
1818
perf-kallsyms mainporcelain common
19-
perf-kmem mainporcelain common
19+
perf-kmem mainporcelain traceevent
2020
perf-kvm mainporcelain common
21-
perf-kwork mainporcelain common
21+
perf-kwork mainporcelain traceevent
2222
perf-list mainporcelain common
23-
perf-lock mainporcelain common
23+
perf-lock mainporcelain traceevent
2424
perf-mem mainporcelain common
2525
perf-probe mainporcelain full
2626
perf-record mainporcelain common
2727
perf-report mainporcelain common
28-
perf-sched mainporcelain common
28+
perf-sched mainporcelain traceevent
2929
perf-script mainporcelain common
3030
perf-stat mainporcelain common
3131
perf-test mainporcelain common
32-
perf-timechart mainporcelain common
32+
perf-timechart mainporcelain traceevent
3333
perf-top mainporcelain common
3434
perf-trace mainporcelain audit
3535
perf-version mainporcelain common

tools/perf/util/generate-cmdlist.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ do
3838
done
3939
echo "#endif /* HAVE_LIBELF_SUPPORT */"
4040

41-
echo "#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)"
41+
echo "#if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT))"
4242
sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt |
4343
sort |
4444
while read cmd
@@ -51,5 +51,20 @@ do
5151
p
5252
}' "Documentation/perf-$cmd.txt"
5353
done
54-
echo "#endif /* HAVE_LIBELF_SUPPORT */"
54+
echo "#endif /* HAVE_LIBTRACEEVENT && (HAVE_LIBAUDIT_SUPPORT || HAVE_SYSCALL_TABLE_SUPPORT) */"
55+
56+
echo "#ifdef HAVE_LIBTRACEEVENT"
57+
sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt |
58+
sort |
59+
while read cmd
60+
do
61+
sed -n '
62+
/^NAME/,/perf-'"$cmd"'/H
63+
${
64+
x
65+
s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
66+
p
67+
}' "Documentation/perf-$cmd.txt"
68+
done
69+
echo "#endif /* HAVE_LIBTRACEEVENT */"
5570
echo "};"

0 commit comments

Comments
 (0)