Skip to contentSkip to conversation

numa: Mark __node_set as __always_inline

PATCH In review Tom Rini 3 participants 3 messages Jul 25, 2013 – Jul 26, 2013 Bitmap API

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH v2 1/1 numa: Mark __node_set as __always_inline

It is posible for some compilers to decide that __node_set does not need to be made turned into an inline function. When the compiler does this on an __init function calling it on __initdata we get a section mismatch warning now. Use __always_inline to ensure that we will be inlined.

Cc Jianpeng Ma <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Lai Jiangshan <[email protected]>
Cc Yasuaki Ishimatsu <[email protected]>
Cc Wen Congyang <[email protected]>
Cc Jiang Liu <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Mel Gorman <[email protected]>
Cc David Rientjes <[email protected]>
Cc Yinghai Lu <[email protected]>
Cc Greg KH <[email protected]>

---
Changes in v2:
- As per KOSAKI Motohiro, add a comment as well about why we need __always_inline to the header.

---
 include/linux/nodemask.h |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
include/linux/nodemask.h +10 -1
index 4e2cbfa..58b9a02 100644
@@ -98,8 +98,17 @@
 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
 extern nodemask_t _unused_nodemask_arg_;
 
+/*
+ * The inline keyword gives the compiler room to decide to inline, or
+ * not inline a function as it sees best.  However, as these functions
+ * are called in both __init and non-__init functions, if they are not
+ * inlined we will end up with a section mis-match error (of the type of
+ * freeable items not being freed).  So we must use __always_inline here
+ * to fix the problem.  If other functions in the future also end up in
+ * this situation they will also need to be annotated as __always_inline
+ */
 #define node_set(node, dst) __node_set((node), &(dst))
-static inline void __node_set(int node, volatile nodemask_t *dstp)
+static __always_inline void __node_set(int node, volatile nodemask_t *dstp)
 {
 	set_bit(node, dstp->bits);
 }
Signature · 1 line
1.7.9.5
Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines
include/linux/nodemask.h +5 -0
+/*
+ * The inline keyword gives the compiler room to decide to inline, or
+ * not inline a function as it sees best.  However, as these functions
+ * are called in both __init and non-__init functions, if they are not
+ * inlined we will end up with a section mis-match error (of the type of

include/linux/nodemask.h line 114

Quoted 10 lines
include/linux/nodemask.h +5 -1
+ * freeable items not being freed).  So we must use __always_inline here
+ * to fix the problem.  If other functions in the future also end up in
+ * this situation they will also need to be annotated as __always_inline
+ */
  #define node_set(node, dst) __node_set((node), &(dst))
-static inline void __node_set(int node, volatile nodemask_t *dstp)
+static __always_inline void __node_set(int node, volatile nodemask_t *dstp)
  {
  	set_bit(node, dstp->bits);
  }
#2 lore raw

[tip:sched/core] numa: Mark __node_set() as __always_inline

In reply to Tom Rini
numa: Mark __node_set() as __always_inline
Commit-ID:  323f54ed0f3ce20e9946c961fc928ccdb80d9345
Gitweb:     http://git.kernel.org/tip/323f54ed0f3ce20e9946c961fc928ccdb80d9345
Author:     Tom Rini <[email protected]>
AuthorDate: Thu, 25 Jul 2013 14:26:10 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 25 Jul 2013 21:54:01 +0200

numa: Mark __node_set() as __always_inline

It is posible for some compilers to decide that __node_set() does not need to be made turned into an inline function. When the compiler does this on an __init function calling it on __initdata we get a section mismatch warning now. Use __always_inline to ensure that we will be inlined.

Cc Jianpeng Ma <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Lai Jiangshan <[email protected]>
Cc Yasuaki Ishimatsu <[email protected]>
Cc Wen Congyang <[email protected]>
Cc Jiang Liu <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Mel Gorman <[email protected]>
Cc David Rientjes <[email protected]>
Cc Yinghai Lu <[email protected]>
Cc Greg KH <[email protected]>
---
 include/linux/nodemask.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
include/linux/nodemask.h +10 -1
index 4e2cbfa..58b9a02 100644
@@ -98,8 +98,17 @@
 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
 extern nodemask_t _unused_nodemask_arg_;
 
+/*
+ * The inline keyword gives the compiler room to decide to inline, or
+ * not inline a function as it sees best.  However, as these functions
+ * are called in both __init and non-__init functions, if they are not
+ * inlined we will end up with a section mis-match error (of the type of
+ * freeable items not being freed).  So we must use __always_inline here
+ * to fix the problem.  If other functions in the future also end up in
+ * this situation they will also need to be annotated as __always_inline
+ */
 #define node_set(node, dst) __node_set((node), &(dst))
-static inline void __node_set(int node, volatile nodemask_t *dstp)
+static __always_inline void __node_set(int node, volatile nodemask_t *dstp)
 {
 	set_bit(node, dstp->bits);
 }