perf: use hrtimer for event multiplexing
Subsystems (2)
v2 cover perf: use hrtimer for event multiplexing
The current scheme of using the timer tick was fine for per-thread events. However, it was causing bias issues in system-wide mode (including for uncore PMUs). Event groups would not get their fair share of runtime on the PMU. With tickless kernels, if a core is idle there is no timer tick, and thus no event rotation (multiplexing). However, there are events (especially uncore events) which do count even though cores are asleep.
This patch changes the timer source for multiplexing. It introduces a per-cpu hrtimer. The advantage is that even when the core goes idle, it will come back to service the hrtimer, thus multiplexing on system-wide events works much better.
In order to minimize the impact of the hrtimer, it is turned on and off on demand. When the PMU on a CPU is overcommited, the hrtimer is activated. It is stopped when the PMU is not overcommitted.
In order for this to work properly with HOTPLUG_CPU, we had to change the order of initialization in start_kernel() such that hrtimer_init() is run before perf_event_init().
The second patch provide a sysctl control to adjust the multiplexing interval. Unit is milliseconds.
Here is a simple before/after example with two event groups which do require multiplexing. This is done in system-wide mode on an idle system. What matters here is the scaling factor in [] in not the total counts.
Before:
# perf stat -a -e ref-cycles,ref-cycles sleep 10 Performance counter stats for 'sleep 10': 34,319,545 ref-cycles [56.51%] 31,917,229 ref-cycles [43.50%]
10.000827569 seconds time elapsed
After:
# perf stat -a -e ref-cycles,ref-cycles sleep 10 Performance counter stats for 'sleep 10': 11,144,822,193 ref-cycles [50.00%] 11,103,760,513 ref-cycles [50.00%]
10.000672946 seconds time elapsed
In this second version of the patchset, we now have the hrtimer_interval per PMU instance. The tunable is in /sys/devices/XXX/mux_interval_ms, where XXX is the name of the PMU instance. Due to initialization changes of each hrtimer, we had to introduce hrtimer_init_cpu() to initialize a hrtimer from another CPU.
---
Stephane Eranian (3):
hrtimer: add hrtimer_init_cpu()
perf: use hrtimer for event multiplexing
perf: add sysfs entry to adjust multiplexing interval per PMU
include/linux/hrtimer.h | 2 + include/linux/perf_event.h | 5 +- init/main.c | 2 +- kernel/events/core.c | 166 +++++++++++++++++++++++++++++++++++++++++--- kernel/hrtimer.c | 17 +++-- 5 files changed, 176 insertions(+), 16 deletions(-)
Signature · 1 line
1.7.5.4
PATCH v2 1/3 hrtimer: add hrtimer_init_cpu()
hrtimer_init() assumes it is called for the current CPU as it accesses per-cpu variables (hrtimer_bases).
However, there can be cases where a hrtimer is initialized from a different CPU, so add an entry point to make this more explicit.
--- include/linux/hrtimer.h | 3 +++ kernel/hrtimer.c | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
include/linux/hrtimer.h +3 -0
@@ -337,6 +337,9 @@ DECLARE_PER_CPU(struct tick_device, tick_cpu_device);/* Initialize timers: */ extern void hrtimer_init (struct hrtimer *timer,clockid_t which_clock,enum hrtimer_mode mode); +extern void hrtimer_init_cpu (int cpu,struct hrtimer *timer, +clockid_t which_clock, +enum hrtimer_mode mode);#ifdef CONFIG_DEBUG_OBJECTS_TIMERS extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
kernel/hrtimer.c +12 -5
@@ -440,14 +440,14 @@ static inline void debug_hrtimer_free(struct hrtimer *timer)debug_object_free (timer, &hrtimer_debug_descr); } -static void __hrtimer_init (struct hrtimer *timer,clockid_t clock_id, +static void __hrtimer_init (int cpu,struct hrtimer *timer,clockid_t clock_id,enum hrtimer_mode mode);void hrtimer_init_on_stack (struct hrtimer *timer,clockid_t clock_id,enum hrtimer_mode mode) {debug_object_init_on_stack (timer, &hrtimer_debug_descr); -__hrtimer_init (timer, clock_id, mode); +__hrtimer_init (smp_processor_id (), timer, clock_id, mode); }EXPORT_SYMBOL_GPL (hrtimer_init_on_stack);
@@ -1146,7 +1146,7 @@ ktime_t hrtimer_get_next_event(void) }#endif -static void __hrtimer_init (struct hrtimer *timer,clockid_t clock_id, +static void __hrtimer_init (int cpu,struct hrtimer *timer,clockid_t clock_id,enum hrtimer_mode mode) {struct hrtimer_cpu_base *cpu_base;
@@ -1154,7 +1154,7 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,memset (timer,0 ,sizeof (struct hrtimer )); - cpu_base = &__raw_get_cpu_var (hrtimer_bases); + cpu_base = &per_cpu (hrtimer_bases, cpu);if (clock_id ==CLOCK_REALTIME && mode !=HRTIMER_MODE_ABS ) clock_id =CLOCK_MONOTONIC ;
@@ -1180,10 +1180,17 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, enum hrtimer_mode mode) {debug_init (timer, clock_id, mode); -__hrtimer_init (timer, clock_id, mode); +__hrtimer_init (smp_processor_id (), timer, clock_id, mode); }EXPORT_SYMBOL_GPL (hrtimer_init); +void hrtimer_init_cpu (int cpu,struct hrtimer *timer,clockid_t clock_id, +enum hrtimer_mode mode) +{ +debug_init (timer, clock_id, mode); +__hrtimer_init (cpu, timer, clock_id, mode); +} +/** * hrtimer_get_res - get the timer resolution for a clock * @which_clock: which clock to query
Signature · 1 line
1.7.5.4
Re: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
kernel/hrtimer.c static inline void debug_hrtimer_free(struct hrtimer *timer) · line 451
Quoted 7 lines · Stephane Eranian
void hrtimer_init_on_stack(struct hrtimer *timer,
clockid_tclock_id,kernel/hrtimer.c +1
-1enum hrtimer_mode mode) {debug_object_init_on_stack (timer, &hrtimer_debug_descr); -__hrtimer_init (timer, clock_id, mode); +__hrtimer_init (smp_processor_id (), timer, clock_id, mode); }
This assumes caller is in non preemptable context.
Peter Zijlstra
maintainerRe: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
In reply to Stephane EranianI'm rather sure Thomas would want to know about this..
Quoted 19 lines · Stephane Eranian
hrtimer_init()assumes it is called for the current CPU as it accesses per-cpu variables (hrtimer_bases).However, there can be cases where a hrtimer is initialized from a different CPU, so add an entry point to make this more explicit.
Signed-off-by Stephane Eranian <[email protected]>--- include/linux/hrtimer.h | 3 +++ kernel/hrtimer.c | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)kernel/hrtimer.c +1
-0+static void __hrtimer_init (int cpu,struct hrtimer *timer,clockid_t clock_id,enum hrtimer_mode mode) {struct hrtimer_cpu_base *cpu_base;
kernel/hrtimer.c static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, · line 1160
Quoted 8 lines
kernel/hrtimer.c +1
-1@@ -1154,7 +1154,7 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,memset (timer,0 ,sizeof (struct hrtimer )); - cpu_base = &__raw_get_cpu_var (hrtimer_bases); + cpu_base = &per_cpu (hrtimer_bases, cpu);if (clock_id ==CLOCK_REALTIME && mode !=HRTIMER_MODE_ABS ) clock_id =CLOCK_MONOTONIC ;
I don't see the point, one of the first things __hrtimer_start_range_ns() does is switch_hrtimer_base() to swizzle it to the calling CPUs base.
And since all the perf event rotation muck is strictly per cpu that all should work out just fine, no?
Re: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
Quoted 37 lines · Peter Zijlstra
I'm rather sure Thomas would want to know about this..
Quoted 19 lines · Stephane Eranian
hrtimer_init()assumes it is called for the current CPU as it accesses per-cpu variables (hrtimer_bases).However, there can be cases where a hrtimer is initialized from a different CPU, so add an entry point to make this more explicit.
Signed-off-by Stephane Eranian <[email protected]>--- include/linux/hrtimer.h | 3 +++ kernel/hrtimer.c | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)kernel/hrtimer.c +1
-0+static void __hrtimer_init (int cpu,struct hrtimer *timer,clockid_t clock_id,enum hrtimer_mode mode) {struct hrtimer_cpu_base *cpu_base;kernel/hrtimer.c static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, · line 1160
Quoted 8 lines
kernel/hrtimer.c +1
-1@@ -1154,7 +1154,7 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,memset (timer,0 ,sizeof (struct hrtimer )); - cpu_base = &__raw_get_cpu_var (hrtimer_bases); + cpu_base = &per_cpu (hrtimer_bases, cpu);if (clock_id ==CLOCK_REALTIME && mode !=HRTIMER_MODE_ABS ) clock_id =CLOCK_MONOTONIC ;I don't see the point, one of the first things
__hrtimer_start_range_ns()does isswitch_hrtimer_base()to swizzle it to the calling CPUs base.
Quoted 2 lines
And since all the perf event rotation muck is strictly per cpu that all should work out just fine, no?
If I do:
for_each_possible_cpu(cpu) {
cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
hr = &cpuctx->hrtimer;
hrtimer_init(hr)
}I don't understand why I would have to refer to per-cpu data (hrtimer_bases) from
a CPU that is not equal to "cpu" here. Unless you're telling me it's read-only data.
But still if it's per-cpu why not initialize with the correct CPU from the start?
Peter Zijlstra
maintainerRe: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
Quoted 11 lines · Stephane Eranian
If I do:
for_each_possible_cpu(cpu) { cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); hr = &cpuctx->hrtimer; hrtimer_init(hr) }I don't understand why I would have to refer to per-cpu data (
hrtimer_bases) from
a CPU that is not equal to "cpu" here. Unless you're telling me it's read-only data.
No its not read only, but it is unused until you do *hrtimer_start*(), which will test and fix.
Quoted 2 lines
But still if it's per-cpu why not initialize with the correct CPU from the start?
To keep the interface simpler I guess. There's no great harm in your proposal, but it is strictly speaking superfluous. I'm not sure the max one time avoidance of a base swizzle is worth the extra interface, I'll leave that up to Thomas.
Also, what Eric said ;-)
Re: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
Quoted 20 lines · Peter Zijlstra
Quoted 11 lines · Stephane Eranian
If I do:
for_each_possible_cpu(cpu) { cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); hr = &cpuctx->hrtimer; hrtimer_init(hr) }I don't understand why I would have to refer to per-cpu data (
hrtimer_bases) from
a CPU that is not equal to "cpu" here. Unless you're telling me it's read-only data.No its not read only, but it is unused until you do *hrtimer_start*(), which will test and fix.
Quoted 2 lines
But still if it's per-cpu why not initialize with the correct CPU from the start?
Quoted 6 lines
To keep the interface simpler I guess. There's no great harm in your proposal, but it is strictly speaking superfluous. I'm not sure the max one time avoidance of a base swizzle is worth the extra interface, I'll leave that up to Thomas.
Also, what Eric said ;-)
I am fine with dropping this patch. I just found it odd there was a per-cpu data reference embedded deep into the call. I wanted things to be more explicit. I know it works without the proposed change.
Peter Zijlstra
maintainerRe: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
Quoted 3 lines · Stephane Eranian
I am fine with dropping this patch. I just found it odd there was a per-cpu data reference embedded deep into the call. I wanted things to be more explicit. I know it works without the proposed change.
Ah the reason its there is to make sure the base pointer is a valid base pointer, this avoids an extra conditional in a number of places. Note that it uses raw_get_cpu_var(), so it doesn't even actually know which specific pointer goes in.
Re: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()
Quoted 12 lines · Peter Zijlstra
Quoted 3 lines · Stephane Eranian
I am fine with dropping this patch. I just found it odd there was a per-cpu data reference embedded deep into the call. I wanted things to be more explicit. I know it works without the proposed change.
Ah the reason its there is to make sure the base pointer is a valid base pointer, this avoids an extra conditional in a number of places. Note that it uses
raw_get_cpu_var(), so it doesn't even actually know which specific pointer goes in.
Ok, fine. Then let's drop this patch then.
Thanks for the explanations.
PATCH v2 2/3 perf: use hrtimer for event multiplexing
In reply to Stephane EranianThe current scheme of using the timer tick was fine for per-thread events. However, it was causing bias issues in system-wide mode (including for uncore PMUs). Event groups would not get their fair share of runtime on the PMU. With tickless kernels, if a core is idle there is no timer tick, and thus no event rotation (multiplexing). However, there are events (especially uncore events) which do count even though cores are asleep.
This patch changes the timer source for multiplexing. It introduces a per-PMU per-cpu hrtimer. The advantage is that even when a core goes idle, it will come back to service the hrtimer, thus multiplexing on system-wide events works much better.
The per-PMU implementation (suggested by PeterZ) enables adjusting the multiplexing interval per PMU. The preferred interval is stashed into the struct pmu. If not set, it will be forced to the default interval value.
In order to minimize the impact of the hrtimer, it is turned on and off on demand. When the PMU on a CPU is overcommited, the hrtimer is activated. It is stopped when the PMU is not overcommitted.
In order for this to work properly, we had to change the order of initialization in start_kernel() such that hrtimer_init() is run before perf_event_init().
The default interval in milliseconds is set to a timer tick just like with the old code. We will provide a sysctl to tune this in another patch.
--- include/linux/perf_event.h | 4 +- init/main.c | 2 +- kernel/events/core.c | 123 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 118 insertions(+), 11 deletions(-)
include/linux/perf_event.h +3 -1
@@ -1106,8 +1106,10 @@ struct perf_cpu_context {struct perf_event_context *task_ctx;int active_oncpu;int exclusive; +struct hrtimer hrtimer;struct list_head rotation_list; -int jiffies_interval; +ktime_t hrtimer_interval; +int hrtimer_active;struct pmu *active_pmu;struct perf_cgroup *cgrp; };
init/main.c +1 -1
@@ -541,7 +541,6 @@ asmlinkage void __init start_kernel(void)local_irq_disable (); }idr_init_cache (); -perf_event_init ();rcu_init ();radix_tree_init ();/* init some links before init_ISA_irqs() */
@@ -553,6 +552,7 @@ asmlinkage void __init start_kernel(void)softirq_init ();timekeeping_init ();time_init (); +perf_event_init ();profile_init ();call_function_init ();if (!irqs_disabled ())
kernel/events/core.c +114 -9
196 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Peter Zijlstra
maintainerQuoted 1 line · Stephane Eranian
+static
DEFINE_PER_CPU(struct list_head, rotation_list);
Why do you keep the rotation list? The only use seems to be:
Quoted 10 lines
kernel/events/core.c +10
-0+void perf_cpu_hrtimer_cancel (int cpu) +{ +struct list_head *head = &__get_cpu_var (rotation_list); +struct perf_cpu_context *cpuctx, *tmp; +unsigned long flags; + +if (WARN_ON (cpu !=smp_processor_id ())) +return ; + +local_irq_save (flags);
kernel/events/core.c perf_cgroup_mark_enabled(struct perf_event *event, · line 687
Quoted 10 lines
kernel/events/core.c +10
-0+ +list_for_each_entry_safe (cpuctx, tmp, head, rotation_list) { +if (cpuctx->hrtimer_active) { +hrtimer_cancel (&cpuctx->hrtimer); + cpuctx->hrtimer_active =0 ; + } + } + +local_irq_restore (flags); +}
Which is weird, why not use the existing for-each-pmu loop in perf_event_exit_cpu_context() ? Or something similar to iterate all extant PMUs and thus their cpuctxs?
Also, you can do away with hrtimer_active, you can hrtimer_cancel() on an inactive hrtimer just fine, it will DTRT.
Quoted 22 lines · Peter Zijlstra
Quoted 1 line · Stephane Eranian
+static
DEFINE_PER_CPU(struct list_head, rotation_list);Why do you keep the rotation list? The only use seems to be:
Quoted 16 lines
kernel/events/core.c +16
-0+void perf_cpu_hrtimer_cancel (int cpu) +{ +struct list_head *head = &__get_cpu_var (rotation_list); +struct perf_cpu_context *cpuctx, *tmp; +unsigned long flags; + +if (WARN_ON (cpu !=smp_processor_id ())) +return ; + +local_irq_save (flags); + +list_for_each_entry_safe (cpuctx, tmp, head, rotation_list) { +if (cpuctx->hrtimer_active) { +hrtimer_cancel (&cpuctx->hrtimer); + cpuctx->hrtimer_active =0 ; + }
Quoted 9 lines
kernel/events/core.c perf_cgroup_mark_enabled(struct perf_event *event, · line 662
Quoted 4 lines
kernel/events/core.c +4
-0+ } + +local_irq_restore (flags); +}Which is weird, why not use the existing for-each-pmu loop in
perf_event_exit_cpu_context()? Or something similar to iterate all extant PMUs and thus their cpuctxs?
True. That would probably work too.
Quoted 2 lines
Also, you can do away with
hrtimer_active, you canhrtimer_cancel()on an inactive hrtimer just fine, it will DTRT.
The hrtimer_active is used to prevent activating the timer multiple times in a row.
Peter Zijlstra
maintainerQuoted 2 lines · Stephane Eranian
The
hrtimer_activeis used to prevent activating the timer multiple times in a row.
see hrtimer_active(), this should do what you want I think.
Quoted 5 lines · Peter Zijlstra
Quoted 2 lines · Stephane Eranian
The
hrtimer_activeis used to prevent activating the timer multiple times in a row.see
hrtimer_active(), this should do what you want I think.
I need something that is true even when the hrtimer is not executing the callback handler. I guess that may be the different between hrtimer_active() vs. hrtimer_running()?
Peter Zijlstra
maintainerQuoted 10 lines · Stephane Eranian
Quoted 5 lines · Peter Zijlstra
Quoted 2 lines · Stephane Eranian
The
hrtimer_activeis used to prevent activating the timer multiple times in a row.see
hrtimer_active(), this should do what you want I think.I need something that is true even when the hrtimer is not executing the callback handler. I guess that may be the different between
hrtimer_active()vs.hrtimer_running()?
As the comment states, hrtimer_active() returns true if the timer is either in the tree (enqueued) or running.
hrtimer_callback_running() is true iff the callback is currently executing.
hrtimer_queued() is true iff the timer is queued.
Quoted 32 lines · Stephane Eranian
Quoted 22 lines · Peter Zijlstra
Quoted 1 line · Stephane Eranian
+static
DEFINE_PER_CPU(struct list_head, rotation_list);Why do you keep the rotation list? The only use seems to be:
Quoted 16 lines
kernel/events/core.c +16
-0+void perf_cpu_hrtimer_cancel (int cpu) +{ +struct list_head *head = &__get_cpu_var (rotation_list); +struct perf_cpu_context *cpuctx, *tmp; +unsigned long flags; + +if (WARN_ON (cpu !=smp_processor_id ())) +return ; + +local_irq_save (flags); + +list_for_each_entry_safe (cpuctx, tmp, head, rotation_list) { +if (cpuctx->hrtimer_active) { +hrtimer_cancel (&cpuctx->hrtimer); + cpuctx->hrtimer_active =0 ; + }Quoted 9 lines
kernel/events/core.c perf_cgroup_mark_enabled(struct perf_event *event, · line 662
Quoted 4 lines
kernel/events/core.c +4
-0+ } + +local_irq_restore (flags); +}Which is weird, why not use the existing for-each-pmu loop in
perf_event_exit_cpu_context()? Or something similar to iterate all extant PMUs and thus their cpuctxs?
Quoted 2 lines
True. That would probably work too.
Note however that the rotation_list is still used in perf_event_task_tick() to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.
Quoted 33 lines · Stephane Eranian
Quoted 32 lines · Stephane Eranian
Quoted 31 lines · Peter Zijlstra
Quoted 1 line · Stephane Eranian
+static
DEFINE_PER_CPU(struct list_head, rotation_list);Why do you keep the rotation list? The only use seems to be:
Quoted 10 lines
kernel/events/core.c +10
-0+void perf_cpu_hrtimer_cancel (int cpu) +{ +struct list_head *head = &__get_cpu_var (rotation_list); +struct perf_cpu_context *cpuctx, *tmp; +unsigned long flags; + +if (WARN_ON (cpu !=smp_processor_id ())) +return ; + +local_irq_save (flags);kernel/events/core.c perf_cgroup_mark_enabled(struct perf_event *event, · line 687
Quoted 10 lines
kernel/events/core.c +10
-0+ +list_for_each_entry_safe (cpuctx, tmp, head, rotation_list) { +if (cpuctx->hrtimer_active) { +hrtimer_cancel (&cpuctx->hrtimer); + cpuctx->hrtimer_active =0 ; + } + } + +local_irq_restore (flags); +}Which is weird, why not use the existing for-each-pmu loop in
perf_event_exit_cpu_context()? Or something similar to iterate all extant PMUs and thus their cpuctxs?
Quoted 6 lines
Quoted 2 lines
True. That would probably work too.
Note however that the
rotation_listis still used inperf_event_task_tick()to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.
That reminds me that dropping sw context from rotation_list causes an issue in perf_event_task_tick() because that means the sw PMU are not considered anymore for interrupt unthrottling but they should. So I think switching to for-each-pmu() in perf_event_task_tick() will solve that problem too.
Peter Zijlstra
maintainerQuoted 4 lines · Stephane Eranian
Note however that the
rotation_listis still used inperf_event_task_tick()to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.
Oh urgh, right. I think that was one of the reasons I bailed on the hrtimer thing, the frequency and throttle stuff.
ctx->nr_freq and needs_unthr could help, but yeah.
Quoted 11 lines · Peter Zijlstra
Quoted 4 lines · Stephane Eranian
Note however that the
rotation_listis still used inperf_event_task_tick()to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.Oh urgh, right. I think that was one of the reasons I bailed on the hrtimer thing, the frequency and throttle stuff.
ctx->nr_freqandneeds_unthrcould help, but yeah.
I think for now, we could keep rotation list for the unthrottling. Multiplexing won't use rotation_list anymore.
Peter Zijlstra
maintainerQuoted 8 lines · Stephane Eranian
Quoted 7 lines · Peter Zijlstra
Quoted 4 lines · Stephane Eranian
Note however that the
rotation_listis still used inperf_event_task_tick()to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.
Quoted 7 lines
Quoted 4 lines
Oh urgh, right. I think that was one of the reasons I bailed on the hrtimer thing, the frequency and throttle stuff.
ctx->nr_freqandneeds_unthrcould help, but yeah.I think for now, we could keep rotation list for the unthrottling. Multiplexing won't use
rotation_listanymore.
wouldn't that still have the problem where we take the sw-pmus off of the rotation-list?
Quoted 12 lines · Peter Zijlstra
Quoted 11 lines · Stephane Eranian
Quoted 10 lines · Peter Zijlstra
Quoted 4 lines · Stephane Eranian
Note however that the
rotation_listis still used inperf_event_task_tick()to iterate over the ctx which needs unthrottling. We would have to switch that loop over to a for-each-pmu() which would necessary incur more iterations as it would include all the SW PMUs.Oh urgh, right. I think that was one of the reasons I bailed on the hrtimer thing, the frequency and throttle stuff.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
ctx->nr_freqandneeds_unthrcould help, but yeah.I think for now, we could keep rotation list for the unthrottling. Multiplexing won't use
rotation_listanymore.wouldn't that still have the problem where we take the sw-pmus off of the rotation-list?
No because we should not use the patch I posted last week. So rotation_start() would still enqueue SW pmus.
Peter Zijlstra
maintainerQuoted 2 lines · Stephane Eranian
No because we should not use the patch I posted last week. So
rotation_start()would still enqueue SW pmus.
Hrmm. I just send it to Ingo.. let me see if I can still recall that.
PATCH v2 3/3 perf: add sysfs entry to adjust multiplexing interval per PMU
In reply to Stephane EranianThis patch adds /sys/device/xxx/mux_interval_ms to ajust the multiplexing interval per PMU. The unit is milliseconds. Value has to be >= 1.
--- include/linux/perf_event.h | 1 + kernel/events/core.c | 54 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-)
include/linux/perf_event.h +1 -0
@@ -784,6 +784,7 @@ struct pmu {int *__percpu pmu_disable_count;struct perf_cpu_context *__percpu pmu_cpu_context;int task_ctx_nr; +int hrtimer_interval_ms;/* * Fully disable/enable this PMU, can be used to protect from the PMI
kernel/events/core.c +50 -4
74 lines not on this page · raw message
Signature · 1 line
1.7.5.4