lkml.org 
[lkml]   [2008]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ip2: avoid add_timer() with pending timer
On Mon, Jul 14, 2008 at 10:04:02AM -0700, Andrew Morton wrote:
> On Mon, 14 Jul 2008 11:49:55 +0900 Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> > @@ -746,10 +742,8 @@ ip2_loadmain(int *iop, int *irqp)
> > }
> > if ( ip2config.irq[i] == CIR_POLL ) {
> > retry:
> > - if (!TimerOn) {
> > - PollTimer.expires = POLL_TIMEOUT;
> > - add_timer ( &PollTimer );
> > - TimerOn = 1;
> > + if (!timer_pending(&PollTimer)) {
> > + mod_timer(&PollTimer, POLL_TIMEOUT);
> > printk( KERN_INFO "IP2: polling\n");
>
> This change to ip2_loadmain() might be racy if it actually did
> anything. But afaict timer_pending() can never be true here (we're
> only called from module_init()) so it can and should be removed.

Yes, ip2_loadmain() is only called from module_init(). But this add_timer()
is in the loop for each device. So it may be called more than once.

And yes, I can remove timer_pending() here because I switched to use
mod_timer() instead of add_timer(). But this PollTimer works as periodic
timer and it's global timer. So it will not cause a problem.



\
 
 \ /
  Last update: 2008-07-15 05:09    [W:0.105 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site