From d54f5cdfbca7af2da2139fb76af1f1e416a6d848 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 2 Jan 2019 18:20:07 +0530 Subject: timer-wheel: run the timer function outside of locked region Surprizingly this also reduced 80% CPU overhead 'perf record' tool reported in posix_spin_lock in a brick-mux test volume initialization process. updates: bz#1193929 Change-Id: I4e1df60d6fd094105c312df39f1527d3f07bed68 Signed-off-by: Amar Tumballi --- contrib/timer-wheel/timer-wheel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'contrib/timer-wheel') diff --git a/contrib/timer-wheel/timer-wheel.c b/contrib/timer-wheel/timer-wheel.c index cfbd74e166f..58e0607bf0c 100644 --- a/contrib/timer-wheel/timer-wheel.c +++ b/contrib/timer-wheel/timer-wheel.c @@ -159,7 +159,14 @@ run_timers (struct tvec_base *base) data = timer->data; __gf_tw_detach_timer (timer); - fn (timer, data, call_time); + pthread_spin_unlock(&base->lock); + { + /* It is required to run the actual function outside + of the locked zone, so we don't bother about + locked operations inside that function */ + fn(timer, data, call_time); + } + pthread_spin_lock(&base->lock); } } pthread_spin_unlock (&base->lock); -- cgit