]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf tools: Rename group to topdown
authorKan Liang <kan.liang@linux.intel.com>
Fri, 11 Sep 2020 14:48:05 +0000 (07:48 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Sep 2020 18:47:55 +0000 (15:47 -0300)
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>
tools/perf/arch/x86/util/Build
tools/perf/arch/x86/util/group.c [deleted file]
tools/perf/arch/x86/util/topdown.c [new file with mode: 0644]
tools/perf/builtin-stat.c
tools/perf/util/Build
tools/perf/util/group.h [deleted file]
tools/perf/util/topdown.c [new file with mode: 0644]
tools/perf/util/topdown.h [new file with mode: 0644]

index 47f9c56e744f8c3751e6cf22ec9f738182ea8370..347c39b960eba845be4d84893145bbe50f7522b5 100644 (file)
@@ -3,7 +3,7 @@ perf-y += tsc.o
 perf-y += pmu.o
 perf-y += kvm-stat.o
 perf-y += perf_regs.o
-perf-y += group.o
+perf-y += topdown.o
 perf-y += machine.o
 perf-y += event.o
 
diff --git a/tools/perf/arch/x86/util/group.c b/tools/perf/arch/x86/util/group.c
deleted file mode 100644 (file)
index e2f8034..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <stdio.h>
-#include "api/fs/fs.h"
-#include "util/group.h"
-
-/*
- * Check whether we can use a group for top down.
- * Without a group may get bad results due to multiplexing.
- */
-bool arch_topdown_check_group(bool *warn)
-{
-       int n;
-
-       if (sysctl__read_int("kernel/nmi_watchdog", &n) < 0)
-               return false;
-       if (n > 0) {
-               *warn = true;
-               return false;
-       }
-       return true;
-}
-
-void arch_topdown_group_warn(void)
-{
-       fprintf(stderr,
-               "nmi_watchdog enabled with topdown. May give wrong results.\n"
-               "Disable with echo 0 > /proc/sys/kernel/nmi_watchdog\n");
-}
diff --git a/tools/perf/arch/x86/util/topdown.c b/tools/perf/arch/x86/util/topdown.c
new file mode 100644 (file)
index 0000000..597e963
--- /dev/null
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <stdio.h>
+#include "api/fs/fs.h"
+#include "util/topdown.h"
+
+/*
+ * Check whether we can use a group for top down.
+ * Without a group may get bad results due to multiplexing.
+ */
+bool arch_topdown_check_group(bool *warn)
+{
+       int n;
+
+       if (sysctl__read_int("kernel/nmi_watchdog", &n) < 0)
+               return false;
+       if (n > 0) {
+               *warn = true;
+               return false;
+       }
+       return true;
+}
+
+void arch_topdown_group_warn(void)
+{
+       fprintf(stderr,
+               "nmi_watchdog enabled with topdown. May give wrong results.\n"
+               "Disable with echo 0 > /proc/sys/kernel/nmi_watchdog\n");
+}
index 7f8d756d9408ffdfece3c10a79ccc011ad9b29dd..a39bb28b44f93484f8d83cda3b946e5a0fccc031 100644 (file)
@@ -56,7 +56,7 @@
 #include "util/cpumap.h"
 #include "util/thread_map.h"
 #include "util/counts.h"
-#include "util/group.h"
+#include "util/topdown.h"
 #include "util/session.h"
 #include "util/tool.h"
 #include "util/string2.h"
@@ -1481,55 +1481,6 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)
        return 0;
 }
 
-static 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)
-{
-}
-
 /*
  * Add default attributes, if there were no attributes specified or
  * if -d/--detailed, -d -d or -d -d -d is used:
index cd5e41960e64accc89eebc02b0f3349096db9ba7..eebbd5223caee11ea4ca8cba7ae64d53cecc1d37 100644 (file)
@@ -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/group.h b/tools/perf/util/group.h
deleted file mode 100644 (file)
index f36c7e3..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef GROUP_H
-#define GROUP_H 1
-
-bool arch_topdown_check_group(bool *warn);
-void arch_topdown_group_warn(void);
-
-#endif
diff --git a/tools/perf/util/topdown.c b/tools/perf/util/topdown.c
new file mode 100644 (file)
index 0000000..a085b3c
--- /dev/null
@@ -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/topdown.h b/tools/perf/util/topdown.h
new file mode 100644 (file)
index 0000000..e3d70e9
--- /dev/null
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#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