path: root/include/linux/memory.h
diff options
authorRobert Jennings <>2009-12-17 14:44:38 +0000
committerBenjamin Herrenschmidt <>2009-12-18 14:53:36 +1100
commit925cc71e512a29e2594bcc17dc58d0a0e9c4d524 (patch)
tree7240ccf6ba713cc180d388a28f00c1a43293bc14 /include/linux/memory.h
parent55639353a0035052d9ea6cfe4dde0ac7fcbb2c9f (diff)
mm: Add notifier in pageblock isolation for balloon drivers
Memory balloon drivers can allocate a large amount of memory which is not movable but could be freed to accomodate memory hotplug remove. Prior to calling the memory hotplug notifier chain the memory in the pageblock is isolated. Currently, if the migrate type is not MIGRATE_MOVABLE the isolation will not proceed, causing the memory removal for that page range to fail. Rather than failing pageblock isolation if the migrateteype is not MIGRATE_MOVABLE, this patch checks if all of the pages in the pageblock, and not on the LRU, are owned by a registered balloon driver (or other entity) using a notifier chain. If all of the non-movable pages are owned by a balloon, they can be freed later through the memory notifier chain and the range can still be isolated in set_migratetype_isolate(). Signed-off-by: Robert Jennings <> Cc: Mel Gorman <> Cc: Ingo Molnar <> Cc: Brian King <> Cc: Paul Mackerras <> Cc: Martin Schwidefsky <> Cc: Gerald Schaefer <> Cc: KAMEZAWA Hiroyuki <> Cc: Benjamin Herrenschmidt <> Signed-off-by: Andrew Morton <> Signed-off-by: Benjamin Herrenschmidt <>
Diffstat (limited to 'include/linux/memory.h')
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 37fa19b34ef..1adfe779eb9 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -50,6 +50,19 @@ struct memory_notify {
int status_change_nid;
+ * During pageblock isolation, count the number of pages within the
+ * range [start_pfn, start_pfn + nr_pages) which are owned by code
+ * in the notifier chain.
+ */
+#define MEM_ISOLATE_COUNT (1<<0)
+struct memory_isolate_notify {
+ unsigned long start_pfn; /* Start of range to check */
+ unsigned int nr_pages; /* # pages in range to check */
+ unsigned int pages_found; /* # pages owned found by callbacks */
struct notifier_block;
struct mem_section;
@@ -76,14 +89,28 @@ static inline int memory_notify(unsigned long val, void *v)
return 0;
+static inline int register_memory_isolate_notifier(struct notifier_block *nb)
+ return 0;
+static inline void unregister_memory_isolate_notifier(struct notifier_block *nb)
+static inline int memory_isolate_notify(unsigned long val, void *v)
+ return 0;
extern int register_memory_notifier(struct notifier_block *nb);
extern void unregister_memory_notifier(struct notifier_block *nb);
+extern int register_memory_isolate_notifier(struct notifier_block *nb);
+extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
extern int register_new_memory(int, struct mem_section *);
extern int unregister_memory_section(struct mem_section *);
extern int memory_dev_init(void);
extern int remove_memory_block(unsigned long, struct mem_section *, int);
extern int memory_notify(unsigned long val, void *v);
+extern int memory_isolate_notify(unsigned long val, void *v);
extern struct memory_block *find_memory_block(struct mem_section *);
enum mem_add_context { BOOT, HOTPLUG };