diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2013-04-29 18:08:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:36 -0400 |
commit | f02c696800886382198df897b30bb796b46a8dae (patch) | |
tree | 72155687f3f89bf1f300114cd22f90540396a69c /include/linux/memory.h | |
parent | f9d531b8dcd1b62a7bf96f29212ca80b58f96e82 (diff) |
include/linux/memory.h: implement register_hotmemory_notifier()
When CONFIG_MEMORY_HOTPLUG=n, we don't want the memory-hotplug notifier
handlers to be included in the .o files, for space reasons.
The existing hotplug_memory_notifier() tries to handle this but testing
with gcc-4.4.4 shows that it doesn't work - the hotplug functions are
still present in the .o files.
So implement a new register_hotmemory_notifier() which is a copy of
register_hotcpu_notifier(), and which actually works as desired.
hotplug_memory_notifier() and register_memory_notifier() callsites
should be converted to use this new register_hotmemory_notifier().
While we're there, let's repair the existing hotplug_memory_notifier():
it simply stomps on the register_memory_notifier() return value, so
well-behaved code cannot check for errors. Apparently non of the
existing callers were well-behaved :(
Cc: Andrew Shewmaker <agshew@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/memory.h')
-rw-r--r-- | include/linux/memory.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/linux/memory.h b/include/linux/memory.h index 45e93b468878..0ff6598ee62f 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/node.h> | 18 | #include <linux/node.h> |
19 | #include <linux/compiler.h> | 19 | #include <linux/compiler.h> |
20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
21 | #include <linux/notifier.h> | ||
21 | 22 | ||
22 | #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) | 23 | #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) |
23 | 24 | ||
@@ -127,13 +128,18 @@ enum mem_add_context { BOOT, HOTPLUG }; | |||
127 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 128 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
128 | 129 | ||
129 | #ifdef CONFIG_MEMORY_HOTPLUG | 130 | #ifdef CONFIG_MEMORY_HOTPLUG |
130 | #define hotplug_memory_notifier(fn, pri) { \ | 131 | #define hotplug_memory_notifier(fn, pri) ({ \ |
131 | static __meminitdata struct notifier_block fn##_mem_nb =\ | 132 | static __meminitdata struct notifier_block fn##_mem_nb =\ |
132 | { .notifier_call = fn, .priority = pri }; \ | 133 | { .notifier_call = fn, .priority = pri };\ |
133 | register_memory_notifier(&fn##_mem_nb); \ | 134 | register_memory_notifier(&fn##_mem_nb); \ |
134 | } | 135 | }) |
136 | #define register_hotmemory_notifier(nb) register_memory_notifier(nb) | ||
137 | #define unregister_hotmemory_notifier(nb) unregister_memory_notifier(nb) | ||
135 | #else | 138 | #else |
136 | #define hotplug_memory_notifier(fn, pri) do { } while (0) | 139 | #define hotplug_memory_notifier(fn, pri) (0) |
140 | /* These aren't inline functions due to a GCC bug. */ | ||
141 | #define register_hotmemory_notifier(nb) ({ (void)(nb); 0; }) | ||
142 | #define unregister_hotmemory_notifier(nb) ({ (void)(nb); }) | ||
137 | #endif | 143 | #endif |
138 | 144 | ||
139 | /* | 145 | /* |