Re: [PATCH 8/9] hrtimer: Allow hrtimer::function() to free the timer

From: Ingo Molnar
Date: Thu Jun 04 2015 - 01:59:50 EST



* Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> On Wed, Jun 03, 2015 at 07:41:43PM +0200, Thomas Gleixner wrote:
> > On Wed, 3 Jun 2015, Peter Zijlstra wrote:
> > > /**
> > > * struct hrtimer - the basic hrtimer structure
> > > @@ -153,6 +144,7 @@ struct hrtimer_clock_base {
> > > struct timerqueue_head active;
> > > ktime_t (*get_time)(void);
> > > ktime_t offset;
> > > + struct hrtimer *running;
> >
> > Aside of lacking a KernelDoc comment, it expands the struct size on
> > 32bit from 32 bytes to 36 bytes which undoes some of the recent cache
> > line optimizations I did. Mooo!
> >
> > So we might think about storing the running timer pointer in cpu_base
> > instead for 32bit, which increases the foot print of the migration
> > base and the extra cost for the additional indirection, but it would
> > keep cache line tight for the hot pathes.
>
> A wee something like this then?
>
> ---
> --- a/include/linux/hrtimer.h
> +++ b/include/linux/hrtimer.h
> @@ -123,8 +123,10 @@ struct hrtimer_sleeper {
>
> #ifdef CONFIG_64BIT
> # define HRTIMER_CLOCK_BASE_ALIGN 64
> +# define __timer_base_running(timer) timer->base->running
> #else
> # define HRTIMER_CLOCK_BASE_ALIGN 32
> +# define __timer_base_running(timer) timer->base->cpu_base->running
> #endif

Please put it into the cpu_base on 64-bit as well: the base pointer is available
already on 64-bit so there should be no measurable performance difference, and
readability is a primary concern with all this code.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/