lkml.org 
[lkml]   [2004]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[2/2] fix io_getevents() timer expiry setting
On Tue, Jun 01, 2004 at 06:24:29PM -0700, William Lee Irwin III wrote:
> The time conversion functions may have const args, which is in fact
> useful for when they are passed const variables as arguments so as
> to avoid discarding qualifiers from pointer types warnings. This is
> a preparatory cleanup for a minor aio bugfix.

start_jiffies was not respected by set_timeout(), which reread jiffies
instead of respecting what read_events() passed it. This difference can
be significant, particularly if the calling process slept during the
copy_to_user() operation in read_events(). To correct this, this patch
teaches it to respect its argument, with the additional bonus of
converting it to use timespec_to_jiffies() instead of open-coding it.

Index: timer-2.6.7-rc2/fs/aio.c
===================================================================
--- timer-2.6.7-rc2.orig/fs/aio.c 2004-06-01 03:25:53.000000000 -0700
+++ timer-2.6.7-rc2/fs/aio.c 2004-06-01 16:03:41.000000000 -0700
@@ -777,19 +777,11 @@
static inline void set_timeout(long start_jiffies, struct timeout *to,
const struct timespec *ts)
{
- unsigned long how_long;
-
- if (ts->tv_sec < 0 || (!ts->tv_sec && !ts->tv_nsec)) {
+ to->timer.expires = start_jiffies + timespec_to_jiffies(ts);
+ if (time_after(to->timer.expires, jiffies))
+ add_timer(&to->timer);
+ else
to->timed_out = 1;
- return;
- }
-
- how_long = ts->tv_sec * HZ;
-#define HZ_NS (1000000000 / HZ)
- how_long += (ts->tv_nsec + HZ_NS - 1) / HZ_NS;
-
- to->timer.expires = jiffies + how_long;
- add_timer(&to->timer);
}

static inline void clear_timeout(struct timeout *to)
-
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/
\
 
 \ /
  Last update: 2005-03-22 14:03    [from the cache]
©2003-2011 Jasper Spaans