lkml.org 
[lkml]   [2019]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 54/73] libperf: Add perf_evlist_mmap_ops::idx callback
Date
Adding perf_evlist_mmap_ops::idx callback to be called
in mmap_per_cpu and mmap_per_thread with current cpu and
thread indexes. It's used by current aux code, so perf
will used this callback to set aux index.

Link: http://lkml.kernel.org/n/tip-smr1w2e6j37ncbmsd1eet228@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/lib/evlist.c | 18 +++++++++++++-----
tools/perf/lib/include/internal/evlist.h | 4 ++++
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c
index 0f103c10d8ca..67b5f14f738f 100644
--- a/tools/perf/lib/evlist.c
+++ b/tools/perf/lib/evlist.c
@@ -397,7 +397,8 @@ mmap_per_evsel(struct perf_evlist *evlist, int idx,
}

static int
-mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp)
+mmap_per_thread(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp)
{
int thread;
int nr_threads = perf_thread_map__nr(evlist->threads);
@@ -406,6 +407,9 @@ mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp)
int output = -1;
int output_overwrite = -1;

+ if (ops->idx)
+ ops->idx(evlist, mp, thread, false);
+
if (mmap_per_evsel(evlist, thread, mp, 0, thread,
&output, &output_overwrite))
goto out_unmap;
@@ -419,7 +423,8 @@ mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp)
}

static int
-mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp)
+mmap_per_cpu(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp)
{
int nr_threads = perf_thread_map__nr(evlist->threads);
int nr_cpus = perf_cpu_map__nr(evlist->cpus);
@@ -429,6 +434,9 @@ mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp)
int output = -1;
int output_overwrite = -1;

+ if (ops->idx)
+ ops->idx(evlist, mp, cpu, true);
+
for (thread = 0; thread < nr_threads; thread++) {
if (mmap_per_evsel(evlist, cpu, mp, cpu,
thread, &output, &output_overwrite))
@@ -462,15 +470,15 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist,
}

if (perf_cpu_map__empty(cpus))
- return mmap_per_thread(evlist, mp);
+ return mmap_per_thread(evlist, ops, mp);

- return mmap_per_cpu(evlist, mp);
+ return mmap_per_cpu(evlist, ops, mp);
}

int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
{
struct perf_mmap_param mp;
- struct perf_evlist_mmap_ops ops;
+ struct perf_evlist_mmap_ops ops = { 0 };

if (!evlist->mmap && perf_evlist__alloc_maps(evlist))
return -ENOMEM;
diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h
index 5a8706a81c0d..64522b8237be 100644
--- a/tools/perf/lib/include/internal/evlist.h
+++ b/tools/perf/lib/include/internal/evlist.h
@@ -27,7 +27,11 @@ struct perf_evlist {
struct perf_mmap **mmap_ovw;
};

+typedef void
+(*perf_evlist_mmap__cb_idx_t)(struct perf_evlist*, struct perf_mmap_param*, int, bool);
+
struct perf_evlist_mmap_ops {
+ perf_evlist_mmap__cb_idx_t idx;
};

int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
--
2.21.0
\
 
 \ /
  Last update: 2019-09-13 15:26    [W:0.399 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site