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 <linux/timer.h>
> > >  #include <linux/timerqueue.h>
> > >  
> > > +/*
> > > + * 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

Reply via email to