Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932130Ab0GAUoK (ORCPT ); Thu, 1 Jul 2010 16:44:10 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:59894 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1758291Ab0GAUoH (ORCPT ); Thu, 1 Jul 2010 16:44:07 -0400 Date: Thu, 1 Jul 2010 16:44:04 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Rafael J. Wysocki" 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 , , Jesse Barnes Subject: Re: [update] Re: [PATCH] PM: Make it possible to avoid wakeup events from being lost In-Reply-To: <201007012208.11464.rjw@sisk.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1564 Lines: 46 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. > 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. Alan Stern -- 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/