2009-12-24 03:05:50

by Rakib Mullick

[permalink] [raw]
Subject: [PATCH] hugetlb: Fix section mismatch warning in hugetlb.c

The patch titled hugetlb-add-per-node-hstate-attributes.patch introduces
the following section mismatch warning, due to a reference form non-init
function hugetlb_register_node to a init function hugetlb_sysfs_add_hstate.

LD mm/built-in.o
WARNING: mm/built-in.o(.text+0x5396d): Section mismatch in reference
from the function hugetlb_register_node() to the function
.init.text:hugetlb_sysfs_add_hstate()
The function hugetlb_register_node() references
the function __init hugetlb_sysfs_add_hstate().
This is often because hugetlb_register_node lacks a __init
annotation or the annotation of hugetlb_sysfs_add_hstate is wrong.

---
Signed-off-by: Rakib Mullick <[email protected]>

--- linus/mm/hugetlb.c 2009-12-18 15:52:35.000000000 +0600
+++ rakib/mm/hugetlb.c 2009-12-23 20:37:16.000000000 +0600
@@ -1515,7 +1515,7 @@ static struct attribute_group hstate_att
.attrs = hstate_attrs,
};

-static int __init hugetlb_sysfs_add_hstate(struct hstate *h,
+static int hugetlb_sysfs_add_hstate(struct hstate *h,
struct kobject *parent,
struct kobject **hstate_kobjs,
struct attribute_group *hstate_attr_group)


2009-12-30 23:30:08

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: Fix section mismatch warning in hugetlb.c

On Thu, 24 Dec 2009 09:05:48 +0600
Rakib Mullick <[email protected]> wrote:

> The patch titled hugetlb-add-per-node-hstate-attributes.patch introduces
> the following section mismatch warning, due to a reference form non-init
> function hugetlb_register_node to a init function hugetlb_sysfs_add_hstate.
>
> LD mm/built-in.o
> WARNING: mm/built-in.o(.text+0x5396d): Section mismatch in reference
> from the function hugetlb_register_node() to the function
> .init.text:hugetlb_sysfs_add_hstate()
> The function hugetlb_register_node() references
> the function __init hugetlb_sysfs_add_hstate().
> This is often because hugetlb_register_node lacks a __init
> annotation or the annotation of hugetlb_sysfs_add_hstate is wrong.
>
> ---
> Signed-off-by: Rakib Mullick <[email protected]>
>
> --- linus/mm/hugetlb.c 2009-12-18 15:52:35.000000000 +0600
> +++ rakib/mm/hugetlb.c 2009-12-23 20:37:16.000000000 +0600
> @@ -1515,7 +1515,7 @@ static struct attribute_group hstate_att
> .attrs = hstate_attrs,
> };
>
> -static int __init hugetlb_sysfs_add_hstate(struct hstate *h,
> +static int hugetlb_sysfs_add_hstate(struct hstate *h,
> struct kobject *parent,
> struct kobject **hstate_kobjs,
> struct attribute_group *hstate_attr_group)

I would be better to fix it the other way. AFACIT,
hugetlb_register_node() and both versions of
hugetlb_register_all_nodes() should be marked __init.

2010-01-01 14:52:20

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: Fix section mismatch warning in hugetlb.c

On 12/31/09, Andrew Morton <[email protected]> wrote:
>
> I would be better to fix it the other way. AFACIT,
> hugetlb_register_node() and both versions of
> hugetlb_register_all_nodes() should be marked __init.
>

Okay. Thanks for suggestion.
-----

Since hugetlb_sysfs_add_hstate()'s ancestor function is from __init
and isn't referencing from any other function, so we can do it.


Signed-off-by: Rakib Mullick <[email protected]>
---

--- linus/mm/hugetlb.c 2010-01-01 20:31:10.000000000 +0600
+++ rakib/mm/hugetlb.c 2010-01-01 20:26:58.000000000 +0600
@@ -1650,7 +1650,7 @@ static void hugetlb_unregister_all_nodes
* Register hstate attributes for a single node sysdev.
* No-op if attributes already registered.
*/
-void hugetlb_register_node(struct node *node)
+void __init hugetlb_register_node(struct node *node)
{
struct hstate *h;
struct node_hstate *nhs = &node_hstates[node->sysdev.id];
@@ -1683,7 +1683,7 @@ void hugetlb_register_node(struct node *
* sysdevs of nodes that have memory. All on-line nodes should have
* registered their associated sysdev by this time.
*/
-static void hugetlb_register_all_nodes(void)
+static void __init hugetlb_register_all_nodes(void)
{
int nid;

@@ -1712,7 +1712,7 @@ static struct hstate *kobj_to_node_hstat

static void hugetlb_unregister_all_nodes(void) { }

-static void hugetlb_register_all_nodes(void) { }
+static void __init hugetlb_register_all_nodes(void) { }

#endif