aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliezer Tamir <eliezer.tamir@linux.intel.com>2013-06-28 08:59:35 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-01 17:06:47 -0400
commit91e2fd337839319c7745e2cb84cfbf8cf1426a1a (patch)
tree1a832c8fb04fc687dfd40e4a4b69b15d60049172
parentad6276e0fe724b1c8ac3a0bf138d151665ab2349 (diff)
net: avoid calling sched_clock when LLS is off
Change Low Latency Sockets code for select and poll so that when LLS is disabled sched_clock() is never called. Also, avoid sending POLL_LL to sockets if disabled. Reported-by: Andi Kleen <andi@firstfloor.org> Signed-off-by: Eliezer Tamir <eliezer.tamir@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--fs/select.c11
-rw-r--r--include/net/ll_poll.h17
2 files changed, 22 insertions, 6 deletions
diff --git a/fs/select.c b/fs/select.c
index 79b876eb91da..36540754bad7 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -402,7 +402,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
402 poll_table *wait; 402 poll_table *wait;
403 int retval, i, timed_out = 0; 403 int retval, i, timed_out = 0;
404 unsigned long slack = 0; 404 unsigned long slack = 0;
405 unsigned int ll_flag = POLL_LL; 405 unsigned int ll_flag = ll_get_flag();
406 u64 ll_time = ll_end_time(); 406 u64 ll_time = ll_end_time();
407 407
408 rcu_read_lock(); 408 rcu_read_lock();
@@ -497,7 +497,8 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
497 break; 497 break;
498 } 498 }
499 499
500 if (can_ll && can_poll_ll(ll_time)) 500 /* only if on, have sockets with POLL_LL and not out of time */
501 if (ll_flag && can_ll && can_poll_ll(ll_time))
501 continue; 502 continue;
502 503
503 /* 504 /*
@@ -768,7 +769,7 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
768 ktime_t expire, *to = NULL; 769 ktime_t expire, *to = NULL;
769 int timed_out = 0, count = 0; 770 int timed_out = 0, count = 0;
770 unsigned long slack = 0; 771 unsigned long slack = 0;
771 unsigned int ll_flag = POLL_LL; 772 unsigned int ll_flag = ll_get_flag();
772 u64 ll_time = ll_end_time(); 773 u64 ll_time = ll_end_time();
773 774
774 /* Optimise the no-wait case */ 775 /* Optimise the no-wait case */
@@ -817,8 +818,10 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
817 if (count || timed_out) 818 if (count || timed_out)
818 break; 819 break;
819 820
820 if (can_ll && can_poll_ll(ll_time)) 821 /* only if on, have sockets with POLL_LL and not out of time */
822 if (ll_flag && can_ll && can_poll_ll(ll_time))
821 continue; 823 continue;
824
822 /* 825 /*
823 * If this is the first loop and we have a timeout 826 * If this is the first loop and we have a timeout
824 * given, then we convert to ktime_t and set the to 827 * given, then we convert to ktime_t and set the to
diff --git a/include/net/ll_poll.h b/include/net/ll_poll.h
index 6d45e6f6ff4c..6c06f7c0a22d 100644
--- a/include/net/ll_poll.h
+++ b/include/net/ll_poll.h
@@ -37,6 +37,11 @@ extern unsigned int sysctl_net_ll_poll __read_mostly;
37#define LL_FLUSH_FAILED -1 37#define LL_FLUSH_FAILED -1
38#define LL_FLUSH_BUSY -2 38#define LL_FLUSH_BUSY -2
39 39
40static inline unsigned int ll_get_flag(void)
41{
42 return sysctl_net_ll_poll ? POLL_LL : 0;
43}
44
40/* a wrapper to make debug_smp_processor_id() happy 45/* a wrapper to make debug_smp_processor_id() happy
41 * we can use sched_clock() because we don't care much about precision 46 * we can use sched_clock() because we don't care much about precision
42 * we only care that the average is bounded 47 * we only care that the average is bounded
@@ -67,10 +72,14 @@ static inline u64 ll_sk_end_time(struct sock *sk)
67 return ((u64)ACCESS_ONCE(sk->sk_ll_usec) << 10) + ll_sched_clock(); 72 return ((u64)ACCESS_ONCE(sk->sk_ll_usec) << 10) + ll_sched_clock();
68} 73}
69 74
70/* in poll/select we use the global sysctl_net_ll_poll value */ 75/* in poll/select we use the global sysctl_net_ll_poll value
76 * only call sched_clock() if enabled
77 */
71static inline u64 ll_end_time(void) 78static inline u64 ll_end_time(void)
72{ 79{
73 return ((u64)ACCESS_ONCE(sysctl_net_ll_poll) << 10) + ll_sched_clock(); 80 u64 end_time = ACCESS_ONCE(sysctl_net_ll_poll);
81
82 return end_time ? (end_time << 10) + ll_sched_clock() : 0;
74} 83}
75 84
76static inline bool sk_valid_ll(struct sock *sk) 85static inline bool sk_valid_ll(struct sock *sk)
@@ -141,6 +150,10 @@ static inline void sk_mark_ll(struct sock *sk, struct sk_buff *skb)
141} 150}
142 151
143#else /* CONFIG_NET_LL_RX_POLL */ 152#else /* CONFIG_NET_LL_RX_POLL */
153static inline unsigned long ll_get_flag(void)
154{
155 return 0;
156}
144 157
145static inline u64 sk_ll_end_time(struct sock *sk) 158static inline u64 sk_ll_end_time(struct sock *sk)
146{ 159{