* [PATCH] NET : Corrects a bug in ip_rt_acct_read()
@ 2007-11-16 10:25 Eric Dumazet
2007-11-16 10:32 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2007-11-16 10:25 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org
Hi David
Before the patch to convert ip_rt_acct to percpu storage,
I believe this bug should be corrected.
(against net-2.6.25 but might apply on previous kernels as well)
Thank you
[PATCH] NET : Corrects a bug in ip_rt_acct_read()
It seems that stats of cpu 0 are counted twice, since
for_each_possible_cpu() is looping on all possible cpus,
including 0
Before percpu conversion of ip_rt_acct, we should also remove
the assumption that CPU 0 is online (or even possible)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index f0b28f9..70529a9 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2884,18 +2884,14 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
offset /= sizeof(u32);
if (length > 0) {
- u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset;
u32 *dst = (u32 *) buffer;
- /* Copy first cpu. */
*start = buffer;
- memcpy(dst, src, length);
+ memset(dst, 0, length);
- /* Add the other cpus in, one int at a time */
for_each_possible_cpu(i) {
unsigned int j;
-
- src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
+ u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
for (j = 0; j < length/4; j++)
dst[j] += src[j];
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] NET : Corrects a bug in ip_rt_acct_read()
2007-11-16 10:25 [PATCH] NET : Corrects a bug in ip_rt_acct_read() Eric Dumazet
@ 2007-11-16 10:32 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-11-16 10:32 UTC (permalink / raw)
To: dada1; +Cc: netdev
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Fri, 16 Nov 2007 11:25:19 +0100
> [PATCH] NET : Corrects a bug in ip_rt_acct_read()
>
> It seems that stats of cpu 0 are counted twice, since
> for_each_possible_cpu() is looping on all possible cpus,
> including 0
>
> Before percpu conversion of ip_rt_acct, we should also remove
> the assumption that CPU 0 is online (or even possible)
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Applied, good catch Eric.
To make things easier for you I've applied it to both
net-2.6 and net-2.6.25
It seems like the code was trying to avoid that initial
memset, grabbing the first cpu explicitly and then copying
along the way. But the loop iterator wasn't adjusted
correctly and of course the zero-cpu-assumption you
noticed as well plays into this :-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-16 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-16 10:25 [PATCH] NET : Corrects a bug in ip_rt_acct_read() Eric Dumazet
2007-11-16 10:32 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).