Commit 9c3aa1f4 authored by Leo Yan's avatar Leo Yan Committed by Arnaldo Carvalho de Melo

perf kvm: Refactor overall statistics

Currently the tool computes overall statistics when sort the results.
This patch refactors overall statistics during events processing,
therefore, the function update_total_coun() is not needed anymore, an
extra benefit is we can de-couple code between the statistics and the
sorting.

This patch is not expected any functionality changes.
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230315145112.186603-2-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c46bf3bd
...@@ -278,9 +278,14 @@ static double kvm_event_rel_stddev(int vcpu_id, struct kvm_event *event) ...@@ -278,9 +278,14 @@ static double kvm_event_rel_stddev(int vcpu_id, struct kvm_event *event)
avg_stats(&kvm_stats->stats)); avg_stats(&kvm_stats->stats));
} }
static bool update_kvm_event(struct kvm_event *event, int vcpu_id, static bool update_kvm_event(struct perf_kvm_stat *kvm,
struct kvm_event *event, int vcpu_id,
u64 time_diff) u64 time_diff)
{ {
/* Update overall statistics */
kvm->total_count++;
kvm->total_time += time_diff;
if (vcpu_id == -1) { if (vcpu_id == -1) {
kvm_update_event_stats(&event->total, time_diff); kvm_update_event_stats(&event->total, time_diff);
return true; return true;
...@@ -399,7 +404,7 @@ static bool handle_end_event(struct perf_kvm_stat *kvm, ...@@ -399,7 +404,7 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
} }
} }
return update_kvm_event(event, vcpu, time_diff); return update_kvm_event(kvm, event, vcpu, time_diff);
} }
static static
...@@ -526,15 +531,6 @@ static void insert_to_result(struct rb_root *result, struct kvm_event *event, ...@@ -526,15 +531,6 @@ static void insert_to_result(struct rb_root *result, struct kvm_event *event,
rb_insert_color(&event->rb, result); rb_insert_color(&event->rb, result);
} }
static void
update_total_count(struct perf_kvm_stat *kvm, struct kvm_event *event)
{
int vcpu = kvm->trace_vcpu;
kvm->total_count += get_event_count(event, vcpu);
kvm->total_time += get_event_time(event, vcpu);
}
static bool event_is_valid(struct kvm_event *event, int vcpu) static bool event_is_valid(struct kvm_event *event, int vcpu)
{ {
return !!get_event_count(event, vcpu); return !!get_event_count(event, vcpu);
...@@ -549,7 +545,6 @@ static void sort_result(struct perf_kvm_stat *kvm) ...@@ -549,7 +545,6 @@ static void sort_result(struct perf_kvm_stat *kvm)
for (i = 0; i < EVENTS_CACHE_SIZE; i++) { for (i = 0; i < EVENTS_CACHE_SIZE; i++) {
list_for_each_entry(event, &kvm->kvm_events_cache[i], hash_entry) { list_for_each_entry(event, &kvm->kvm_events_cache[i], hash_entry) {
if (event_is_valid(event, vcpu)) { if (event_is_valid(event, vcpu)) {
update_total_count(kvm, event);
insert_to_result(&kvm->result, event, insert_to_result(&kvm->result, event,
kvm->compare, vcpu); kvm->compare, vcpu);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment