From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdHaM0V (ORCPT ); Thu, 31 Aug 2017 08:26:21 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60601 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbdHaMXo (ORCPT ); Thu, 31 Aug 2017 08:23:44 -0400 Message-Id: <20170831105826.997132802@linutronix.de> User-Agent: quilt/0.63-1 Date: Thu, 31 Aug 2017 12:23:42 -0000 From: Anna-Maria Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Christoph Hellwig , keescook@chromium.org, John Stultz , Thomas Gleixner Subject: [PATCH 18/25] hrtimer: Enable soft and hard hrtimer References: <20170831105725.809317030@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=hrtimer_Enable_soft_and_hard_hrtimer.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anna-Maria Gleixner Move the definition of the clock ids, to be available not only internal. The transition between clock id and hrtimer base is now expanded by the soft hrtimer bases and the corresponding clock ids. Update all hard hrtimer restricted queries to handle soft and hard hrtimers similarly. Signed-off-by: Anna-Maria Gleixner --- include/linux/hrtimer.h | 11 +++++++++++ kernel/time/hrtimer.c | 22 +++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -23,6 +23,17 @@ #include #include +/* + * Clock ids for hrtimers which expire in softirq context. These clock ids + * are kernel internal and never exported to user space. + */ +#define HRTIMER_BASE_SOFT_MASK MAX_CLOCKS + +#define CLOCK_REALTIME_SOFT (CLOCK_REALTIME | HRTIMER_BASE_SOFT_MASK) +#define CLOCK_MONOTONIC_SOFT (CLOCK_MONOTONIC | HRTIMER_BASE_SOFT_MASK) +#define CLOCK_BOOTTIME_SOFT (CLOCK_BOOTTIME | HRTIMER_BASE_SOFT_MASK) +#define CLOCK_TAI_SOFT (CLOCK_TAI | HRTIMER_BASE_SOFT_MASK) + struct hrtimer_clock_base; struct hrtimer_cpu_base; --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -60,18 +60,6 @@ #include "tick-internal.h" /* - * Clock ids for timers which expire in softirq context. These clock ids - * are kernel internal and never exported to user space. Kept internal - * until the rest of the functionality is in place. - */ -#define HRTIMER_BASE_SOFT_MASK MAX_CLOCKS - -#define CLOCK_REALTIME_SOFT (CLOCK_REALTIME | HRTIMER_BASE_SOFT_MASK) -#define CLOCK_MONOTONIC_SOFT (CLOCK_MONOTONIC | HRTIMER_BASE_SOFT_MASK) -#define CLOCK_BOOTTIME_SOFT (CLOCK_BOOTTIME | HRTIMER_BASE_SOFT_MASK) -#define CLOCK_TAI_SOFT (CLOCK_TAI | HRTIMER_BASE_SOFT_MASK) - -/* * Masks for selecting the soft and hard context timers from * cpu_base->active */ @@ -1173,7 +1161,7 @@ u64 hrtimer_get_next_event(void) static inline int hrtimer_clockid_to_base(clockid_t clock_id) { - if (likely(clock_id < MAX_CLOCKS)) { + if (likely(clock_id < MAX_CLOCKS_HRT)) { int base = hrtimer_clock_to_base_table[clock_id]; if (likely(base != HRTIMER_MAX_CLOCK_BASES)) @@ -1193,8 +1181,12 @@ static void __hrtimer_init(struct hrtime cpu_base = raw_cpu_ptr(&hrtimer_bases); - if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS) - clock_id = CLOCK_MONOTONIC; + if (mode != HRTIMER_MODE_ABS) { + if (clock_id == CLOCK_REALTIME) + clock_id = CLOCK_MONOTONIC; + else if (clock_id == CLOCK_REALTIME_SOFT) + clock_id = CLOCK_MONOTONIC_SOFT; + } base = hrtimer_clockid_to_base(clock_id); timer->base = &cpu_base->clock_base[base];