[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230315145112.186603-3-leo.yan@linaro.org>
Date: Wed, 15 Mar 2023 22:50:58 +0800
From: Leo Yan <leo.yan@...aro.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
John Garry <john.g.garry@...cle.com>,
James Clark <james.clark@....com>,
Adrian Hunter <adrian.hunter@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Cc: Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v5 02/16] perf kvm: Add pointer to 'perf_kvm_stat' in kvm event
Sometimes, handling kvm events needs to base on global variables, e.g.
when read event counts we need to know the target vcpu ID; the global
variables are stored in structure perf_kvm_stat.
This patch adds add a 'perf_kvm_stat' pointer in kvm event structure,
it is to be used by later refactoring.
Signed-off-by: Leo Yan <leo.yan@...aro.org>
Reviewed-by: James Clark <james.clark@....com>
---
tools/perf/builtin-kvm.c | 6 ++++--
tools/perf/util/kvm-stat.h | 5 +++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 0172e5b0d26e..3d2560ec6b37 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -209,7 +209,8 @@ static bool kvm_event_expand(struct kvm_event *event, int vcpu_id)
return true;
}
-static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
+static struct kvm_event *kvm_alloc_init_event(struct perf_kvm_stat *kvm,
+ struct event_key *key)
{
struct kvm_event *event;
@@ -219,6 +220,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
return NULL;
}
+ event->perf_kvm = kvm;
event->key = *key;
init_stats(&event->total.stats);
return event;
@@ -238,7 +240,7 @@ static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm,
return event;
}
- event = kvm_alloc_init_event(key);
+ event = kvm_alloc_init_event(kvm, key);
if (!event)
return NULL;
diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
index 6f0fa05b62b6..40a4b66cfee6 100644
--- a/tools/perf/util/kvm-stat.h
+++ b/tools/perf/util/kvm-stat.h
@@ -24,10 +24,13 @@ struct kvm_event_stats {
struct stats stats;
};
+struct perf_kvm_stat;
+
struct kvm_event {
struct list_head hash_entry;
struct rb_node rb;
+ struct perf_kvm_stat *perf_kvm;
struct event_key key;
struct kvm_event_stats total;
@@ -44,8 +47,6 @@ struct kvm_event_key {
key_cmp_fun key;
};
-struct perf_kvm_stat;
-
struct child_event_ops {
void (*get_key)(struct evsel *evsel,
struct perf_sample *sample,
--
2.34.1
Powered by blists - more mailing lists