net: netdev_kobject_init: annotate with __init
Subsystems (2)
PATCH 1/1 net: netdev_kobject_init: annotate with __init
netdev_kobject_init() is only being called from __init context, that is, net_dev_init(), so annotate it with __init as well, thus the kernel can take this as a hint that the function is used only during the initialization phase and free up used memory resources after its invocation.
--- net/core/net-sysfs.c | 2 +- net/core/net-sysfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/core/net-sysfs.c +1 -1
@@ -1358,7 +1358,7 @@ void netdev_class_remove_file_ns(struct class_attribute *class_attr, }EXPORT_SYMBOL (netdev_class_remove_file_ns); -int netdev_kobject_init (void ) +int __init netdev_kobject_init (void ) {kobj_ns_type_register (&net_ns_type_operations);return class_register (&net_class);
net/core/net-sysfs.h +1 -1
@@ -1,7 +1,7 @@#ifndef __NET_SYSFS_H__#define __NET_SYSFS_H__ -int netdev_kobject_init (void ); +int __init netdev_kobject_init (void );int netdev_register_kobject (struct net_device *);void netdev_unregister_kobject (struct net_device *);int net_rx_queue_update_kobjects (struct net_device *,int old_num,int new_num);
Signature · 1 line
1.7.11.7
From: Daniel Borkmann <[email protected]>
Date: Mon, 6 Jan 2014 01:20:11 +0100
Quoted 7 lines
netdev_kobject_init()is only being called from__initcontext, that is,net_dev_init(), so annotate it with__initas well, thus the kernel can take this as a hint that the function is used only during the initialization phase and free up used memory resources after its invocation.Signed-off-by Daniel Borkmann <[email protected]>
Applied.
Hello.
Quoted 7 lines · Daniel Borkmann
netdev_kobject_init()is only being called from__initcontext, that is,net_dev_init(), so annotate it with__initas well, thus the kernel can take this as a hint that the function is used only during the initialization phase and free up used memory resources after its invocation.Signed-off-by Daniel Borkmann <[email protected]>
[...]
net/core/net-sysfs.h line 4
Quoted 10 lines
net/core/net-sysfs.h +1
-1@@ -1,7 +1,7 @@#ifndef __NET_SYSFS_H__#define __NET_SYSFS_H__ -int netdev_kobject_init (void ); +int __init netdev_kobject_init (void );
There's no need to also annotate function prototype.
WBR, Sergei
Quoted 21 lines · Sergei Shtylyov
Hello.
Quoted 7 lines · Daniel Borkmann
netdev_kobject_init()is only being called from__initcontext, that is,net_dev_init(), so annotate it with__initas well, thus the kernel can take this as a hint that the function is used only during the initialization phase and free up used memory resources after its invocation.Signed-off-by Daniel Borkmann <[email protected]>[...]
Quoted 8 lines
net/core/net-sysfs.h +0
-0@@ -1,7 +1,7 @@#ifndef __NET_SYSFS_H__#define __NET_SYSFS_H__
Quoted 4 lines
net/core/net-sysfs.h line 4
Quoted 2 lines
net/core/net-sysfs.h +1
-1-int netdev_kobject_init (void ); +int __init netdev_kobject_init (void );There's no need to also annotate function prototype.
Hm, is that general convention? Having this in a header file annotated (even if not strictly necessary) would probably better prevent from possible misuse resp. section mismatches if people forget to look into the actual c file where the function is being defined.
Quoted 2 lines
WBR, Sergei
Quoted 17 lines · Daniel Borkmann
Quoted 17 lines
Quoted 7 lines
netdev_kobject_init()is only being called from__initcontext, that is,net_dev_init(), so annotate it with__initas well, thus the kernel can take this as a hint that the function is used only during the initialization phase and free up used memory resources after its invocation.Signed-off-by Daniel Borkmann <[email protected]>[...]
Quoted 8 lines
net/core/net-sysfs.h +0
-0@@ -1,7 +1,7 @@#ifndef __NET_SYSFS_H__#define __NET_SYSFS_H__
Quoted 6 lines
Quoted 4 lines
net/core/net-sysfs.h line 4
Quoted 2 lines
net/core/net-sysfs.h +1
-1-int netdev_kobject_init (void ); +int __init netdev_kobject_init (void );There's no need to also annotate function prototype.
Hm, is that general convention?
More or less, though I've seen some prototypes annotated.
Quoted 5 lines
Having this in a header file
annotated (even if not strictly necessary) would probably better prevent from possible misuse resp. section mismatches if people forget to look into the actual c file where the function is being defined.
Dunno about vi users, I'm using Alt-. in EMACS when I want to find a
function, and it gets me right to the definition, not the prototype.
Quoted 1 line
Quoted 1 line
WBR, Sergei
PS: The patch was merged already, so my comment seems to have been posted too late anyway.
WBR, Sergei