diff options
author | Kan Liang <kan.liang@linux.intel.com> | 2020-09-11 07:48:05 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2020-09-17 15:47:55 -0300 |
commit | 687986bbeb668068d39a47658edf4d7a6414eefb (patch) | |
tree | 9e11e21b91c62f1bbba86effb82860e35ab01691 /tools/perf/util | |
parent | c57f5eaa094ee93b4e27f6624349bc90d41a4e68 (diff) | |
download | linux-687986bbeb668068d39a47658edf4d7a6414eefb.tar.bz2 |
perf tools: Rename group to topdown
The group.h/c only include TopDown group related functions. The name
"group" is too generic and inaccurate. Use the name "topdown" to replace
it.
Move topdown related functions to a dedicated file, topdown.c.
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200911144808.27603-2-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/Build | 1 | ||||
-rw-r--r-- | tools/perf/util/topdown.c | 53 | ||||
-rw-r--r-- | tools/perf/util/topdown.h (renamed from tools/perf/util/group.h) | 6 |
3 files changed, 58 insertions, 2 deletions
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index cd5e41960e64..eebbd5223cae 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -101,6 +101,7 @@ perf-y += call-path.o perf-y += rwsem.o perf-y += thread-stack.o perf-y += spark.o +perf-y += topdown.o perf-$(CONFIG_AUXTRACE) += auxtrace.o perf-$(CONFIG_AUXTRACE) += intel-pt-decoder/ perf-$(CONFIG_AUXTRACE) += intel-pt.o diff --git a/tools/perf/util/topdown.c b/tools/perf/util/topdown.c new file mode 100644 index 000000000000..a085b3c77c27 --- /dev/null +++ b/tools/perf/util/topdown.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <stdio.h> +#include "pmu.h" +#include "topdown.h" + +int topdown_filter_events(const char **attr, char **str, bool use_group) +{ + int off = 0; + int i; + int len = 0; + char *s; + + for (i = 0; attr[i]; i++) { + if (pmu_have_event("cpu", attr[i])) { + len += strlen(attr[i]) + 1; + attr[i - off] = attr[i]; + } else + off++; + } + attr[i - off] = NULL; + + *str = malloc(len + 1 + 2); + if (!*str) + return -1; + s = *str; + if (i - off == 0) { + *s = 0; + return 0; + } + if (use_group) + *s++ = '{'; + for (i = 0; attr[i]; i++) { + strcpy(s, attr[i]); + s += strlen(s); + *s++ = ','; + } + if (use_group) { + s[-1] = '}'; + *s = 0; + } else + s[-1] = 0; + return 0; +} + +__weak bool arch_topdown_check_group(bool *warn) +{ + *warn = false; + return false; +} + +__weak void arch_topdown_group_warn(void) +{ +} diff --git a/tools/perf/util/group.h b/tools/perf/util/topdown.h index f36c7e31780a..e3d70e95f4f1 100644 --- a/tools/perf/util/group.h +++ b/tools/perf/util/topdown.h @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef GROUP_H -#define GROUP_H 1 +#ifndef TOPDOWN_H +#define TOPDOWN_H 1 bool arch_topdown_check_group(bool *warn); void arch_topdown_group_warn(void); +int topdown_filter_events(const char **attr, char **str, bool use_group); + #endif |