lkml.org 
[lkml]   [2021]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v1 12/37] perf evlist: add multithreading to evlist__enable
Date
In this patch, evlist__for_each_evsel_cpu is used in evlist__enable to
allow it to run in parallel.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
---
tools/perf/util/evlist.c | 41 +++++++++++++---------------------------
1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 5c82246813c51c51..fbe2d6ed8ecc8f21 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -552,37 +552,22 @@ void evlist__disable_evsel(struct evlist *evlist, char *evsel_name)
__evlist__disable(evlist, evsel_name);
}

-static void __evlist__enable(struct evlist *evlist, char *evsel_name)
+static int __evlist__enable_evsel_cpu_fun(struct evlist *evlist __maybe_unused,
+ struct evsel *pos, int cpu, void *args)
{
- struct evsel *pos;
- struct affinity affinity;
- int cpu, i, cpu_idx;
+ char *evsel_name = args;

- if (affinity__setup(&affinity) < 0)
- return;
-
- evlist__for_each_cpu(evlist, i, cpu) {
- affinity__set(&affinity, cpu);
+ if (evsel__strcmp(pos, evsel_name))
+ return 0;
+ if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ return 0;
+ evsel__enable_cpu(pos, cpu);
+ return 0;
+}

- evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
- continue;
- cpu_idx = evsel__find_cpu(pos, cpu);
- if (cpu_idx < 0)
- continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
- continue;
- evsel__enable_cpu(pos, cpu_idx);
- }
- }
- affinity__cleanup(&affinity);
- evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
- continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
- continue;
- pos->disabled = false;
- }
+static void __evlist__enable(struct evlist *evlist, char *evsel_name)
+{
+ evlist__for_each_evsel_cpu(evlist, __evlist__enable_evsel_cpu_fun, evsel_name);

/*
* Even single event sets the 'enabled' for evlist,
--
2.31.1
\
 
 \ /
  Last update: 2021-08-21 11:21    [W:0.279 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site