netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: unix: make some variables constant
@ 2010-10-19  5:24 Changli Gao
  2010-10-19  5:47 ` Eric Dumazet
  2010-10-19  6:03 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Changli Gao @ 2010-10-19  5:24 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Changli Gao

And since ctl_table.data is initialized later, we don't need to initialize
the data member of the template variable unix_table.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 net/unix/sysctl_net_unix.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
index 397cffe..1114ccc 100644
--- a/net/unix/sysctl_net_unix.c
+++ b/net/unix/sysctl_net_unix.c
@@ -15,10 +15,9 @@
 
 #include <net/af_unix.h>
 
-static ctl_table unix_table[] = {
+const static ctl_table unix_table[] = {
 	{
 		.procname	= "max_dgram_qlen",
-		.data		= &init_net.unx.sysctl_max_dgram_qlen,
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec
@@ -26,7 +25,7 @@ static ctl_table unix_table[] = {
 	{ }
 };
 
-static struct ctl_path unix_path[] = {
+const static struct ctl_path unix_path[] = {
 	{ .procname = "net", },
 	{ .procname = "unix", },
 	{ },

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: unix: make some variables constant
  2010-10-19  5:24 [PATCH] net: unix: make some variables constant Changli Gao
@ 2010-10-19  5:47 ` Eric Dumazet
  2010-10-19  6:03   ` Changli Gao
  2010-10-19  6:03 ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-10-19  5:47 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, netdev

Le mardi 19 octobre 2010 à 13:24 +0800, Changli Gao a écrit :
> And since ctl_table.data is initialized later, we don't need to initialize
> the data member of the template variable unix_table.
> 

The init cost is nothing, since its a data blob that must be there
anyway.

We could even avoid the kmemdup() if CONFIG_NET_NS is not set





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: unix: make some variables constant
  2010-10-19  5:24 [PATCH] net: unix: make some variables constant Changli Gao
  2010-10-19  5:47 ` Eric Dumazet
@ 2010-10-19  6:03 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2010-10-19  6:03 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, netdev

On Tue, 19 Oct 2010 13:24:02 +0800
Changli Gao <xiaosuo@gmail.com> wrote:

> And since ctl_table.data is initialized later, we don't need to initialize
> the data member of the template variable unix_table.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
>  net/unix/sysctl_net_unix.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
> index 397cffe..1114ccc 100644
> --- a/net/unix/sysctl_net_unix.c
> +++ b/net/unix/sysctl_net_unix.c
> @@ -15,10 +15,9 @@
>  
>  #include <net/af_unix.h>
>  
> -static ctl_table unix_table[] = {
> +const static ctl_table unix_table[] = {

Typical convention is "static const" rather than "const static"

git grep 'const static' | wc -l  => 5
git grep 'static const' | wc -l  => 18589

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: unix: make some variables constant
  2010-10-19  5:47 ` Eric Dumazet
@ 2010-10-19  6:03   ` Changli Gao
  0 siblings, 0 replies; 4+ messages in thread
From: Changli Gao @ 2010-10-19  6:03 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, netdev

On Tue, Oct 19, 2010 at 1:47 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mardi 19 octobre 2010 à 13:24 +0800, Changli Gao a écrit :
>> And since ctl_table.data is initialized later, we don't need to initialize
>> the data member of the template variable unix_table.
>>
>
> The init cost is nothing, since its a data blob that must be there
> anyway.

Yes. I have tried to avoid global variable unix_table and unix_path,
then I got a bigger kernel image, so I gave it up.

>
> We could even avoid the kmemdup() if CONFIG_NET_NS is not set
>
>

It is a good idea. We can check if the NS is init_net before kmalloc and kfree.

I'll send a update patch later. Thanks.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-19  6:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-19  5:24 [PATCH] net: unix: make some variables constant Changli Gao
2010-10-19  5:47 ` Eric Dumazet
2010-10-19  6:03   ` Changli Gao
2010-10-19  6:03 ` Stephen Hemminger

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).