diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-31 16:34:47 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-01 12:02:40 -0400 |
| commit | 2c3e96291164d46e58ea064b778d5f8f747d6c6a (patch) | |
| tree | fe47a3b6ad0becd11258206da13723fe84c63105 /tools/perf | |
| parent | a215684e10484149313068e0a9ea1978ee36d4f7 (diff) | |
perf trace beautify ioctl: Beautify sound ioctl's 'cmd' arg
This time we try a new approach, using a copy of uapi/sound/asound.h we
auto generate the string tables, then include it in the ioctl cmd
beautifier.
This way either the sound developers will add the new commands to the
tools/ copy, like is happening with other areas of tools/include/ (bpf.h
comes to mind), or we'll be notified when building perf that our copy
drifted.
E.g.:
# perf trace -p 22084 -e ioctl 2>&1 | head -5
0.000 ( 0.068 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
0.344 ( 0.041 ms): alsa-sink-ALC3/22084 ioctl(fd: 46</dev/snd/controlC1>, cmd: SNDRV_CTL_ELEM_READ, arg: 0x7fe764018ee0) = 0
0.403 ( 0.011 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
0.427 ( 0.009 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_STATUS_EXT, arg: 0x7fe76c2e0b30) = 0
2.461 ( 0.042 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
#
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-8zuyf3e3u6jjcb2xzerw0kdi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/Makefile.perf | 26 | ||||
| -rw-r--r-- | tools/perf/trace/beauty/ioctl.c | 28 | ||||
| -rwxr-xr-x | tools/perf/trace/beauty/sndrv_ctl_ioctl.sh | 8 | ||||
| -rwxr-xr-x | tools/perf/trace/beauty/sndrv_pcm_ioctl.sh | 8 |
4 files changed, 63 insertions, 7 deletions
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 78654995b99f..d49354d340fd 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
| @@ -381,17 +381,31 @@ export INSTALL SHELL_PATH | |||
| 381 | 381 | ||
| 382 | SHELL = $(SHELL_PATH) | 382 | SHELL = $(SHELL_PATH) |
| 383 | 383 | ||
| 384 | drm_ioctl_outdir := $(OUTPUT)trace/beauty/generated/ioctl | 384 | beauty_ioctl_outdir := $(OUTPUT)trace/beauty/generated/ioctl |
| 385 | drm_ioctl_array := $(drm_ioctl_outdir)/drm_ioctl_array.c | 385 | drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c |
| 386 | drm_hdr_dir := $(srctree)/tools/include/uapi/drm | 386 | drm_hdr_dir := $(srctree)/tools/include/uapi/drm |
| 387 | drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh | 387 | drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh |
| 388 | 388 | ||
| 389 | # Create output directory if not already present | 389 | # Create output directory if not already present |
| 390 | _dummy := $(shell [ -d '$(drm_ioctl_outdir)' ] || mkdir -p '$(drm_ioctl_outdir)') | 390 | _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)') |
| 391 | 391 | ||
| 392 | $(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) | 392 | $(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) |
| 393 | $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ | 393 | $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ |
| 394 | 394 | ||
| 395 | sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c | ||
| 396 | sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound | ||
| 397 | sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh | ||
| 398 | |||
| 399 | $(sndrv_ctl_ioctl_array): $(sndrv_ctl_hdr_dir)/asound.h $(sndrv_ctl_ioctl_tbl) | ||
| 400 | $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(sndrv_ctl_hdr_dir) > $@ | ||
| 401 | |||
| 402 | sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c | ||
| 403 | sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound | ||
| 404 | sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh | ||
| 405 | |||
| 406 | $(sndrv_pcm_ioctl_array): $(sndrv_pcm_hdr_dir)/asound.h $(sndrv_pcm_ioctl_tbl) | ||
| 407 | $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(sndrv_pcm_hdr_dir) > $@ | ||
| 408 | |||
| 395 | all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) | 409 | all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) |
| 396 | 410 | ||
| 397 | $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) | 411 | $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) |
| @@ -486,7 +500,7 @@ endif | |||
| 486 | __build-dir = $(subst $(OUTPUT),,$(dir $@)) | 500 | __build-dir = $(subst $(OUTPUT),,$(dir $@)) |
| 487 | build-dir = $(if $(__build-dir),$(__build-dir),.) | 501 | build-dir = $(if $(__build-dir),$(__build-dir),.) |
| 488 | 502 | ||
| 489 | prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) | 503 | prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) $(sndrv_pcm_ioctl_array) $(sndrv_ctl_ioctl_array) |
| 490 | 504 | ||
| 491 | $(OUTPUT)%.o: %.c prepare FORCE | 505 | $(OUTPUT)%.o: %.c prepare FORCE |
| 492 | $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ | 506 | $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ |
| @@ -752,7 +766,9 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea | |||
| 752 | $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ | 766 | $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ |
| 753 | $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ | 767 | $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ |
| 754 | $(OUTPUT)pmu-events/pmu-events.c \ | 768 | $(OUTPUT)pmu-events/pmu-events.c \ |
| 755 | $(OUTPUT)$(drm_ioctl_array) | 769 | $(OUTPUT)$(drm_ioctl_array) \ |
| 770 | $(OUTPUT)$(sndrv_ctl_ioctl_array) \ | ||
| 771 | $(OUTPUT)$(sndrv_pcm_ioctl_array) | ||
| 756 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean | 772 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean |
| 757 | $(python-clean) | 773 | $(python-clean) |
| 758 | 774 | ||
diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c index 732489d141c4..ec5a5a499667 100644 --- a/tools/perf/trace/beauty/ioctl.c +++ b/tools/perf/trace/beauty/ioctl.c | |||
| @@ -55,6 +55,28 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, size_t size) | |||
| 55 | return scnprintf(bf, size, "(%#x, %#x)", 'd', nr); | 55 | return scnprintf(bf, size, "(%#x, %#x)", 'd', nr); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, char *bf, size_t size) | ||
| 59 | { | ||
| 60 | #include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c" | ||
| 61 | static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds); | ||
| 62 | |||
| 63 | if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL) | ||
| 64 | return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]); | ||
| 65 | |||
| 66 | return scnprintf(bf, size, "(%#x, %#x)", 'A', nr); | ||
| 67 | } | ||
| 68 | |||
| 69 | static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, char *bf, size_t size) | ||
| 70 | { | ||
| 71 | #include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c" | ||
| 72 | static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds); | ||
| 73 | |||
| 74 | if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL) | ||
| 75 | return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]); | ||
| 76 | |||
| 77 | return scnprintf(bf, size, "(%#x, %#x)", 'U', nr); | ||
| 78 | } | ||
| 79 | |||
| 58 | static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) | 80 | static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) |
| 59 | { | 81 | { |
| 60 | int dir = _IOC_DIR(cmd), | 82 | int dir = _IOC_DIR(cmd), |
| @@ -66,8 +88,10 @@ static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) | |||
| 66 | int type; | 88 | int type; |
| 67 | size_t (*scnprintf)(int nr, char *bf, size_t size); | 89 | size_t (*scnprintf)(int nr, char *bf, size_t size); |
| 68 | } ioctl_types[] = { /* Must be ordered by type */ | 90 | } ioctl_types[] = { /* Must be ordered by type */ |
| 69 | { .type = 'T', .scnprintf = ioctl__scnprintf_tty_cmd, }, | 91 | { .type = 'A', .scnprintf = ioctl__scnprintf_sndrv_pcm_cmd, }, |
| 70 | ['d' - 'T'] = { .type = 'd', .scnprintf = ioctl__scnprintf_drm_cmd, } | 92 | ['T' - 'A']= { .type = 'T', .scnprintf = ioctl__scnprintf_tty_cmd, }, |
| 93 | ['U' - 'A']= { .type = 'U', .scnprintf = ioctl__scnprintf_sndrv_ctl_cmd, }, | ||
| 94 | ['d' - 'A'] = { .type = 'd', .scnprintf = ioctl__scnprintf_drm_cmd, } | ||
| 71 | }; | 95 | }; |
| 72 | const int nr_types = ARRAY_SIZE(ioctl_types); | 96 | const int nr_types = ARRAY_SIZE(ioctl_types); |
| 73 | 97 | ||
diff --git a/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh b/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh new file mode 100755 index 000000000000..aad5ab130539 --- /dev/null +++ b/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | sound_header_dir=$1 | ||
| 4 | |||
| 5 | printf "static const char *sndrv_ctl_ioctl_cmds[] = {\n" | ||
| 6 | grep "^#define[\t ]\+SNDRV_CTL_IOCTL_" $sound_header_dir/asound.h | \ | ||
| 7 | sed -r 's/^#define +SNDRV_CTL_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.U., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g' | ||
| 8 | printf "};\n" | ||
diff --git a/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh b/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh new file mode 100755 index 000000000000..b7e9ef6b2f55 --- /dev/null +++ b/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | sound_header_dir=$1 | ||
| 4 | |||
| 5 | printf "static const char *sndrv_pcm_ioctl_cmds[] = {\n" | ||
| 6 | grep "^#define[\t ]\+SNDRV_PCM_IOCTL_" $sound_header_dir/asound.h | \ | ||
| 7 | sed -r 's/^#define +SNDRV_PCM_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.A., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g' | ||
| 8 | printf "};\n" | ||
