From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751978AbdHaM1B (ORCPT ); Thu, 31 Aug 2017 08:27:01 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60592 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751691AbdHaMXn (ORCPT ); Thu, 31 Aug 2017 08:23:43 -0400 Message-Id: <20170831105826.849175752@linutronix.de> User-Agent: quilt/0.63-1 Date: Thu, 31 Aug 2017 12:23:41 -0000 From: Anna-Maria Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Christoph Hellwig , keescook@chromium.org, John Stultz , Thomas Gleixner Subject: [PATCH 16/25] hrtimer: Allow function reuse for softirq based hrtimer References: <20170831105725.809317030@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=hrtimer_Allow_function_reuse_for_softirq_based_hrtimer.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anna-Maria Gleixner The softirq based hrtimer can utilize most of the existing hrtimer functions, but need to operate on a different data set. Add an active_mask argument to various functions so the hard and soft bases can be selected. Fixup the existing callers and hand in the ACTIVE_HARD mask. Signed-off-by: Anna-Maria Gleixner --- kernel/time/hrtimer.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -72,6 +72,14 @@ #define CLOCK_TAI_SOFT (CLOCK_TAI | HRTIMER_BASE_SOFT_MASK) /* + * Masks for selecting the soft and hard context timers from + * cpu_base->active + */ +#define MASK_SHIFT (HRTIMER_BASE_MONOTONIC_SOFT) +#define HRTIMER_ACTIVE_HARD ((1U << MASK_SHIFT) - 1) +#define HRTIMER_ACTIVE_SOFT (HRTIMER_ACTIVE_HARD << MASK_SHIFT) + +/* * The timer bases: * * There are more clockids than hrtimer bases. Thus, we index @@ -527,11 +535,12 @@ static ktime_t __hrtimer_next_event_base static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) { - unsigned int active = cpu_base->active_bases; + unsigned int active; ktime_t expires_next = KTIME_MAX; hrtimer_update_next_timer(cpu_base, NULL); + active = cpu_base->active_bases & HRTIMER_ACTIVE_HARD; expires_next = __hrtimer_next_event_base(cpu_base, active, expires_next); return expires_next; @@ -1264,9 +1273,10 @@ static void __run_hrtimer(struct hrtimer base->running = NULL; } -static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now) +static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now, + unsigned int active_mask) { - unsigned int active = cpu_base->active_bases; + unsigned int active = cpu_base->active_bases & active_mask; while (active) { unsigned int id = __ffs(active); @@ -1333,7 +1343,7 @@ void hrtimer_interrupt(struct clock_even */ cpu_base->expires_next = KTIME_MAX; - __hrtimer_run_queues(cpu_base, now); + __hrtimer_run_queues(cpu_base, now, HRTIMER_ACTIVE_HARD); /* Reevaluate the clock bases for the next expiry */ expires_next = __hrtimer_get_next_event(cpu_base); @@ -1438,7 +1448,7 @@ void hrtimer_run_queues(void) raw_spin_lock(&cpu_base->lock); now = hrtimer_update_base(cpu_base); - __hrtimer_run_queues(cpu_base, now); + __hrtimer_run_queues(cpu_base, now, HRTIMER_ACTIVE_HARD); raw_spin_unlock(&cpu_base->lock); }