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.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -1808,6 +1808,8 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx) · 1807 unmodified lines | ||
| 1808 | 1808 | |
| 1809 | 1809 | list_add_rcu(&event->event_entry, &ctx->event_list); |
| 1810 | 1810 | ctx->nr_events++; |
| 1811 | + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) | |
| 1812 | + ctx->nr_user++; | |
| 1811 | 1813 | if (event->attr.inherit_stat) |
| 1812 | 1814 | ctx->nr_stat++; |
| 1813 | 1815 | |
| @@ -1999,6 +2001,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) · 185 unmodified lines | ||
| 1999 | 2001 | event->attach_state &= ~PERF_ATTACH_CONTEXT; |
| 2000 | 2002 | |
| 2001 | 2003 | ctx->nr_events--; |
| 2004 | + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) | |
| 2005 | + ctx->nr_user--; | |
| 2002 | 2006 | if (event->attr.inherit_stat) |
| 2003 | 2007 | ctx->nr_stat--; |
| 2004 | 2008 | |