[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080829080843.6c8b46e2@infradead.org>
Date: Fri, 29 Aug 2008 08:08:43 -0700
From: Arjan van de Ven <arjan@...radead.org>
To: linux-kernel@...r.kernel.org
Cc: Arjan van de Ven <arjan@...radead.org>, mingo@...e.hu,
tglx@...x.de, torvalds@...ux-foundation.org
Subject: [PATCH 5/5] select: make poll() use schedule_hrtimeout() as well
From: Arjan van de Ven <arjan@...ux.intel.com>
Date: Thu, 28 Aug 2008 13:46:47 -0700
Subject: [PATCH] select: make poll() use schedule_hrtimeout() as well
similar to the select() patch, use schedule_hrtimeout() in the
poll() codepath.
Signed-off-by: Arjan van de Ven <arjan@...ux.intel.com>
---
fs/select.c | 46 ++++++++++++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/fs/select.c b/fs/select.c
index 62b9767..e881b97 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -631,6 +631,10 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
{
int count = 0;
poll_table* pt = &wait->pt;
+ int use_hr = 0;
+
+ if (*timeout < HZ && *timeout > 0)
+ use_hr = 1;
/* Optimise the no-wait case */
if (!(*timeout))
@@ -673,24 +677,34 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
if (count || !*timeout)
break;
- if (*timeout < 0) {
- /* Wait indefinitely */
- __timeout = MAX_SCHEDULE_TIMEOUT;
- } else if (unlikely(*timeout >= (s64)MAX_SCHEDULE_TIMEOUT-1)) {
- /*
- * Wait for longer than MAX_SCHEDULE_TIMEOUT. Do it in
- * a loop
- */
- __timeout = MAX_SCHEDULE_TIMEOUT - 1;
- *timeout -= __timeout;
+ if (use_hr) {
+ struct timespec now;
+ ktime_t expire;
+ schedule_hrtimeout(end_time, HRTIMER_MODE_ABS);
+ getnstimeofday(&now);
+ expire = ktime_sub(timespec_to_ktime(*end_time), timespec_to_ktime(now));
+ if (ktime_to_ns(expire) <= 0)
+ break;
} else {
- __timeout = *timeout;
- *timeout = 0;
- }
+ if (*timeout < 0) {
+ /* Wait indefinitely */
+ __timeout = MAX_SCHEDULE_TIMEOUT;
+ } else if (unlikely(*timeout >= (s64)MAX_SCHEDULE_TIMEOUT-1)) {
+ /*
+ * Wait for longer than MAX_SCHEDULE_TIMEOUT. Do it in
+ * a loop
+ */
+ __timeout = MAX_SCHEDULE_TIMEOUT - 1;
+ *timeout -= __timeout;
+ } else {
+ __timeout = *timeout;
+ *timeout = 0;
+ }
- __timeout = schedule_timeout(__timeout);
- if (*timeout >= 0)
- *timeout += __timeout;
+ __timeout = schedule_timeout(__timeout);
+ if (*timeout >= 0)
+ *timeout += __timeout;
+ }
}
__set_current_state(TASK_RUNNING);
return count;
--
1.5.5.1
--
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