History

perf: Add a counter for number of user access events in context

On arm64, user space counter access will be controlled differently compared to x86. On x86, access in the strictest mode is enabled for all tasks in an MM when any event is mmap'ed. For arm64, access is explicitly requested for an event and only enabled when the event's context is active. This avoids hooks into the arch context switch code and gives better control of when access is enabled. In order to configure user space access when the PMU is enabled, it is necessary to know if any event (currently active or not) in the current context has user space accessed enabled. Add a counter similar to other counters in the context to avoid walking the event list every time.

Rob Herring committed 4 years ago

Commit 82ff0c01 parent 369461c2 files · +5 −0Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/events/core.c+4−0
@@ -1808,6 +1808,8 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx) · 1807 unmodified lines
18081808
18091809 list_add_rcu(&event->event_entry, &ctx->event_list);
18101810 ctx->nr_events++;
1811+ if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
1812+ ctx->nr_user++;
18111813 if (event->attr.inherit_stat)
18121814 ctx->nr_stat++;
18131815
@@ -1999,6 +2001,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) · 185 unmodified lines
19992001 event->attach_state &= ~PERF_ATTACH_CONTEXT;
20002002
20012003 ctx->nr_events--;
2004+ if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
2005+ ctx->nr_user--;
20022006 if (event->attr.inherit_stat)
20032007 ctx->nr_stat--;
20042008