From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753473AbdI0PyO (ORCPT ); Wed, 27 Sep 2017 11:54:14 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53829 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752489AbdI0PyL (ORCPT ); Wed, 27 Sep 2017 11:54:11 -0400 Date: Wed, 27 Sep 2017 17:54:02 +0200 (CEST) From: Thomas Gleixner To: Anna-Maria Gleixner cc: Peter Zijlstra , LKML , Ingo Molnar , Christoph Hellwig , keescook@chromium.org, John Stultz Subject: Re: [PATCH 18/25] hrtimer: Enable soft and hard hrtimer In-Reply-To: Message-ID: References: <20170831105725.809317030@linutronix.de> <20170831105826.997132802@linutronix.de> <20170926125206.63l6jlp76dhfu7um@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Sep 2017, Anna-Maria Gleixner wrote: > On Tue, 26 Sep 2017, Peter Zijlstra wrote: > > > On Thu, Aug 31, 2017 at 12:23:42PM -0000, Anna-Maria Gleixner wrote: > > > --- 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 > > > @@ -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_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 (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]; > > > > So why expose these extra bases at all, why not stick another flag in > > MODE? These extra bases is a pure implementation detail imo; you could > > equally implement the functionality without (albeit at extra cost). Right and that cost too high. > > > > It was Thomas' request not to use a flag for this. We can make that a flag as well. There is no hard requirement for making it a CLOCK. Peter is right that it's a pure internal implementation detail and we can hide it from the outside world. Thanks, tglx