This is a note to let you know that I've just added the patch titled
epoll: epoll_wait() should not use timespec_add_ns()
to the 2.6.37-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
epoll-epoll_wait-should-not-use-timespec_add_ns.patch
and it can be found in the queue-2.6.37 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From 0781b909b5586f4db720b5d1838b78f9d8e42f14 Mon Sep 17 00:00:00 2001
From: Eric Dumazet <[email protected]>
Date: Tue, 1 Feb 2011 15:52:35 -0800
Subject: epoll: epoll_wait() should not use timespec_add_ns()
From: Eric Dumazet <[email protected]>
commit 0781b909b5586f4db720b5d1838b78f9d8e42f14 upstream.
commit 95aac7b1cd224f ("epoll: make epoll_wait() use the hrtimer range
feature") added a performance regression because it uses timespec_add_ns()
with potential very large 'ns' values.
[[email protected]: s/epoll_set_mstimeout/ep_set_mstimeout/, per Davide]
Reported-by: Simon Kirby <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Cc: Shawn Bohrer <[email protected]>
Acked-by: Davide Libenzi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
fs/eventpoll.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1111,6 +1111,17 @@ static int ep_send_events(struct eventpo
return ep_scan_ready_list(ep, ep_send_events_proc, &esed);
}
+static inline struct timespec ep_set_mstimeout(long ms)
+{
+ struct timespec now, ts = {
+ .tv_sec = ms / MSEC_PER_SEC,
+ .tv_nsec = NSEC_PER_MSEC * (ms % MSEC_PER_SEC),
+ };
+
+ ktime_get_ts(&now);
+ return timespec_add_safe(now, ts);
+}
+
static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
int maxevents, long timeout)
{
@@ -1118,12 +1129,11 @@ static int ep_poll(struct eventpoll *ep,
unsigned long flags;
long slack;
wait_queue_t wait;
- struct timespec end_time;
ktime_t expires, *to = NULL;
if (timeout > 0) {
- ktime_get_ts(&end_time);
- timespec_add_ns(&end_time, (u64)timeout * NSEC_PER_MSEC);
+ struct timespec end_time = ep_set_mstimeout(timeout);
+
slack = select_estimate_accuracy(&end_time);
to = &expires;
*to = timespec_to_ktime(end_time);
Patches currently in stable-queue which might be from [email protected] are
queue-2.6.37/net_sched-pfifo_head_drop-problem.patch
queue-2.6.37/net-add-pollpri-to-sock_def_readable.patch
queue-2.6.37/epoll-epoll_wait-should-not-use-timespec_add_ns.patch
queue-2.6.37/net-fix-ip-link-add-netns-oops.patch
queue-2.6.37/ipv4-ip-defragmentation-must-be-ecn-aware.patch
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable