Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932840Ab0GAVHT (ORCPT ); Thu, 1 Jul 2010 17:07:19 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:42051 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758716Ab0GAVHK (ORCPT ); Thu, 1 Jul 2010 17:07:10 -0400 From: "Rafael J. Wysocki" To: Alan Stern Subject: Re: [update] Re: [PATCH] PM: Make it possible to avoid wakeup events from being lost Date: Thu, 1 Jul 2010 23:05:31 +0200 User-Agent: KMail/1.13.3 (Linux/2.6.35-rc3-rjw+; KDE/4.4.3; x86_64; ; ) Cc: linux-pm@lists.linux-foundation.org, Linux Kernel Mailing List , Neil Brown , Matthew Garrett , mark gross <640e9920@gmail.com>, Arve =?iso-8859-1?q?Hj=F8nnev=E5g?= , Dmitry Torokhov , Florian Mickler , linux-pci@vger.kernel.org, Jesse Barnes References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201007012305.31380.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1820 Lines: 50 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 > > #include > > #include > > +#include > > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/