diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-08 23:38:39 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:54:58 -0400 |
commit | 4665079cbb2a3e17de82f2ab2940b9f97f37d65e (patch) | |
tree | 8e51e9b9e6155eaeccf28783620a07b20a067d8d /fs/proc/proc_net.c | |
parent | d62a38d1ab350f787e4941e42a3d3e97971e38f5 (diff) |
[NETNS]: Move some code into __init section when CONFIG_NET_NS=n
With the net namespaces many code leaved the __init section,
thus making the kernel occupy more memory than it did before.
Since we have a config option that prohibits the namespace
creation, the functions that initialize/finalize some netns
stuff are simply not needed and can be freed after the boot.
Currently, this is almost not noticeable, since few calls
are no longer in __init, but when the namespaces will be
merged it will be possible to free more code. I propose to
use the __net_init, __net_exit and __net_initdata "attributes"
for functions/variables that are not used if the CONFIG_NET_NS
is not set to save more space in memory.
The exiting functions cannot just reside in the __exit section,
as noticed by David, since the init section will have
references on it and the compilation will fail due to modpost
checks. These references can exist, since the init namespace
never dies and the exit callbacks are never called. So I
introduce the __exit_refok attribute just like it is already
done with the __init_refok.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs/proc/proc_net.c')
-rw-r--r-- | fs/proc/proc_net.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 85cc8e8bb862..2e91fb756e9a 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -140,7 +140,7 @@ static struct inode_operations proc_net_dir_inode_operations = { | |||
140 | .setattr = proc_net_setattr, | 140 | .setattr = proc_net_setattr, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | static int proc_net_ns_init(struct net *net) | 143 | static __net_init int proc_net_ns_init(struct net *net) |
144 | { | 144 | { |
145 | struct proc_dir_entry *root, *netd, *net_statd; | 145 | struct proc_dir_entry *root, *netd, *net_statd; |
146 | int err; | 146 | int err; |
@@ -178,19 +178,19 @@ free_root: | |||
178 | goto out; | 178 | goto out; |
179 | } | 179 | } |
180 | 180 | ||
181 | static void proc_net_ns_exit(struct net *net) | 181 | static __net_exit void proc_net_ns_exit(struct net *net) |
182 | { | 182 | { |
183 | remove_proc_entry("stat", net->proc_net); | 183 | remove_proc_entry("stat", net->proc_net); |
184 | remove_proc_entry("net", net->proc_net_root); | 184 | remove_proc_entry("net", net->proc_net_root); |
185 | kfree(net->proc_net_root); | 185 | kfree(net->proc_net_root); |
186 | } | 186 | } |
187 | 187 | ||
188 | struct pernet_operations proc_net_ns_ops = { | 188 | struct pernet_operations __net_initdata proc_net_ns_ops = { |
189 | .init = proc_net_ns_init, | 189 | .init = proc_net_ns_init, |
190 | .exit = proc_net_ns_exit, | 190 | .exit = proc_net_ns_exit, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | int proc_net_init(void) | 193 | int __init proc_net_init(void) |
194 | { | 194 | { |
195 | proc_net_shadow = proc_mkdir("net", NULL); | 195 | proc_net_shadow = proc_mkdir("net", NULL); |
196 | proc_net_shadow->proc_iops = &proc_net_dir_inode_operations; | 196 | proc_net_shadow->proc_iops = &proc_net_dir_inode_operations; |