Skip to contentSkip to conversation

net/fs: change busy poll time accounting

PATCH In review Eliezer Tamir 2 participants 2 messages Jul 9, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/fs: change busy poll time accounting

Sorry, I forgot to commit before sending, so I sent the wrong version. The previous version gets a warning in busy_loop_timeout().

Suggested by Linus:
Changed time accounting for busy-poll:
- Make it microsecond based.
- Use unsigned longs.
- Revert back to use time_after instead of time_in_range. Reorder poll/select busy loop conditions:
- Clear busy_flag after one time we can't busy-poll.
- Only init busy_end if we actually are going to busy-poll. Added one more missing need_resched() test.

---

 fs/select.c           |   31 ++++++++++++++++++----------
 include/net/ll_poll.h |   55 ++++++++++++++++---------------------------------
 2 files changed, 38 insertions(+), 48 deletions(-)
fs/select.c +20 -11
index 25cac5f..50a804b 100644
@@ -403,8 +403,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 	int retval, i, timed_out = 0;
 	unsigned long slack = 0;
 	unsigned int busy_flag = net_busy_loop_on() ? POLL_BUSY_LOOP : 0;
-	u64 busy_start = busy_loop_start_time(busy_flag);
-	u64 busy_end = busy_loop_end_time();
+	unsigned long busy_end = 0;
 
 	rcu_read_lock();
 	retval = max_select_fd(n, fds);
@@ -506,9 +505,15 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 		}
 
 		/* only if found POLL_BUSY_LOOP sockets && not out of time */
-		if (!need_resched() && can_busy_loop &&
-		    busy_loop_range(busy_start, busy_end))
-			continue;
+		if (can_busy_loop && !need_resched()) {
+			if (!busy_end) {
+				busy_end = busy_loop_end_time();
+				continue;
+			}
+			if (!busy_loop_timeout(busy_end))
+				continue;
+		}
+		busy_flag = 0;
 
 		/*
 		 * If this is the first loop and we have a timeout
@@ -780,9 +785,7 @@ static int do_poll(unsigned int nfds,  struct poll_list *list,
 	int timed_out = 0, count = 0;
 	unsigned long slack = 0;
 	unsigned int busy_flag = net_busy_loop_on() ? POLL_BUSY_LOOP : 0;
-	u64 busy_start = busy_loop_start_time(busy_flag);
-	u64 busy_end = busy_loop_end_time();
-
+	unsigned long busy_end = 0;
 
 	/* Optimise the no-wait case */
 	if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
@@ -834,9 +837,15 @@ static int do_poll(unsigned int nfds,  struct poll_list *list,
 			break;
 
 		/* only if found POLL_BUSY_LOOP sockets && not out of time */
-		if (!need_resched() && can_busy_loop &&
-		    busy_loop_range(busy_start, busy_end))
-			continue;
+		if (can_busy_loop && !need_resched()) {
+			if (!busy_end) {
+				busy_end = busy_loop_end_time();
+				continue;
+			}
+			if (!busy_loop_timeout(busy_end))
+				continue;
+		}
+		busy_flag = 0;
 
 		/*
 		 * If this is the first loop and we have a timeout
include/net/ll_poll.h +18 -37

110 lines not on this page · raw message

maintainer
#1 lore raw

From: Eliezer Tamir <[email protected]>
Date: Tue, 09 Jul 2013 13:09:21 +0300

Quoted 13 lines

Sorry, I forgot to commit before sending, so I sent the wrong version. The previous version gets a warning in busy_loop_timeout().

Suggested by Linus:
Changed time accounting for busy-poll:
- Make it microsecond based.
- Use unsigned longs.
- Revert back to use time_after instead of time_in_range. Reorder poll/select busy loop conditions:
- Clear busy_flag after one time we can't busy-poll.
- Only init busy_end if we actually are going to busy-poll. Added one more missing need_resched() test.

Quoted 1 line

Ok, looks good, applied.

Thanks!