Skip to content

Commit 01add3e

Browse files
Sukadev BhattiproluIngo Molnar
authored andcommitted
perf/core: Split perf_event_read() and perf_event_count()
perf_event_read() does two things: - call the PMU to read/update the counter value, and - compute the total count of the event and its children Not all callers need both. perf_event_reset() for instance needs the first piece but doesn't need the second. Similarly, when we implement the ability to read a group of events using the transaction interface, we would need the two pieces done independently. Break up perf_event_read() and have it just read/update the counter and have the callers compute the total count if necessary. Signed-off-by: Sukadev Bhattiprolu <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent fbbe070 commit 01add3e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

kernel/events/core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,7 @@ u64 perf_event_read_local(struct perf_event *event)
32753275
return val;
32763276
}
32773277

3278-
static u64 perf_event_read(struct perf_event *event)
3278+
static void perf_event_read(struct perf_event *event)
32793279
{
32803280
/*
32813281
* If event is enabled and currently active on a CPU, update the
@@ -3301,8 +3301,6 @@ static u64 perf_event_read(struct perf_event *event)
33013301
update_event_times(event);
33023302
raw_spin_unlock_irqrestore(&ctx->lock, flags);
33033303
}
3304-
3305-
return perf_event_count(event);
33063304
}
33073305

33083306
/*
@@ -3818,14 +3816,18 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
38183816
*running = 0;
38193817

38203818
mutex_lock(&event->child_mutex);
3821-
total += perf_event_read(event);
3819+
3820+
perf_event_read(event);
3821+
total += perf_event_count(event);
3822+
38223823
*enabled += event->total_time_enabled +
38233824
atomic64_read(&event->child_total_time_enabled);
38243825
*running += event->total_time_running +
38253826
atomic64_read(&event->child_total_time_running);
38263827

38273828
list_for_each_entry(child, &event->child_list, child_list) {
3828-
total += perf_event_read(child);
3829+
perf_event_read(child);
3830+
total += perf_event_count(child);
38293831
*enabled += child->total_time_enabled;
38303832
*running += child->total_time_running;
38313833
}
@@ -3985,7 +3987,7 @@ static unsigned int perf_poll(struct file *file, poll_table *wait)
39853987

39863988
static void _perf_event_reset(struct perf_event *event)
39873989
{
3988-
(void)perf_event_read(event);
3990+
perf_event_read(event);
39893991
local64_set(&event->count, 0);
39903992
perf_event_update_userpage(event);
39913993
}

0 commit comments

Comments
 (0)