lkml.org 
[lkml]   [2022]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH V3] perf/core: Avoid calling perf_mux_hrtimer_restart multiple times when scheduling event groups
Date
Perf uses multiplexing if there are more events to be scheduled than the
available counters. With multiplexing, event groups will be rotated at
specified interval of time which is set using "hrtimer". During event
scheduling, if any of the event group fails to schedule, multiplexing
gets enabled by setting "rotate_necessary" for that event context and
starting the hrtimer by calling "perf_mux_hrtimer_restart".

Patch adds an optimisation to avoid calling "perf_mux_hrtimer_restart"
multiple times if already rotate_necessary is set for that context.
Even though "perf_mux_hrtimer_restart" will just return if hrtimer is
already active, this could avoid the overhead of calling this function
multiple times if there are many event groups. Patch adds the check to
avoid calling perf_mux_hrtimer_restart() for each event group on
every schedule.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Acked-by: Song Liu <song@kernel.org>
---
Changelog:
From v2 -> v3:
- Added Acked-by from Song Liu
From v1 -> v2:
- Rebased on top of latest kernel source.

kernel/events/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 30d94f68c5bd..cc293b4360f6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3753,8 +3753,10 @@ static int merge_sched_in(struct perf_event *event, void *data)
perf_cgroup_event_disable(event, ctx);
perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
} else {
- ctx->rotate_necessary = 1;
- perf_mux_hrtimer_restart(cpuctx);
+ if (!ctx->rotate_necessary) {
+ ctx->rotate_necessary = 1;
+ perf_mux_hrtimer_restart(cpuctx);
+ }
group_update_userpage(event);
}
}
--
2.33.0
\
 
 \ /
  Last update: 2022-01-05 08:16    [W:0.219 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site