The patch titled Subject: mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 has been added to the -mm tree. Its filename is mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Arun KS <arunks@xxxxxxxxxxxxxx> Subject: mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 Link: http://lkml.kernel.org/r/1547098543-26452-1-git-send-email-arunks@xxxxxxxxxxxxxx Signed-off-by: Arun KS <arunks@xxxxxxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Reviewed-by: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/drivers/hv/hv_balloon.c~mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 +++ a/drivers/hv/hv_balloon.c @@ -771,7 +771,7 @@ static void hv_mem_hot_add(unsigned long } } -static int hv_online_page(struct page *pg, unsigned int order) +static void hv_online_page(struct page *pg, unsigned int order) { struct hv_hotadd_state *has; unsigned long flags; @@ -787,8 +787,6 @@ static int hv_online_page(struct page *p break; } spin_unlock_irqrestore(&dm_device.ha_lock, flags); - - return 0; } static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) --- a/drivers/xen/balloon.c~mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 +++ a/drivers/xen/balloon.c @@ -345,7 +345,7 @@ static enum bp_state reserve_additional_ /* * add_memory_resource() will call online_pages() which in its turn - * will call xen_online_pages() callback causing deadlock if we don't + * will call xen_online_page() callback causing deadlock if we don't * release balloon_mutex here. Unlocking here is safe because the * callers drop the mutex before trying again. */ @@ -369,10 +369,10 @@ static enum bp_state reserve_additional_ return BP_ECANCELED; } -static int xen_online_pages(struct page *pg, unsigned int order) +static void xen_online_page(struct page *page, unsigned int order) { unsigned long i, size = (1 << order); - unsigned long start_pfn = page_to_pfn(pg); + unsigned long start_pfn = page_to_pfn(page); struct page *p; pr_debug("Online %lu pages starting at pfn 0x%lx\n", size, start_pfn); @@ -383,8 +383,6 @@ static int xen_online_pages(struct page __balloon_append(p); } mutex_unlock(&balloon_mutex); - - return 0; } static int xen_memory_notifier(struct notifier_block *nb, unsigned long val, void *v) @@ -709,7 +707,7 @@ static int __init balloon_init(void) balloon_stats.max_retry_count = RETRY_UNLIMITED; #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG - set_online_page_callback(&xen_online_pages); + set_online_page_callback(&xen_online_page); register_memory_notifier(&xen_memory_nb); register_sysctl_table(xen_root); #endif --- a/include/linux/memory_hotplug.h~mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 +++ a/include/linux/memory_hotplug.h @@ -87,7 +87,7 @@ extern int test_pages_in_a_zone(unsigned unsigned long *valid_start, unsigned long *valid_end); extern void __offline_isolated_pages(unsigned long, unsigned long); -typedef int (*online_page_callback_t)(struct page *page, unsigned int order); +typedef void (*online_page_callback_t)(struct page *page, unsigned int order); extern int set_online_page_callback(online_page_callback_t callback); extern int restore_online_page_callback(online_page_callback_t callback); --- a/mm/memory_hotplug.c~mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9 +++ a/mm/memory_hotplug.c @@ -47,7 +47,7 @@ * and restore_online_page_callback() for generic callback restore. */ -static int generic_online_page(struct page *page, unsigned int order); +static void generic_online_page(struct page *page, unsigned int order); static online_page_callback_t online_page_callback = generic_online_page; static DEFINE_MUTEX(online_page_callback_lock); @@ -656,7 +656,7 @@ void __online_page_free(struct page *pag } EXPORT_SYMBOL_GPL(__online_page_free); -static int generic_online_page(struct page *page, unsigned int order) +static void generic_online_page(struct page *page, unsigned int order) { __free_pages_core(page, order); totalram_pages_add(1UL << order); @@ -664,7 +664,6 @@ static int generic_online_page(struct pa if (PageHighMem(page)) totalhigh_pages_add(1UL << order); #endif - return 0; } static int online_pages_blocks(unsigned long start, unsigned long nr_pages) @@ -675,20 +674,9 @@ static int online_pages_blocks(unsigned while (start < end) { order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end) - PFN_PHYS(start))); + (*online_page_callback)(pfn_to_page(start), order); - /* - * External callback providers can deny onlining pages. So check - * for return value. - * zero : if all pages are onlined. - * positive : if only few pages are onlined. - * negative : if none of the pages are onlined. - */ - ret = (*online_page_callback)(pfn_to_page(start), order); - if (!ret) - onlined_pages += (1UL << order); - else if (ret > 0) - onlined_pages += ret; - + onlined_pages += (1UL << order); start += (1UL << order); } return onlined_pages; @@ -700,11 +688,11 @@ static int online_pages_range(unsigned l unsigned long onlined_pages = *(unsigned long *)arg; if (PageReserved(pfn_to_page(start_pfn))) - onlined_pages = online_pages_blocks(start_pfn, nr_pages); + onlined_pages += online_pages_blocks(start_pfn, nr_pages); online_mem_sections(start_pfn, start_pfn + nr_pages); - *(unsigned long *)arg += onlined_pages; + *(unsigned long *)arg = onlined_pages; return 0; } _ Patches currently in -mm which might be from arunks@xxxxxxxxxxxxxx are memory_hotplug-free-pages-as-higher-order.patch mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v8.patch mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v9.patch