[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201007012305.31380.rjw@sisk.pl>
Date: Thu, 1 Jul 2010 23:05:31 +0200
From: "Rafael J. Wysocki" <rjw@...k.pl>
To: Alan Stern <stern@...land.harvard.edu>
Cc: linux-pm@...ts.linux-foundation.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Neil Brown <neilb@...e.de>,
Matthew Garrett <mjg59@...f.ucam.org>,
mark gross <640e9920@...il.com>,
Arve Hjønnevåg <arve@...roid.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Florian Mickler <florian@...kler.org>,
linux-pci@...r.kernel.org, Jesse Barnes <jbarnes@...tuousgeek.org>
Subject: Re: [update] Re: [PATCH] PM: Make it possible to avoid wakeup events from being lost
On Thursday, July 01, 2010, Alan Stern wrote:
> On Thu, 1 Jul 2010, Rafael J. Wysocki wrote:
>
> > > > + if (msec) {
> > > > + ktime_t kt;
> > > > + struct timespec ts;
> > > > + unsigned long expires;
> > > > +
> > > > + kt = ktime_get();
> > > > + kt = ktime_add_ns(kt, msec * NSEC_PER_MSEC);
> > > > + ts = ktime_to_timespec(kt);
> > > > + expires = timespec_to_jiffies(&ts);
> > >
> > > Is this somehow better than jiffies + msecs_to_jiffies(msec)?
> >
> > I'm not sure about overflows. That said, the "+" version is used in many
> > places, so there's no problem I think.
>
> Hmm. NSEC_PER_MSEC must be one million, right? So if msec referred to
> anything above 4 seconds (which seems unlikely but not impossible), the
> multiplication would overflow on a 32-bit machine.
>
> Apart from that, the main difference between the two patches lies in
> when the events are counted, i.e., whether event_count gets incremented
> at the start or when the timer expires. I can't see that it matters
> much either way.
Well, your version doesn't require the additional static variable and
generally takes fewer lines of code. :-)
> > Index: linux-2.6/drivers/base/power/wakeup.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/base/power/wakeup.c
> > +++ linux-2.6/drivers/base/power/wakeup.c
> > @@ -9,6 +9,7 @@
> > #include <linux/device.h>
> > #include <linux/slab.h>
> > #include <linux/sched.h>
> > +#include <linux/ktime.h>
>
> This isn't needed any more.
Right, I've dropped this line.
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists