diff options
author | Willem de Bruijn <willemb@google.com> | 2013-06-13 15:29:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-13 20:13:05 -0400 |
commit | 5f121b9a83b499a61ed44e5ba619c7de8f7271ad (patch) | |
tree | 6765d95f468e5c8c884af26f5fbfd2c6428d255d /include/linux/netdevice.h | |
parent | 85f16525a2eb66e6092cbd8dcf42371df8334ed0 (diff) |
net-rps: fixes for rps flow limit
Caught by sparse:
- __rcu: missing annotation to sd->flow_limit
- __user: direct access in cpumask_scnprintf
Also
- add endline character when printing bitmap if room in buffer
- avoid bucket overflow by reducing FLOW_LIMIT_HISTORY
The last item warrants some explanation. The hashtable buckets are
subject to overflow if FLOW_LIMIT_HISTORY is larger than or equal
to bucket size, since all packets may end up in a single bucket. The
current (rather arbitrary) history value of 256 happens to match the
buffer size (u8).
As a result, with a single flow, the first 128 packets are accepted
(correct), the second 128 packets dropped (correct) and then the
history[] array has filled, so that each subsequent new packet
causes an increment in the bucket for new_flow plus a decrement
for old_flow: a steady state.
This is fine if packets are dropped, as the steady state goes away
as soon as a mix of traffic reappears. But, because the 256th packet
overflowed the bucket to 0: no packets are dropped.
Instead of explicitly adding an overflow check, this patch changes
FLOW_LIMIT_HISTORY to never be able to overflow a single bucket.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
(first item)
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e5d65573b4d6..8c9fcc42502a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1840,7 +1840,7 @@ static inline int unregister_gifconf(unsigned int family) | |||
1840 | } | 1840 | } |
1841 | 1841 | ||
1842 | #ifdef CONFIG_NET_FLOW_LIMIT | 1842 | #ifdef CONFIG_NET_FLOW_LIMIT |
1843 | #define FLOW_LIMIT_HISTORY (1 << 8) /* must be ^2 */ | 1843 | #define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */ |
1844 | struct sd_flow_limit { | 1844 | struct sd_flow_limit { |
1845 | u64 count; | 1845 | u64 count; |
1846 | unsigned int num_buckets; | 1846 | unsigned int num_buckets; |
@@ -1883,7 +1883,7 @@ struct softnet_data { | |||
1883 | struct napi_struct backlog; | 1883 | struct napi_struct backlog; |
1884 | 1884 | ||
1885 | #ifdef CONFIG_NET_FLOW_LIMIT | 1885 | #ifdef CONFIG_NET_FLOW_LIMIT |
1886 | struct sd_flow_limit *flow_limit; | 1886 | struct sd_flow_limit __rcu *flow_limit; |
1887 | #endif | 1887 | #endif |
1888 | }; | 1888 | }; |
1889 | 1889 | ||