mm: add notifier in pageblock isolation for balloon drivers
Subsystems (5)
[email protected]
maintainerPATCH 2/3 mm: add notifier in pageblock isolation for balloon drivers
From: Robert Jennings <[email protected]>
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().
---
drivers/base/memory.c | 19 +++++++++++++ include/linux/memory.h | 27 ++++++++++++++++++ mm/page_alloc.c | 57 ++++++++++++++++++++++++++++++++++----- 3 files changed, 96 insertions(+), 7 deletions(-)
drivers/base/memory.c renamed from drivers/base/memory.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers +19 -0
@@ -63,6 +63,20 @@ void unregister_memory_notifier(struct n }EXPORT_SYMBOL (unregister_memory_notifier); +static ATOMIC_NOTIFIER_HEAD (memory_isolate_chain); + +int register_memory_isolate_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&memory_isolate_chain, nb); +} +EXPORT_SYMBOL (register_memory_isolate_notifier); + +void unregister_memory_isolate_notifier (struct notifier_block *nb) +{ +atomic_notifier_chain_unregister (&memory_isolate_chain, nb); +} +EXPORT_SYMBOL (unregister_memory_isolate_notifier); +/* * register_memory - Setup a sysfs device for a memory block */
@@ -157,6 +171,11 @@ int memory_notify(unsigned long val, voireturn blocking_notifier_call_chain (&memory_chain, val, v); } +int memory_isolate_notify (unsigned long val,void *v) +{ +return atomic_notifier_call_chain (&memory_isolate_chain, val, v); +} +/* * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is * OK to have direct references to sparsemem variables in here.
include/linux/memory.h renamed from include/linux/memory.h~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers +27 -0
@@ -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 {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 ; +}#else 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 *);#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)enum mem_add_context {BOOT ,HOTPLUG };
mm/page_alloc.c renamed from mm/page_alloc.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers +50 -7
79 lines not on this page · raw message
_