提交 cf8da764 编写于 作者: E Eric Dumazet 提交者: David S. Miller

net: fix length computation in rt_check_expire()

rt_check_expire() computes average and standard deviation of chain lengths,
but not correclty reset length to 0 at beginning of each chain.
This probably gives overflows for sum2 (and sum) on loaded machines instead
of meaningful results.
Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
Acked-by: NNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bc8a5397
...@@ -785,7 +785,7 @@ static void rt_check_expire(void) ...@@ -785,7 +785,7 @@ static void rt_check_expire(void)
static unsigned int rover; static unsigned int rover;
unsigned int i = rover, goal; unsigned int i = rover, goal;
struct rtable *rth, **rthp; struct rtable *rth, **rthp;
unsigned long length = 0, samples = 0; unsigned long samples = 0;
unsigned long sum = 0, sum2 = 0; unsigned long sum = 0, sum2 = 0;
u64 mult; u64 mult;
...@@ -795,9 +795,9 @@ static void rt_check_expire(void) ...@@ -795,9 +795,9 @@ static void rt_check_expire(void)
goal = (unsigned int)mult; goal = (unsigned int)mult;
if (goal > rt_hash_mask) if (goal > rt_hash_mask)
goal = rt_hash_mask + 1; goal = rt_hash_mask + 1;
length = 0;
for (; goal > 0; goal--) { for (; goal > 0; goal--) {
unsigned long tmo = ip_rt_gc_timeout; unsigned long tmo = ip_rt_gc_timeout;
unsigned long length;
i = (i + 1) & rt_hash_mask; i = (i + 1) & rt_hash_mask;
rthp = &rt_hash_table[i].chain; rthp = &rt_hash_table[i].chain;
...@@ -809,6 +809,7 @@ static void rt_check_expire(void) ...@@ -809,6 +809,7 @@ static void rt_check_expire(void)
if (*rthp == NULL) if (*rthp == NULL)
continue; continue;
length = 0;
spin_lock_bh(rt_hash_lock_addr(i)); spin_lock_bh(rt_hash_lock_addr(i));
while ((rth = *rthp) != NULL) { while ((rth = *rthp) != NULL) {
if (rt_is_expired(rth)) { if (rt_is_expired(rth)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册