Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646389

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

From Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 2/9] timers: provide a "modern" variant of timers
Date 2017-05-21 20:30 +0200
Message-ID <tJDM5-2Sz-3@gated-at.bofh.it> (permalink)
References (1 earlier) <tHJiX-59w-29@gated-at.bofh.it> <tHQX8-1J7-23@gated-at.bofh.it> <tIoYN-7HX-9@gated-at.bofh.it> <tIpi9-7Qp-7@gated-at.bofh.it> <tJDj3-2tw-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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):
> > > > 
> > > >  +       union {
> > > >  +               void            (*func)(struct timer_list *timer);
> > > >  +               void            (*function)(unsigned long);
> > > >  +       } u;
> > > 
> > > I'll look into that, as it seems a lot safer, and places outside
> > > the timer code shouldn't really touch it (although I bet they do,
> > > so more fixes for this series..)
> > 
> > Meh.  All the old init_timer users set function directly, so
> > I guess we need to use the other approach.
> 
> There is another possibility. Create a coccinelle script which wraps all
> 
>       timer.function = f;
>       timer->function = f;
> 
> assignements into a helper timer_set_function(timer, func) and ask Linus to
> run it right before the next -rc. That handles everything in tree and the
> few new instances in next can be addressed with patches sent to the
> maintainers.

FWIW, there was another possible approach - I toyed with that several years
ago, but it didn't go anywhere.  Namely, make timer.function take void *
*and* turn the setup part into setup(timer, callback, argument), verifying
that
	* callback(argument) will be acceptable expression for C typechecking
	* callback returns void
	* argument is a pointer type
then cast callback to void (*)(void *) and argument to void *.  That way
we get rid of any boilerplate in callbacks and get sane typechecking...

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

RFC: better timer interface Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
  [PATCH 3/9] kthread: remove unused macros Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
    Re: [PATCH 3/9] kthread: remove unused macros Petr Mladek <pmladek@suse.com> - 2017-05-17 14:20 +0200
      Re: [PATCH 3/9] kthread: remove unused macros Christoph Hellwig <hch@lst.de> - 2017-05-18 10:30 +0200
  [PATCH 8/9] tlclk: switch switchover_timer to a modern timer Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
  [PATCH 6/9] s390: switch topology_timer to a modern timer Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
  [PATCH 4/9] workqueue: switch to modern timers Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
  [PATCH 7/9] s390: switch lgr timer to a modern timer Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
  [PATCH 9/9] timers: remove old timer initialization macros Christoph Hellwig <hch@lst.de> - 2017-05-16 13:50 +0200
    Re: [PATCH 9/9] timers: remove old timer initialization macros Arnd Bergmann <arnd@arndb.de> - 2017-05-16 21:50 +0200
      Re: [PATCH 9/9] timers: remove old timer initialization macros Christoph Hellwig <hch@lst.de> - 2017-05-18 10:30 +0200
  [PATCH 2/9] timers: provide a "modern" variant of timers Christoph Hellwig <hch@lst.de> - 2017-05-16 14:00 +0200
    Re: [PATCH 2/9] timers: provide a "modern" variant of timers Randy Dunlap <rdunlap@infradead.org> - 2017-05-16 21:30 +0200
    Re: [PATCH 2/9] timers: provide a "modern" variant of timers Arnd Bergmann <arnd@arndb.de> - 2017-05-16 22:10 +0200
      Re: [PATCH 2/9] timers: provide a "modern" variant of timers Christoph Hellwig <hch@lst.de> - 2017-05-18 10:30 +0200
        Re: [PATCH 2/9] timers: provide a "modern" variant of timers Christoph Hellwig <hch@lst.de> - 2017-05-18 10:50 +0200
          Re: [PATCH 2/9] timers: provide a "modern" variant of timers Arnd Bergmann <arnd@arndb.de> - 2017-05-18 11:00 +0200
            Re: [PATCH 2/9] timers: provide a "modern" variant of timers Christoph Hellwig <hch@lst.de> - 2017-05-21 09:10 +0200
              Re: [PATCH 2/9] timers: provide a "modern" variant of timers Arnd Bergmann <arnd@arndb.de> - 2017-05-21 14:30 +0200
          Re: [PATCH 2/9] timers: provide a "modern" variant of timers Thomas Gleixner <tglx@linutronix.de> - 2017-05-21 20:00 +0200
            Re: [PATCH 2/9] timers: provide a "modern" variant of timers Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-21 20:30 +0200
    RE: [PATCH 2/9] timers: provide a "modern" variant of timers David Laight <David.Laight@ACULAB.COM> - 2017-05-19 12:50 +0200
      Re: [PATCH 2/9] timers: provide a "modern" variant of timers 'Christoph Hellwig' <hch@lst.de> - 2017-05-21 09:00 +0200
  [PATCH 5/9] powerpc/numa: switch topology_timer to modern timer Christoph Hellwig <hch@lst.de> - 2017-05-16 14:00 +0200
  Re: RFC: better timer interface Arnd Bergmann <arnd@arndb.de> - 2017-05-16 17:50 +0200
    Re: RFC: better timer interface Christoph Hellwig <hch@lst.de> - 2017-05-16 18:00 +0200
      Re: RFC: better timer interface Arnd Bergmann <arnd@arndb.de> - 2017-05-16 22:30 +0200
        Re: RFC: better timer interface Christoph Hellwig <hch@lst.de> - 2017-05-18 10:30 +0200
        Re: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-21 19:20 +0200
          Re: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-21 20:20 +0200
            Re: RFC: better timer interface Arnd Bergmann <arnd@arndb.de> - 2017-05-22 13:30 +0200
              Re: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-22 21:30 +0200
            RE: RFC: better timer interface David Laight <David.Laight@ACULAB.COM> - 2017-05-23 13:40 +0200
              RE: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-23 14:00 +0200
                RE: RFC: better timer interface David Laight <David.Laight@ACULAB.COM> - 2017-05-23 15:00 +0200
                RE: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-23 15:10 +0200
          Re: RFC: better timer interface Arnd Bergmann <arnd@arndb.de> - 2017-05-22 15:40 +0200
            Re: RFC: better timer interface Thomas Gleixner <tglx@linutronix.de> - 2017-05-22 21:20 +0200

csiph-web