netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] net: make ip_rt_acct a normal percpu var
Date: Mon, 17 Nov 2008 23:36:14 +0100	[thread overview]
Message-ID: <4921F1DE.9080305@cosmosbay.com> (raw)
In-Reply-To: <200811172050.31308.rusty@rustcorp.com.au>

Rusty Russell a écrit :
> There's no reason for this to be dynamically allocated: we panic if
> allocation fails anyway.
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> 

Well, since we dont have "per_cpu bss", this also grow the size of vmlinux file, with
a block of 4096 nul bytes.

Same thing for rt_hash_lock_init() : We dynamically allocate the rt_hash_locks,
while its size is usually quite small, and we could avoid the pointer.

Maybe with current machines/boot loaders, we dont care anymore, I dont know...

> diff -r 643c2cdfdb62 include/net/route.h
> --- a/include/net/route.h	Mon Nov 17 19:57:42 2008 +1030
> +++ b/include/net/route.h	Mon Nov 17 20:23:37 2008 +1030
> @@ -34,6 +34,7 @@
>  #include <linux/ip.h>
>  #include <linux/cache.h>
>  #include <linux/security.h>
> +#include <linux/percpu.h>
>  
>  #ifndef __KERNEL__
>  #warning This file is not supposed to be used outside of kernel.
> @@ -105,7 +106,7 @@
>          unsigned int out_hlist_search;
>  };
>  
> -extern struct ip_rt_acct *ip_rt_acct;
> +DECLARE_PER_CPU(struct ip_rt_acct[256], ip_rt_acct);
>  
>  struct in_device;
>  extern int		ip_rt_init(void);
> diff -r 643c2cdfdb62 net/ipv4/ip_input.c
> --- a/net/ipv4/ip_input.c	Mon Nov 17 19:57:42 2008 +1030
> +++ b/net/ipv4/ip_input.c	Mon Nov 17 20:23:37 2008 +1030
> @@ -339,7 +339,7 @@
>  
>  #ifdef CONFIG_NET_CLS_ROUTE
>  	if (unlikely(skb->dst->tclassid)) {
> -		struct ip_rt_acct *st = per_cpu_ptr(ip_rt_acct, smp_processor_id());
> +		struct ip_rt_acct *st = __get_cpu_var(ip_rt_acct);
>  		u32 idx = skb->dst->tclassid;
>  		st[idx&0xFF].o_packets++;
>  		st[idx&0xFF].o_bytes+=skb->len;
> diff -r 643c2cdfdb62 net/ipv4/route.c
> --- a/net/ipv4/route.c	Mon Nov 17 19:57:42 2008 +1030
> +++ b/net/ipv4/route.c	Mon Nov 17 20:23:37 2008 +1030
> @@ -541,7 +541,7 @@
>  			unsigned int j;
>  			u32 *src;
>  
> -			src = ((u32 *) per_cpu_ptr(ip_rt_acct, i)) + offset;
> +			src = ((u32 *)per_cpu(ip_rt_acct, i)) + offset;
>  			for (j = 0; j < length/4; j++)
>  				dst[j] += src[j];
>  		}
> @@ -3237,7 +3237,7 @@
>  
>  
>  #ifdef CONFIG_NET_CLS_ROUTE
> -struct ip_rt_acct *ip_rt_acct __read_mostly;
> +DEFINE_PER_CPU(struct ip_rt_acct[256], ip_rt_acct);
>  #endif /* CONFIG_NET_CLS_ROUTE */
>  
>  static __initdata unsigned long rhash_entries;
> @@ -3253,12 +3253,6 @@
>  int __init ip_rt_init(void)
>  {
>  	int rc = 0;
> -
> -#ifdef CONFIG_NET_CLS_ROUTE
> -	ip_rt_acct = __alloc_percpu(256 * sizeof(struct ip_rt_acct));
> -	if (!ip_rt_acct)
> -		panic("IP: failed to allocate ip_rt_acct\n");
> -#endif
>  
>  	ipv4_dst_ops.kmem_cachep =
>  		kmem_cache_create("ip_dst_cache", sizeof(struct rtable), 0,
>  
> ���{.n�+�������+%�����ݶ\x17��w��{.n�+���z�^��\x17��ܨ}���Ơz�&j:+v����\x1e��\x1e�w����2�ޙ���&�)ߡ�a������z��z�ޗ�+��ݢj��w��^[f
> 
> 



  reply	other threads:[~2008-11-17 22:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-17 10:20 [PATCH] net: make ip_rt_acct a normal percpu var Rusty Russell
2008-11-17 22:36 ` Eric Dumazet [this message]
2008-11-18 15:38   ` Rusty Russell
2008-11-19 22:20     ` David Miller
2008-11-19 23:13       ` Rusty Russell
2008-11-19 23:17         ` David Miller
2008-11-20  4:22           ` Rusty Russell
2008-11-19 23:23         ` Eric Dumazet
2008-11-20  0:28           ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4921F1DE.9080305@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).