netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: netdev_kobject_init: annotate with __init
@ 2014-01-06  0:20 Daniel Borkmann
  2014-01-06  1:28 ` David Miller
  2014-01-06 15:13 ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Borkmann @ 2014-01-06  0:20 UTC (permalink / raw)
  To: davem; +Cc: netdev

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.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
 net/core/net-sysfs.c | 2 +-
 net/core/net-sysfs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 1a7b7b1..49843bf 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -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);
diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
index bd7751e..2745a1b 100644
--- a/net/core/net-sysfs.h
+++ b/net/core/net-sysfs.h
@@ -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);
-- 
1.7.11.7

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

* Re: [PATCH net-next] net: netdev_kobject_init: annotate with __init
  2014-01-06  0:20 [PATCH net-next] net: netdev_kobject_init: annotate with __init Daniel Borkmann
@ 2014-01-06  1:28 ` David Miller
  2014-01-06 15:13 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-01-06  1:28 UTC (permalink / raw)
  To: dborkman; +Cc: netdev

From: Daniel Borkmann <dborkman@redhat.com>
Date: Mon,  6 Jan 2014 01:20:11 +0100

> 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.
> 
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>

Applied.

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

* Re: [PATCH net-next] net: netdev_kobject_init: annotate with __init
  2014-01-06  0:20 [PATCH net-next] net: netdev_kobject_init: annotate with __init Daniel Borkmann
  2014-01-06  1:28 ` David Miller
@ 2014-01-06 15:13 ` Sergei Shtylyov
  2014-01-06 16:18   ` Daniel Borkmann
  1 sibling, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2014-01-06 15:13 UTC (permalink / raw)
  To: Daniel Borkmann, davem; +Cc: netdev

Hello.

On 06-01-2014 4:20, Daniel Borkmann wrote:

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

> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
[...]

> diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
> index bd7751e..2745a1b 100644
> --- a/net/core/net-sysfs.h
> +++ b/net/core/net-sysfs.h
> @@ -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

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

* Re: [PATCH net-next] net: netdev_kobject_init: annotate with __init
  2014-01-06 15:13 ` Sergei Shtylyov
@ 2014-01-06 16:18   ` Daniel Borkmann
  2014-01-06 17:13     ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2014-01-06 16:18 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: davem, netdev

On 01/06/2014 04:13 PM, Sergei Shtylyov wrote:
> Hello.
>
> On 06-01-2014 4:20, Daniel Borkmann wrote:
>
>> 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.
>
>> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> [...]
>
>> diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
>> index bd7751e..2745a1b 100644
>> --- a/net/core/net-sysfs.h
>> +++ b/net/core/net-sysfs.h
>> @@ -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.

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.

> WBR, Sergei
>

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

* Re: [PATCH net-next] net: netdev_kobject_init: annotate with __init
  2014-01-06 16:18   ` Daniel Borkmann
@ 2014-01-06 17:13     ` Sergei Shtylyov
  0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2014-01-06 17:13 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, netdev

On 06.01.2014 20:18, Daniel Borkmann wrote:

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

>>> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
>> [...]

>>> diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
>>> index bd7751e..2745a1b 100644
>>> --- a/net/core/net-sysfs.h
>>> +++ b/net/core/net-sysfs.h
>>> @@ -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.

> Hm, is that general convention?

    More or less, though I've seen some prototypes annotated.

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

>> WBR, Sergei

PS: The patch was merged already, so my comment seems to have been posted too 
late anyway.

WBR, Sergei

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

end of thread, other threads:[~2014-01-06 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-06  0:20 [PATCH net-next] net: netdev_kobject_init: annotate with __init Daniel Borkmann
2014-01-06  1:28 ` David Miller
2014-01-06 15:13 ` Sergei Shtylyov
2014-01-06 16:18   ` Daniel Borkmann
2014-01-06 17:13     ` Sergei Shtylyov

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