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

Unified · Split

2 files
  1. include/linux/perf_event.h +1 −0
  2. kernel/events/core.c +4 −0
include/linux/perf_event.h+1−0
@@ -831,6 +831,7 @@ struct perf_event_context { · 830 unmodified lines
831 831
832 int nr_events;832 int nr_events;
833 int nr_active;833 int nr_active;
834 int nr_user;
834 int is_active;835 int is_active;
835 int nr_stat;836 int nr_stat;
836 int nr_freq;837 int nr_freq;
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
1808 1808
1809 list_add_rcu(&event->event_entry, &ctx->event_list);1809 list_add_rcu(&event->event_entry, &ctx->event_list);
1810 ctx->nr_events++;1810 ctx->nr_events++;
1811 if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
1812 ctx->nr_user++;
1811 if (event->attr.inherit_stat)1813 if (event->attr.inherit_stat)
1812 ctx->nr_stat++;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 event->attach_state &= ~PERF_ATTACH_CONTEXT;2001 event->attach_state &= ~PERF_ATTACH_CONTEXT;
2000 2002
2001 ctx->nr_events--;2003 ctx->nr_events--;
2004 if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
2005 ctx->nr_user--;
2002 if (event->attr.inherit_stat)2006 if (event->attr.inherit_stat)
2003 ctx->nr_stat--;2007 ctx->nr_stat--;
2004 2008