Skip to contentSkip to conversation

perf/core: addressing 4x slowdown during per-process profiling of STREAM benchmark on Intel Xeon Phi

PATCH New Alexey Budankov 1 participant 3 messages Aug 31, 2017 perf events

lore
Share & tools
lore
#0 lore raw

v9 cover perf/core: addressing 4x slowdown during per-process profiling of STREAM benchmark on Intel Xeon Phi

Hi,

This patch set v9 addresses feedback captured on review of v7. For more background details please refer to v7 and earlier.

Specifically in this version groups are kept in a single tree indexed by CPU and then by a 64bit virtual index.

In this version mux switch is renamed to rotation switch and the value of rotation switch may be the one of defined by ROTATION_DISABLED or ROTATION_ENABLED macros.

ctx->rotate_disable bool flag is renamed to ctx->rotation and also employs ROTATION_DISABLE and ROTATION_ENABLED macros.

pinned_group_sched_in() and flexible_group_sched_in() API are introduced to consolidate code enabling a whole group from pinned and flexible groups appropriately.

Patches in the set are expected to be applied one after another in the mentioned order and they are logically split into two parts to simplify the review process.

Thanks,
Alexey

---
Alexey Budankov (2):
perf/core: use rb trees for pinned/flexible groups
perf/core: add rotation switch to skip to the current CPU's events list on mux interrupt

 include/linux/perf_event.h |  17 +-
 kernel/events/core.c       | 500 +++++++++++++++++++++++++++++++++------------
 2 files changed, 382 insertions(+), 135 deletions(-)
#1 lore raw

PATCH v9 1/2 perf/core: use rb trees for pinned/flexible groups

This patch moves event groups into rb tree sorted by CPU and then by a 64bit index, so that multiplexing hrtimer interrupt handler would be able skipping to the current CPU's list and ignore groups allocated for the other CPUs.

New API for manipulating event groups in the trees is implemented as well as adoption on the API in the current implementation.

pinned_group_sched_in() and flexible_group_sched_in() API are introduced to consolidate code enabling the whole group from pinned and flexible groups appropriately.

---
 include/linux/perf_event.h |  15 ++-
 kernel/events/core.c       | 317 ++++++++++++++++++++++++++++++++++-----------
 2 files changed, 256 insertions(+), 76 deletions(-)
include/linux/perf_event.h +12 -3
index 718ba16..d2e58da 100644
@@ -570,7 +570,11 @@ struct perf_event {
 	 */
 	struct list_head		group_entry;
 	struct list_head		sibling_list;
-
+	/*
+	 * Node on the pinned or flexible tree located at the event context;
+	 */
+	struct rb_node			group_node;
+	u64				group_index;
 	/*
 	 * We need storage to track the entries in perf_pmu_migrate_context; we
 	 * cannot use the event_entry because of RCU and we want to keep the
@@ -719,6 +723,11 @@ struct perf_event {
 #endif /* CONFIG_PERF_EVENTS */
 };
 
+struct perf_event_groups {
+	struct rb_root	tree;
+	u64		index;
+};
+
 /**
  * struct perf_event_context - event context structure
  *
@@ -739,8 +748,8 @@ struct perf_event_context {
 	struct mutex			mutex;
 
 	struct list_head		active_ctx_list;
-	struct list_head		pinned_groups;
-	struct list_head		flexible_groups;
+	struct perf_event_groups	pinned_groups;
+	struct perf_event_groups	flexible_groups;
 	struct list_head		event_list;
 	int				nr_events;
 	int				nr_active;
kernel/events/core.c +244 -73

446 lines not on this page · raw message

#2 lore raw

PATCH v9 2/2 perf/core: add rotation switch to skip to the current CPU's events list on mux interrupt

In reply to Alexey Budankov

This patch implements rotation switch that triggers skipping to the current CPU's events list at mulitplexing hrtimer interrupt handler as well as adoption of the switch in the existing implementation.

The value of rotation switch may be the one of defined by ROTATION_DISABLED or ROTATION_ENABLED macros.

ctx->rotate_disable bool flag is renamed to ctx->rotation and also employs ROTATION_DISABLE and ROTATION_ENABLED macros.

perf_event_groups_iterate_cpu() API is introduced to implement iteration through the certain CPU groups list skipping groups allocated for the other CPUs.

---
 include/linux/perf_event.h |   2 +-
 kernel/events/core.c       | 213 +++++++++++++++++++++++++++++----------------
 2 files changed, 141 insertions(+), 74 deletions(-)
include/linux/perf_event.h +1 -1
index d2e58da..9970b4f 100644
@@ -756,7 +756,7 @@ struct perf_event_context {
 	int				is_active;
 	int				nr_stat;
 	int				nr_freq;
-	int				rotate_disable;
+	int				rotation;
 	atomic_t			refcount;
 	struct task_struct		*task;
 
kernel/events/core.c +140 -73

495 lines not on this page · raw message