Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: cleanup to make remove_memory() arch-neutral

There is nothing architecture specific about remove_memory().
remove_memory() function is common for all architectures which support
hotplug memory remove. Instead of duplicating it in every architecture,
collapse them into arch neutral function.

[akpm@linux-foundation.org: fix the export]
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Gary Hade <garyhade@us.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Badari Pulavarty and committed by
Linus Torvalds
71088785 8433ac61

+11 -46
-17
arch/ia64/mm/init.c
··· 700 700 701 701 return ret; 702 702 } 703 - #ifdef CONFIG_MEMORY_HOTREMOVE 704 - int remove_memory(u64 start, u64 size) 705 - { 706 - unsigned long start_pfn, end_pfn; 707 - unsigned long timeout = 120 * HZ; 708 - int ret; 709 - start_pfn = start >> PAGE_SHIFT; 710 - end_pfn = start_pfn + (size >> PAGE_SHIFT); 711 - ret = offline_pages(start_pfn, end_pfn, timeout); 712 - if (ret) 713 - goto out; 714 - /* we can free mem_map at this point */ 715 - out: 716 - return ret; 717 - } 718 - EXPORT_SYMBOL_GPL(remove_memory); 719 - #endif /* CONFIG_MEMORY_HOTREMOVE */ 720 703 #endif 721 704 722 705 /*
-17
arch/powerpc/mm/mem.c
··· 134 134 135 135 return __add_pages(zone, start_pfn, nr_pages); 136 136 } 137 - 138 - #ifdef CONFIG_MEMORY_HOTREMOVE 139 - int remove_memory(u64 start, u64 size) 140 - { 141 - unsigned long start_pfn, end_pfn; 142 - int ret; 143 - 144 - start_pfn = start >> PAGE_SHIFT; 145 - end_pfn = start_pfn + (size >> PAGE_SHIFT); 146 - ret = offline_pages(start_pfn, end_pfn, 120 * HZ); 147 - if (ret) 148 - goto out; 149 - /* Arch-specific calls go here - next patch */ 150 - out: 151 - return ret; 152 - } 153 - #endif /* CONFIG_MEMORY_HOTREMOVE */ 154 137 #endif /* CONFIG_MEMORY_HOTPLUG */ 155 138 156 139 /*
-11
arch/s390/mm/init.c
··· 189 189 return rc; 190 190 } 191 191 #endif /* CONFIG_MEMORY_HOTPLUG */ 192 - 193 - #ifdef CONFIG_MEMORY_HOTREMOVE 194 - int remove_memory(u64 start, u64 size) 195 - { 196 - unsigned long start_pfn, end_pfn; 197 - 198 - start_pfn = PFN_DOWN(start); 199 - end_pfn = start_pfn + PFN_DOWN(size); 200 - return offline_pages(start_pfn, end_pfn, 120 * HZ); 201 - } 202 - #endif /* CONFIG_MEMORY_HOTREMOVE */
+11 -1
mm/memory_hotplug.c
··· 26 26 #include <linux/delay.h> 27 27 #include <linux/migrate.h> 28 28 #include <linux/page-isolation.h> 29 + #include <linux/pfn.h> 29 30 30 31 #include <asm/tlbflush.h> 31 32 ··· 850 849 851 850 return ret; 852 851 } 852 + 853 + int remove_memory(u64 start, u64 size) 854 + { 855 + unsigned long start_pfn, end_pfn; 856 + 857 + start_pfn = PFN_DOWN(start); 858 + end_pfn = start_pfn + PFN_DOWN(size); 859 + return offline_pages(start_pfn, end_pfn, 120 * HZ); 860 + } 853 861 #else 854 862 int remove_memory(u64 start, u64 size) 855 863 { 856 864 return -EINVAL; 857 865 } 858 - EXPORT_SYMBOL_GPL(remove_memory); 859 866 #endif /* CONFIG_MEMORY_HOTREMOVE */ 867 + EXPORT_SYMBOL_GPL(remove_memory);