Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-21 Thread Al Viro
On Sun, May 21, 2017 at 07:57:53PM +0200, Thomas Gleixner wrote: > On Thu, 18 May 2017, Christoph Hellwig wrote: > > On Thu, May 18, 2017 at 10:24:48AM +0200, Christoph Hellwig wrote: > > > > b) give the union a name (breaks any reference to timer_list->func in C > > > > code): > > > > > > > > +

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-21 Thread Thomas Gleixner
On Thu, 18 May 2017, Christoph Hellwig wrote: > On Thu, May 18, 2017 at 10:24:48AM +0200, Christoph Hellwig wrote: > > > b) give the union a name (breaks any reference to timer_list->func in C > > > code): > > > > > > + union { > > > + void(*func)(struct timer_li

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-21 Thread Arnd Bergmann
On Sun, May 21, 2017 at 9:00 AM, Christoph Hellwig wrote: > On Thu, May 18, 2017 at 10:57:31AM +0200, Arnd Bergmann wrote: >> How expensive would it be to add another field to timer_list and >> just have both pointers? > > That would add 4/8 bytes to every structure containing a timer, > so I'd ra

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-21 Thread Christoph Hellwig
On Thu, May 18, 2017 at 10:57:31AM +0200, Arnd Bergmann wrote: > How expensive would it be to add another field to timer_list and > just have both pointers? That would add 4/8 bytes to every structure containing a timer, so I'd rather avoid it if possible. But one option might be to inflict this

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-20 Thread 'Christoph Hellwig'
On Fri, May 19, 2017 at 10:48:51AM +, David Laight wrote: > From: Christoph Hellwig > > Sent: 16 May 2017 12:48 > > > > The new callback gets a pointer to the timer_list itself, which can > > then be used to get the containing structure using container_of > > instead of casting from and to unsi

RE: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-19 Thread David Laight
From: Christoph Hellwig > Sent: 16 May 2017 12:48 > > The new callback gets a pointer to the timer_list itself, which can > then be used to get the containing structure using container_of > instead of casting from and to unsigned long all the time. What about sensible drivers that put some other v

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-18 Thread Arnd Bergmann
On Thu, May 18, 2017 at 10:41 AM, Christoph Hellwig wrote: > On Thu, May 18, 2017 at 10:24:48AM +0200, Christoph Hellwig wrote: >> > b) give the union a name (breaks any reference to timer_list->func in C >> > code): >> > >> > + union { >> > + void(*func)(struct

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-18 Thread Christoph Hellwig
On Thu, May 18, 2017 at 10:24:48AM +0200, Christoph Hellwig wrote: > > b) give the union a name (breaks any reference to timer_list->func in C > > code): > > > > + union { > > + void(*func)(struct timer_list *timer); > > + void(*functio

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-18 Thread Christoph Hellwig
> b) give the union a name (breaks any reference to timer_list->func in C code): > > + union { > + void(*func)(struct timer_list *timer); > + void(*function)(unsigned long); > + } u; I'll look into that, as it seems a lot safer,

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-16 Thread Arnd Bergmann
On Tue, May 16, 2017 at 1:48 PM, Christoph Hellwig wrote: > unsigned long expires; > - void(*function)(unsigned long); > + union { > + void(*func)(struct timer_list *timer); > + void(*function)(u

Re: [PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-16 Thread Randy Dunlap
On 05/16/17 04:48, Christoph Hellwig wrote: > diff --git a/include/linux/timer.h b/include/linux/timer.h > index e6789b8757d5..87afe52c8349 100644 > --- a/include/linux/timer.h > +++ b/include/linux/timer.h \ > @@ -126,6 +146,32 @@ static inline void init_timer_on_stack_key(struct

[PATCH 2/9] timers: provide a "modern" variant of timers

2017-05-16 Thread Christoph Hellwig
The new callback gets a pointer to the timer_list itself, which can then be used to get the containing structure using container_of instead of casting from and to unsigned long all the time. The setup helpers take a flags argument instead of needing countless variants. Note: this further reduces