memory-hotplug: hot-remove physical memory
Subsystems (12)
v3 cover memory-hotplug: hot-remove physical memory
The patch-set was divided from following thread's patch-set.
https://lkml.org/lkml/2012/9/5/201
The last version of this patchset:
https://lkml.org/lkml/2012/10/23/213
If you want to know the reason, please read following thread.
https://lkml.org/lkml/2012/10/2/83
The patch-set has only the function of kernel core side for physical memory hot remove. So if you use the patch, please apply following patches.
- bug fix for memory hot remove
https://lkml.org/lkml/2012/10/31/269
- acpi framework
https://lkml.org/lkml/2012/10/26/175
The patches can free/remove the following things:
- /sys/firmware/memmap/X/{end, start, type} : [PATCH 2/10]
- mem_section and related sysfs files : [PATCH 3-4/10] - memmap of sparse-vmemmap : [PATCH 5-7/10] - page table of removed memory : [RFC PATCH 8/10] - node and related sysfs files : [RFC PATCH 9-10/10]
* [PATCH 2/10] checks whether the memory can be removed or not.
If you find lack of function for physical memory hot-remove, please let me know.
How to test this patchset?
1. apply this patchset and build the kernel. MEMORY_HOTPLUG, MEMORY_HOTREMOVE, ACPI_HOTPLUG_MEMORY must be selected.
2. load the module acpi_memhotplug
3. hotplug the memory device(it depends on your hardware)
You will see the memory device under the directory /sys/bus/acpi/devices/. Its name is PNP0C80:XX.
4. online/offline pages provided by this memory device
You can write online/offline to /sys/devices/system/memory/memoryX/state to online/offline pages provided by this memory device
5. hotremove the memory device
You can hotremove the memory device by the hardware, or writing 1 to /sys/bus/acpi/devices/PNP0C80:XX/eject.
Note: if the memory provided by the memory device is used by the kernel, it can't be offlined. It is not a bug.
Known problems:
1. hotremoving memory device may cause kernel panicked This bug will be fixed by Liu Jiang's patch:
https://lkml.org/lkml/2012/7/3/1
Changelogs from v2 to v3:
Patch9: call sync_global_pgds() if pgd is changed
Patch10: fix a problem int the patch
Changelogs from v1 to v2:
Patch1: new patch, offline memory twice. 1st iterate: offline every non primary
memory block. 2nd iterate: offline primary (i.e. first added) memory block.
Patch3: new patch, no logical change, just remove reduntant codes.
Patch9: merge the patch from wujianguo into this patch. flush tlb on all cpu
after the pagetable is changed.
Patch12: new patch, free node_data when a node is offlined
Wen Congyang (6):
memory-hotplug: try to offline the memory twice to avoid dependence
memory-hotplug: remove redundant codes
memory-hotplug: introduce new function arch_remove_memory() for
removing page table depends on architecture
memory-hotplug: remove page table of x86_64 architecture
memory-hotplug: remove sysfs file of node
memory-hotplug: free node_data when a node is offlined
Yasuaki Ishimatsu (6):
memory-hotplug: check whether all memory blocks are offlined or not
when removing memory
memory-hotplug: remove /sys/firmware/memmap/X sysfs
memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
memory-hotplug: implement register_page_bootmem_info_section of
sparse-vmemmap
memory-hotplug: remove memmap of sparse-vmemmap
memory-hotplug: memory_hotplug: clear zone when removing the memory
arch/ia64/mm/discontig.c | 14 ++ arch/ia64/mm/init.c | 18 ++ arch/powerpc/mm/init_64.c | 14 ++ arch/powerpc/mm/mem.c | 12 + arch/s390/mm/init.c | 12 + arch/s390/mm/vmem.c | 14 ++ arch/sh/mm/init.c | 17 ++ arch/sparc/mm/init_64.c | 14 ++ arch/tile/mm/init.c | 8 + arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/init_32.c | 12 + arch/x86/mm/init_64.c | 417 +++++++++++++++++++++++++++++++++++ arch/x86/mm/pageattr.c | 47 ++-- drivers/acpi/acpi_memhotplug.c | 8 +- drivers/base/memory.c | 6 + drivers/firmware/memmap.c | 98 +++++++- include/linux/firmware-map.h | 6 + include/linux/memory_hotplug.h | 15 +- include/linux/mm.h | 5 +- mm/memory_hotplug.c | 409 ++++++++++++++++++++++++++++++++-- mm/sparse.c | 5 +- 21 files changed, 1095 insertions(+), 57 deletions(-)
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 1/12 memory-hotplug: try to offline the memory twice to avoid dependence
memory can't be offlined when CONFIG_MEMCG is selected.
For example: there is a memory device on node 1. The address range is [1G, 1.5G). You will find 4 new directories memory8, memory9, memory10, and memory11 under the directory /sys/devices/system/memory/.
If CONFIG_MEMCG is selected, we will allocate memory to store page cgroup when we online pages. When we online memory8, the memory stored page cgroup is not provided by this memory device. But when we online memory9, the memory stored page cgroup may be provided by memory8. So we can't offline memory8 now. We should offline the memory in the reversed order.
When the memory device is hotremoved, we will auto offline memory provided by this memory device. But we don't know which memory is onlined first, so offlining memory may fail. In such case, iterate twice to offline the memory. 1st iterate: offline every non primary memory block.
2nd iterate: offline primary (i.e. first added) memory block.
This idea is suggested by KOSAKI Motohiro.
--- mm/memory_hotplug.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
mm/memory_hotplug.c +14 -2
@@ -1019,10 +1019,13 @@ int remove_memory(u64 start, u64 size)unsigned long start_pfn, end_pfn;unsigned long pfn, section_nr;int ret; +int return_on_error =0 ; +int retry =0 ; start_pfn =PFN_DOWN (start); end_pfn = start_pfn +PFN_DOWN (size); +repeat:for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { section_nr =pfn_to_section_nr (pfn);if (!present_section_nr (section_nr))
@@ -1041,14 +1044,23 @@ int remove_memory(u64 start, u64 size) ret =offline_memory_block (mem);if (ret) { -kobject_put (&mem->dev.kobj); -return ret; +if (return_on_error) { +kobject_put (&mem->dev.kobj); +return ret; + }else { + retry =1 ; + } } }if (mem)kobject_put (&mem->dev.kobj); +if (retry) { + return_on_error =1 ; + goto repeat; + } +return 0 ; }#else
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 2/12 memory-hotplug: check whether all memory blocks are offlined or not when removing memory
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
We remove the memory like this:
1. lock memory hotplug
2. offline a memory block
3. unlock memory hotplug
4. repeat 1-3 to offline all memory blocks
5. lock memory hotplug
6. remove memory(TODO)
7. unlock memory hotplug
All memory blocks must be offlined before removing memory. But we don't hold the lock in the whole operation. So we should check whether all memory blocks are offlined before step6. Otherwise, kernel maybe panicked.
--- drivers/base/memory.c | 6 ++++++ include/linux/memory_hotplug.h | 1 + mm/memory_hotplug.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
drivers/base/memory.c +6 -0
@@ -675,6 +675,12 @@ int offline_memory_block(struct memory_block *mem)return ret; } +/* return true if the memory block is offlined, otherwise, return false */ +bool is_memblock_offlined (struct memory_block *mem) +{ +return mem->state ==MEM_OFFLINE ; +} +/* * Initialize the sysfs support for memory devices... */
include/linux/memory_hotplug.h +1 -0
@@ -236,6 +236,7 @@ extern int add_memory(int nid, u64 start, u64 size);extern int arch_add_memory (int nid,u64 start,u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem); +extern bool is_memblock_offlined (struct memory_block *mem);extern int remove_memory (u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);
mm/memory_hotplug.c +47 -0
53 lines not on this page · raw message
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 3/12 memory-hotplug: remove redundant codes
In reply to Wen Congyangofflining memory blocks and checking whether memory blocks are offlined are very similar. This patch introduces a new function to remove redundant codes.
--- mm/memory_hotplug.c | 101 ++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 46 deletions(-)
mm/memory_hotplug.c +55 -46
@@ -1012,20 +1012,14 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages)return __offline_pages (start_pfn, start_pfn + nr_pages,120 *HZ ); } -int remove_memory (u64 start,u64 size) +static int walk_memory_range (unsigned long start_pfn,unsigned long end_pfn, +void *arg,int (*func)(struct memory_block *,void *)) {struct memory_block *mem =NULL ;struct mem_section *section; -unsigned long start_pfn, end_pfn;unsigned long pfn, section_nr;int ret; -int return_on_error =0 ; -int retry =0 ; - - start_pfn =PFN_DOWN (start); - end_pfn = start_pfn +PFN_DOWN (size); -repeat:for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { section_nr =pfn_to_section_nr (pfn);if (!present_section_nr (section_nr))
@@ -1042,22 +1036,61 @@ repeat:if (!mem)continue ; - ret =offline_memory_block (mem); + ret =func (mem, arg);if (ret) { -if (return_on_error) { -kobject_put (&mem->dev.kobj); -return ret; - }else { - retry =1 ; - } +kobject_put (&mem->dev.kobj); +return ret; } }if (mem)kobject_put (&mem->dev.kobj); -if (retry) { - return_on_error =1 ; +return 0 ; +} + +static int offline_memory_block_cb (struct memory_block *mem,void *arg) +{ +int *ret = arg; +int error =offline_memory_block (mem); + +if (error !=0 && *ret ==0 ) + *ret = error; + +return 0 ; +} + +static int is_memblock_offlined_cb (struct memory_block *mem,void *arg) +{ +int ret = !is_memblock_offlined (mem); + +if (unlikely (ret)) +pr_warn ("removing memory fails, because memory " +"[%#010llx-%#010llx] is onlined\n" , +PFN_PHYS (section_nr_to_pfn (mem->start_section_nr)), +PFN_PHYS (section_nr_to_pfn (mem->end_section_nr +1 ))-1 ); + +return ret; +} + +int remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn, end_pfn; +int ret =0 ; +int retry =1 ; + + start_pfn =PFN_DOWN (start); + end_pfn = start_pfn +PFN_DOWN (size); + +repeat: +walk_memory_range (start_pfn, end_pfn, &ret, + offline_memory_block_cb); +if (ret) { +if (!retry) +return ret; + + retry =0 ; + ret =0 ; goto repeat; }
@@ -1075,37 +1108,13 @@ repeat:* memory blocks are offlined. */ -for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { - section_nr =pfn_to_section_nr (pfn); -if (!present_section_nr (section_nr)) -continue ; - - section =__nr_to_section (section_nr); -/* same memblock? */ -if (mem) -if ((section_nr >= mem->start_section_nr) && - (section_nr <= mem->end_section_nr)) -continue ; - - mem =find_memory_block_hinted (section, mem); -if (!mem) -continue ; - - ret =is_memblock_offlined (mem); -if (!ret) { -pr_warn ("removing memory fails, because memory " -"[%#010llx-%#010llx] is onlined\n" , -PFN_PHYS (section_nr_to_pfn (mem->start_section_nr)), -PFN_PHYS (section_nr_to_pfn (mem->end_section_nr +1 )) -1 ); - -kobject_put (&mem->dev.kobj); -unlock_memory_hotplug (); -return ret; - } + ret =walk_memory_range (start_pfn, end_pfn,NULL , + is_memblock_offlined_cb); +if (ret) { +unlock_memory_hotplug (); +return ret; } -if (mem) -kobject_put (&mem->dev.kobj);unlock_memory_hotplug ();return 0 ;
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 4/12 memory-hotplug: remove /sys/firmware/memmap/X sysfs
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
When (hot)adding memory into system, /sys/firmware/memmap/X/{end, start, type} sysfs files are created. But there is no code to remove these files. The patch implements the function to remove them.
Note: The code does not free firmware_map_entry which is allocated by bootmem.
So the patch makes memory leak. But I think the memory leak size is very samll. And it does not affect the system.
--- drivers/firmware/memmap.c | 98 +++++++++++++++++++++++++++++++++++++++++++- include/linux/firmware-map.h | 6 +++ mm/memory_hotplug.c | 5 ++- 3 files changed, 106 insertions(+), 3 deletions(-)
drivers/firmware/memmap.c +96 -2
@@ -21,6 +21,7 @@#include <linux/types.h> #include <linux/bootmem.h> #include <linux/slab.h> +#include <linux/mm.h> /* * Data types ------------------------------------------------------------------
@@ -41,6 +42,7 @@ struct firmware_map_entry {const char *type;/* type of the memory range */ struct list_head list;/* entry for the linked list */ struct kobject kobj;/* kobject for each entry */ + unsigned int bootmem:1; /* allocated from bootmem */ };/*
@@ -79,7 +81,26 @@ static const struct sysfs_ops memmap_attr_ops = { .show = memmap_attr_show, }; + +static inline struct firmware_map_entry * +to_memmap_entry (struct kobject *kobj) +{ + return container_of(kobj, struct firmware_map_entry, kobj); +} + +static void release_firmware_map_entry (struct kobject *kobj) +{ +struct firmware_map_entry *entry =to_memmap_entry (kobj); + +if (entry->bootmem) +/* There is no way to free memory allocated from bootmem */ +return ; + +kfree (entry); +} +static struct kobj_type memmap_ktype = { + .release = release_firmware_map_entry, .sysfs_ops = &memmap_attr_ops, .default_attrs = def_attrs, };
@@ -94,6 +115,7 @@ static struct kobj_type memmap_ktype = {* in firmware initialisation code in one single thread of execution. */ static LIST_HEAD (map_entries); +static DEFINE_SPINLOCK (map_entries_lock);/** * firmware_map_add_entry() - Does the real work to add a firmware memmap entry.
@@ -118,11 +140,25 @@ static int firmware_map_add_entry(u64 start, u64 end,INIT_LIST_HEAD (&entry->list);kobject_init (&entry->kobj, &memmap_ktype); +spin_lock (&map_entries_lock);list_add_tail (&entry->list, &map_entries); +spin_unlock (&map_entries_lock);return 0 ; } +/** +* firmware_map_remove_entry() - Does the real work to remove a firmware +* memmap entry. +* @entry: removed entry. +**/ +static inline void firmware_map_remove_entry (struct firmware_map_entry *entry) +{ +spin_lock (&map_entries_lock); +list_del (&entry->list); +spin_unlock (&map_entries_lock); +} +/* * Add memmap entry on sysfs */
@@ -144,6 +180,35 @@ static int add_sysfs_fw_map_entry(struct firmware_map_entry *entry)return 0 ; } +/* +* Remove memmap entry on sysfs +*/ +static inline void remove_sysfs_fw_map_entry (struct firmware_map_entry *entry) +{ +kobject_put (&entry->kobj); +} + +/* +* Search memmap entry +*/ + +static struct firmware_map_entry *__meminit +firmware_map_find_entry (u64 start,u64 end,const char *type) +{ +struct firmware_map_entry *entry; + +spin_lock (&map_entries_lock); +list_for_each_entry (entry, &map_entries, list) +if ((entry->start == start) && (entry->end == end) && + (!strcmp (entry->type, type))) { +spin_unlock (&map_entries_lock); +return entry; + } + +spin_unlock (&map_entries_lock); +return NULL ; +} +/** * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do * memory hotplug.
@@ -193,9 +258,36 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type)if (WARN_ON (!entry))return -ENOMEM ; + entry->bootmem =1 ;return firmware_map_add_entry (start, end, type, entry); } +/** +* firmware_map_remove() - remove a firmware mapping entry +* @start: Start of the memory range. +* @end: End of the memory range. +* @type: Type of the memory range. +* +* removes a firmware mapping entry. +* +* Returns 0 on success, or -EINVAL if no entry. +**/ +int __meminit firmware_map_remove (u64 start,u64 end,const char *type) +{ +struct firmware_map_entry *entry; + + entry =firmware_map_find_entry (start, end -1 , type); +if (!entry) +return -EINVAL ; + +firmware_map_remove_entry (entry); + +/* remove the memmap entry */ +remove_sysfs_fw_map_entry (entry); + +return 0 ; +} +/* * Sysfs functions ------------------------------------------------------------- */
@@ -217,8 +309,10 @@ static ssize_t type_show(struct firmware_map_entry *entry, char *buf)return snprintf (buf,PAGE_SIZE ,"%s\n" , entry->type); } -#define to_memmap_attr (_attr) container_of(_attr, struct memmap_attribute, attr) -#define to_memmap_entry (obj) container_of(obj, struct firmware_map_entry, kobj) +static inline struct memmap_attribute *to_memmap_attr (struct attribute *attr) +{ + return container_of(attr, struct memmap_attribute, attr); +}static ssize_t memmap_attr_show (struct kobject *kobj,struct attribute *attr,char *buf)
include/linux/firmware-map.h +6 -0
@@ -25,6 +25,7 @@int firmware_map_add_early (u64 start,u64 end,const char *type);int firmware_map_add_hotplug (u64 start,u64 end,const char *type); +int firmware_map_remove (u64 start,u64 end,const char *type);#else /* CONFIG_FIRMWARE_MEMMAP */
@@ -38,6 +39,11 @@ static inline int firmware_map_add_hotplug(u64 start, u64 end, const char *type)return 0 ; } +static inline int firmware_map_remove (u64 start,u64 end,const char *type) +{ +return 0 ; +} +#endif /* CONFIG_FIRMWARE_MEMMAP */ #endif /* _LINUX_FIRMWARE_MAP_H */
mm/memory_hotplug.c +4 -1
@@ -1073,7 +1073,7 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)return ret; } -int remove_memory (u64 start,u64 size) +int __ref remove_memory (u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;
@@ -1115,6 +1115,9 @@ repeat:return ret; } +/* remove memmap entry */ +firmware_map_remove (start, start + size,"System RAM" ); +unlock_memory_hotplug ();return 0 ;
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 5/12 memory-hotplug: introduce new function arch_remove_memory() for removing page table depends on architecture
In reply to Wen CongyangFor removing memory, we need to remove page table. But it depends on architecture. So the patch introduce arch_remove_memory() for removing page table. Now it only calls __remove_pages().
Note: __remove_pages() for some archtecuture is not implemented
(I don't know how to implement it for s390).
--- arch/ia64/mm/init.c | 18 ++++++++++++++++++ arch/powerpc/mm/mem.c | 12 ++++++++++++ arch/s390/mm/init.c | 12 ++++++++++++ arch/sh/mm/init.c | 17 +++++++++++++++++ arch/tile/mm/init.c | 8 ++++++++ arch/x86/mm/init_32.c | 12 ++++++++++++ arch/x86/mm/init_64.c | 15 +++++++++++++++ include/linux/memory_hotplug.h | 1 + mm/memory_hotplug.c | 2 ++ 9 files changed, 97 insertions(+)
arch/ia64/mm/init.c +18 -0
@@ -690,6 +690,24 @@ int arch_add_memory(int nid, u64 start, u64 size) return ret; } + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn = start >>PAGE_SHIFT ; +unsigned long nr_pages = size >>PAGE_SHIFT ; +struct zone *zone; +int ret; + + zone =page_zone (pfn_to_page (start_pfn)); + ret =__remove_pages (zone, start_pfn, nr_pages); +if (ret) +pr_warn ("%s: Problem encountered in __remove_pages() as" +" ret=%d\n" , __func__, ret); + +return ret; +} +#endif #endif /*
arch/powerpc/mm/mem.c +12 -0
@@ -133,6 +133,18 @@ int arch_add_memory(int nid, u64 start, u64 size) return __add_pages(nid, zone, start_pfn, nr_pages); } + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn = start >>PAGE_SHIFT ; +unsigned long nr_pages = size >>PAGE_SHIFT ; +struct zone *zone; + + zone =page_zone (pfn_to_page (start_pfn)); +return __remove_pages (zone, start_pfn, nr_pages); +} +#endif #endif /* CONFIG_MEMORY_HOTPLUG */ /*
arch/s390/mm/init.c +12 -0
@@ -257,4 +257,16 @@ int arch_add_memory(int nid, u64 start, u64 size)vmem_remove_mapping (start, size); return rc; } + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +/* +* There is no hardware or firmware interface which could trigger a +* hot memory remove on s390. So there is nothing that needs to be +* implemented. +*/ +return -EBUSY ; +} +#endif #endif /* CONFIG_MEMORY_HOTPLUG */
arch/sh/mm/init.c +17 -0
@@ -558,4 +558,21 @@ int memory_add_physaddr_to_nid(u64 addr)EXPORT_SYMBOL_GPL (memory_add_physaddr_to_nid);#endif +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn = start >>PAGE_SHIFT ; +unsigned long nr_pages = size >>PAGE_SHIFT ; +struct zone *zone; +int ret; + + zone =page_zone (pfn_to_page (start_pfn)); + ret =__remove_pages (zone, start_pfn, nr_pages); +if (unlikely (ret)) +pr_warn ("%s: Failed, __remove_pages() == %d\n" , __func__, + ret); + +return ret; +} +#endif #endif /* CONFIG_MEMORY_HOTPLUG */
arch/tile/mm/init.c +8 -0
@@ -935,6 +935,14 @@ int remove_memory(u64 start, u64 size) {return -EINVAL ; } + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +/* TODO */ +return -EBUSY ; +} +#endif #endif struct kmem_cache *pgd_cache;
arch/x86/mm/init_32.c +12 -0
@@ -839,6 +839,18 @@ int arch_add_memory(int nid, u64 start, u64 size) return __add_pages(nid, zone, start_pfn, nr_pages); } + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn = start >>PAGE_SHIFT ; +unsigned long nr_pages = size >>PAGE_SHIFT ; +struct zone *zone; + + zone =page_zone (pfn_to_page (start_pfn)); +return __remove_pages (zone, start_pfn, nr_pages); +} +#endif #endif /*
arch/x86/mm/init_64.c +15 -0
@@ -680,6 +680,21 @@ int arch_add_memory(int nid, u64 start, u64 size) }EXPORT_SYMBOL_GPL (arch_add_memory); +#ifdef CONFIG_MEMORY_HOTREMOVE +int __ref arch_remove_memory (u64 start,u64 size) +{ +unsigned long start_pfn = start >>PAGE_SHIFT ; +unsigned long nr_pages = size >>PAGE_SHIFT ; +struct zone *zone; +int ret; + + zone =page_zone (pfn_to_page (start_pfn)); + ret =__remove_pages (zone, start_pfn, nr_pages); +WARN_ON_ONCE (ret); + +return ret; +} +#endif #endif /* CONFIG_MEMORY_HOTPLUG */ static struct kcore_list kcore_vsyscall;
include/linux/memory_hotplug.h +1 -0
@@ -85,6 +85,7 @@ extern void __online_page_free(struct page *page);#ifdef CONFIG_MEMORY_HOTREMOVE extern bool is_pageblock_removable_nolock (struct page *page); +extern int arch_remove_memory (u64 start,u64 size);#endif /* CONFIG_MEMORY_HOTREMOVE */ /* reasonably generic interface to expand the physical pages in a zone */
mm/memory_hotplug.c +2 -0
@@ -1118,6 +1118,8 @@ repeat:/* remove memmap entry */ firmware_map_remove (start, start + size,"System RAM" ); +arch_remove_memory (start, size); +unlock_memory_hotplug ();return 0 ;
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 6/12 memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
Currently __remove_section for SPARSEMEM_VMEMMAP does nothing. But even if we use SPARSEMEM_VMEMMAP, we can unregister the memory_section.
So the patch add unregister_memory_section() into __remove_section().
--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
mm/memory_hotplug.c +8 -5
@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else static int __remove_section (struct zone *zone,struct mem_section *ms)
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
Quoted 6 lines · Wen Congyang
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().
Hi Yasuaki,
In order to review this patch, I should dig sparse memory codes in advance. But I have some confuse of codes. Why need encode/decode mem map instead of set mem_map to ms->section_mem_map directly?
Regards,
Jaegeuk
Quoted 28 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +1
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ;
mm/memory_hotplug.c static int __meminit __add_section(int nid, struct zone *zone, · line 299
Quoted 10 lines
mm/memory_hotplug.c +7
-0+ +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + + return ret; }#else static int __remove_section (struct zone *zone,struct mem_section *ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
At 11/20/2012 02:22 PM, Jaegeuk Hanse Wrote:
Quoted 7 lines · Wen Congyang
Quoted 6 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.
Quoted 7 lines
Quoted 1 line
So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
In order to review this patch, I should dig sparse memory codes in advance. But I have some confuse of codes. Why need encode/decode mem map instead of set
mem_maptoms->section_mem_mapdirectly?
The memmap is aligned, and the low bits are zero. We store some information in these bits. So we need to encode/decode memmap here.
Thanks
Wen Congyang
Quoted 35 lines
Regards,
JaegeukQuoted 31 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +3
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms))
Quoted 10 lines
Quoted 8 lines
mm/memory_hotplug.c +5
-0+return ret; + + ret =unregister_memory_section (ms); + + return ret; }#else static int
__remove_section(struct zone *zone, struct mem_section *ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
Quoted 8 lines · Wen Congyang
At 11/20/2012 02:22 PM, Jaegeuk Hanse Wrote:
Quoted 7 lines · Wen Congyang
Quoted 6 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
In order to review this patch, I should dig sparse memory codes in advance. But I have some confuse of codes. Why need encode/decode mem map instead of set
mem_maptoms->section_mem_mapdirectly?The memmap is aligned, and the low bits are zero. We store some information in these bits. So we need to encode/decode memmap here.
Hi Congyang,
Thanks for you reponse. But I mean why return (unsigned long)(mem_map - (section_nr_to_pfn(pnum))); in function sparse_encode_mem_map, and then return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum); in funtion sparse_decode_mem_map instead of just store mem_map in ms->section_mep_map directly.
Regards,
Jaegeuk
Quoted 46 lines
Thanks
Wen CongyangQuoted 42 lines
Regards,
JaegeukQuoted 38 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else static int
__remove_section(struct zone *zone, struct mem_section *ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
At 11/20/2012 02:58 PM, Jaegeuk Hanse Wrote:
Quoted 19 lines · Wen Congyang
Quoted 9 lines
At 11/20/2012 02:22 PM, Jaegeuk Hanse Wrote:
Quoted 8 lines · Wen Congyang
Quoted 7 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().Quoted 8 lines
Quoted 5 lines
Hi Yasuaki,
In order to review this patch, I should dig sparse memory codes in advance. But I have some confuse of codes. Why need encode/decode mem map instead of set
mem_maptoms->section_mem_mapdirectly?The memmap is aligned, and the low bits are zero. We store some information
in these bits. So we need to encode/decode memmap here.
Quoted 7 lines
Hi Congyang,
Thanks for you reponse. But I mean why return (unsigned long)(mem_map - (
section_nr_to_pfn(pnum))); in functionsparse_encode_mem_map, and then return ((struct page *)coded_mem_map) +section_nr_to_pfn(pnum); in funtionsparse_decode_mem_mapinstead of just storemem_mapinms->section_mep_mapdirectly.
I don't know why. I try to find the reason, but I don't find any place to use the pfn stored in the mem_map except in the decode function. Maybe the designer doesn't want us to access the mem_map directly.
Thanks
Wen Congyang
Quoted 54 lines
Regards,
JaegeukQuoted 48 lines
Thanks
Wen CongyangQuoted 44 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
Quoted 26 lines · Wen Congyang
At 11/20/2012 02:58 PM, Jaegeuk Hanse Wrote:
Quoted 18 lines · Wen Congyang
Quoted 9 lines
At 11/20/2012 02:22 PM, Jaegeuk Hanse Wrote:
Quoted 8 lines · Wen Congyang
Quoted 7 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().Quoted 8 lines
Quoted 5 lines
Hi Yasuaki,
In order to review this patch, I should dig sparse memory codes in advance. But I have some confuse of codes. Why need encode/decode mem map instead of set
mem_maptoms->section_mem_mapdirectly?The memmap is aligned, and the low bits are zero. We store some information
in these bits. So we need to encode/decode memmap here.Quoted 7 lines
Hi Congyang,
Thanks for you reponse. But I mean why return (unsigned long)(mem_map - (
section_nr_to_pfn(pnum))); in functionsparse_encode_mem_map, and then return ((struct page *)coded_mem_map) +section_nr_to_pfn(pnum); in funtionsparse_decode_mem_mapinstead of just storemem_mapinms->section_mep_mapdirectly.
Quoted 4 lines
I don't know why. I try to find the reason, but I don't find any place to use the pfn stored in the
mem_mapexcept in the decode function. Maybe the designer doesn't want us to access themem_mapdirectly.
It seems that mem_map is per node, but pfn is real pfn. you can check __page_to_pfn.
Quoted 54 lines
Thanks
Wen CongyangQuoted 50 lines
Regards,
JaegeukQuoted 46 lines
Thanks
Wen CongyangQuoted 43 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
In reply to Wen CongyangQuoted 6 lines · Wen Congyang
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().
Hi Yasuaki,
I have a question about these sparse vmemmap memory related patches. Hot add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous, page_to_pfn and pfn_to_page can't work correctly.
Regards,
Jaegeuk
Quoted 38 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else static int __remove_section (struct zone *zone,struct mem_section *ms)
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 9 lines · Wen Congyang
Quoted 7 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().
Quoted 7 lines
Hi Yasuaki,
I have a question about these sparse vmemmap memory related patches. Hot add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,
page_to_pfnandpfn_to_pagecan't work correctly.
vmemmap has its virtual address range:ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
We allocate memory from buddy system to store struct page, and its virtual address isn't in this range. So we should update the page table:
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page() // get the virtual address in the vmemmap range vmemmap_populate() // we update page table here
When we use vmemmap, page_to_pfn() always returns address in the vmemmap range, not the address that kmalloc() returns. So the virtual address is continuous.
Thanks
Wen Congyang
Quoted 35 lines
Regards,
JaegeukQuoted 31 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +3
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms))
Quoted 10 lines
Quoted 8 lines
mm/memory_hotplug.c +5
-0+return ret; + + ret =unregister_memory_section (ms); + + return ret; }#else static int
__remove_section(struct zone *zone, struct mem_section *ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
Quoted 22 lines · Wen Congyang
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 7 lines · Wen Congyang
Quoted 6 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.Quoted 8 lines
Quoted 1 line
So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
I have a question about these sparse vmemmap memory related patches. Hot add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,
page_to_pfnandpfn_to_pagecan't work correctly.vmemmap has its virtual address range:
ffffea0000000000- ffffeaffffffffff (=40 bits) virtual memory map (1TB)We allocate memory from buddy system to store struct page, and its virtual address isn't in this range. So we should update the page table:
Quoted 8 lines
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page()// get the virtual address in the vmemmap rangevmemmap_populate()// we update page table hereWhen we use vmemmap,
page_to_pfn()always returns address in the vmemmap range, not the address thatkmalloc()returns. So the virtual address is continuous.
Hi Congyang,
Another question about memory hotplug. During hot remove memory, it will also call memblock_remove to remove related memblock. memblock_remove()
__memblock_remove()
memblock_isolate_range()
memblock_remove_region()But memblock_isolate_range() only record fully contained regions, regions which are partial overlapped just be splitted instead of record. So these partial overlapped regions can't be removed. Where I miss?
Regards,
Jaegeuk
Quoted 44 lines
Thanks
Wen CongyangQuoted 42 lines
Regards,
JaegeukQuoted 38 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else static int
__remove_section(struct zone *zone, struct mem_section *ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
At 11/21/2012 12:22 PM, Jaegeuk Hanse Wrote:
Quoted 29 lines · Wen Congyang
Quoted 28 lines
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 7 lines · Wen Congyang
Quoted 6 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.Quoted 8 lines
Quoted 1 line
So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
I have a question about these sparse vmemmap memory related patches. Hot add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,
page_to_pfnandpfn_to_pagecan't work correctly.vmemmap has its virtual address range:
ffffea0000000000- ffffeaffffffffff (=40 bits) virtual memory map (1TB)We allocate memory from buddy system to store struct page, and its virtual
address isn't in this range. So we should update the page table:
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page()// get the virtual address in the vmemmap rangevmemmap_populate()// we update page table here
Quoted 8 lines
Quoted 3 lines
When we use vmemmap,
page_to_pfn()always returns address in the vmemmap range, not the address thatkmalloc()returns. So the virtual address is continuous.Hi Congyang,
Another question about memory hotplug. During hot remove memory, it will also call
memblock_removeto remove related memblock.
IIRC, we don't touch memblock when hot-add/hot-remove memory. memblock is only used for bootmem allocator. I think it isn't used after booting.
Quoted 8 lines
memblock_remove()__memblock_remove() memblock_isolate_range() memblock_remove_region()But
memblock_isolate_range()only record fully contained regions, regions which are partial overlapped just be splitted instead of record. So these partial overlapped regions can't be removed. Where I miss?
No, memblock_isolate_range() can deal with partial overlapped region.
=====================
if (rbase < base) {
/*
* @rgn intersects from below. Split and continue
* to process the next region - the new top half.
*/
rgn->base = base;
rgn->size -= base - rbase;
type->total_size -= base - rbase;
memblock_insert_region(type, i, rbase, base - rbase,
memblock_get_region_node(rgn));
} else if (rend > end) {
/*
* @rgn intersects from above. Split and redo the
* current region - the new bottom half.
*/
rgn->base = end;
rgn->size -= end - rbase;
type->total_size -= end - rbase;
memblock_insert_region(type, i--, rbase, end - rbase,
memblock_get_region_node(rgn));=====================
If the region is partial overlapped region, we will split the old region into two regions. After doing this, it is full contained region now.
Thanks
Wen Congyang
Quoted 52 lines
Regards,
JaegeukQuoted 46 lines
Thanks
Wen CongyangQuoted 44 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
Quoted 33 lines · Wen Congyang
At 11/21/2012 12:22 PM, Jaegeuk Hanse Wrote:
Quoted 32 lines · Wen Congyang
Quoted 31 lines
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 7 lines · Wen Congyang
Quoted 6 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.Quoted 8 lines
Quoted 1 line
So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
I have a question about these sparse vmemmap memory related patches. Hot add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,
page_to_pfnandpfn_to_pagecan't work correctly.vmemmap has its virtual address range:
ffffea0000000000- ffffeaffffffffff (=40 bits) virtual memory map (1TB)We allocate memory from buddy system to store struct page, and its virtual
address isn't in this range. So we should update the page table:
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page()// get the virtual address in the vmemmap rangevmemmap_populate()// we update page table hereWhen we use vmemmap,
page_to_pfn()always returns address in the vmemmap range, not the address thatkmalloc()returns. So the virtual address is continuous.
Quoted 6 lines
Quoted 4 lines
Hi Congyang,
Another question about memory hotplug. During hot remove memory, it will also call
memblock_removeto remove related memblock.IIRC, we don't touch memblock when hot-add/hot-remove memory. memblock is only used for bootmem allocator. I think it isn't used after booting.
In IBM pseries servers.
pseries_remove_memory()
pseries_remove_memblock()
memblock_remove()
Furthermore, memblock is set to record available memory ranges get from e820 map(you can check it in memblock_x86_fill()) in x86 case, after hot-remove memory, this range of memory can't be available, why not remove them as pseries servers' codes do.
Quoted 31 lines
Quoted 9 lines
memblock_remove()
__memblock_remove()memory-hotplug: unregister memory section onSPARSEMEM_VMEMMAP
memblock_isolate_range()
memblock_remove_region()But
memblock_isolate_range()only record fully contained regions, regions which are partial overlapped just be splitted instead of record. So these partial overlapped regions can't be removed. Where I miss?No,
memblock_isolate_range()can deal with partial overlapped region.
=====================if (rbase < base) { /* * @rgn intersects from below. Split and continue * to process the next region - the new top half. */ rgn->base = base; rgn->size -= base - rbase; type->total_size -= base - rbase; memblock_insert_region(type, i, rbase, base - rbase, memblock_get_region_node(rgn)); } else if (rend > end) { /* * @rgn intersects from above. Split and redo the * current region - the new bottom half. */ rgn->base = end; rgn->size -= end - rbase; type->total_size -= end - rbase; memblock_insert_region(type, i--, rbase, end - rbase, memblock_get_region_node(rgn));
Quoted 4 lines
=====================
If the region is partial overlapped region, we will split the old region into two regions. After doing this, it is full contained region now.
You are right, I misunderstand the codes.
Quoted 53 lines
Thanks
Wen CongyangQuoted 49 lines
Regards,
JaegeukQuoted 45 lines
Thanks
Wen CongyangQuoted 43 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
At 11/21/2012 01:03 PM, Jaegeuk Hanse Wrote:
Quoted 46 lines · Wen Congyang
Quoted 36 lines
At 11/21/2012 12:22 PM, Jaegeuk Hanse Wrote:
Quoted 35 lines · Wen Congyang
Quoted 34 lines
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 10 lines · Wen Congyang
Quoted 7 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
Quoted 7 lines
I have a question about these sparse vmemmap memory related patches. Hot
add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,page_to_pfnandpfn_to_page
can't work correctly.vmemmap has its virtual address range:
ffffea0000000000- ffffeaffffffffff (=40 bits) virtual memory map (1TB)We allocate memory from buddy system to store struct page, and its virtual
address isn't in this range. So we should update the page table:
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page()// get the virtual address in the vmemmap rangevmemmap_populate()// we update page table hereWhen we use vmemmap,
page_to_pfn()always returns address in the vmemmap
range, not the address thatkmalloc()returns. So the virtual address is continuous.Quoted 6 lines
Quoted 4 lines
Hi Congyang,
Another question about memory hotplug. During hot remove memory, it will also call
memblock_removeto remove related memblock.IIRC, we don't touch memblock when hot-add/hot-remove memory. memblock is only used for bootmem allocator. I think it isn't used after booting.
In IBM pseries servers.
Quoted 8 lines
pseries_remove_memory()
pseries_remove_memblock()
memblock_remove()Furthermore, memblock is set to record available memory ranges get from e820
map(you can check it in memblock_x86_fill())in x86 case, after hot-remove memory, this range of memory can't be available, why not remove them as pseries servers' codes do.
Oh, it is powerpc, and I don't read this code. I will check it now.
Thanks for pointing it out.
Wen Congyang
Quoted 35 lines
Quoted 35 lines
Quoted 11 lines
memblock_remove()
__memblock_remove()memory-hotplug: unregister memory
section onSPARSEMEM_VMEMMAP
memblock_isolate_range()
memblock_remove_region()But
memblock_isolate_range()only record fully contained regions, regions which are partial overlapped just be splitted instead of record. So these partial overlapped regions can't be removed. Where I miss?No,
memblock_isolate_range()can deal with partial overlapped region.
=====================if (rbase < base) { /* * @rgn intersects from below. Split and continue * to process the next region - the new top half. */ rgn->base = base; rgn->size -= base - rbase; type->total_size -= base - rbase; memblock_insert_region(type, i, rbase, base - rbase, memblock_get_region_node(rgn)); } else if (rend > end) { /* * @rgn intersects from above. Split and redo the * current region - the new bottom half. */ rgn->base = end; rgn->size -= end - rbase; type->total_size -= end - rbase; memblock_insert_region(type, i--, rbase, end - rbase, memblock_get_region_node(rgn));=====================
Quoted 61 lines
Quoted 3 lines
If the region is partial overlapped region, we will split the old region into
two regions. After doing this, it is full contained region now.You are right, I misunderstand the codes.
Quoted 53 lines
Thanks
Wen CongyangQuoted 49 lines
Regards,
JaegeukQuoted 45 lines
Thanks
Wen CongyangQuoted 43 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 06/12] memory-hotplug: unregister memory section on SPARSEMEM_VMEMMAP
In reply to Jaegeuk HanseAt 11/21/2012 01:03 PM, Jaegeuk Hanse Wrote:
Quoted 41 lines · Wen Congyang
Quoted 40 lines
At 11/21/2012 12:22 PM, Jaegeuk Hanse Wrote:
Quoted 39 lines · Wen Congyang
Quoted 30 lines
At 11/20/2012 07:16 PM, Jaegeuk Hanse Wrote:
Quoted 10 lines · Wen Congyang
Quoted 7 lines
From: Yasuaki Ishimatsu <[email protected]>
Currently
__remove_sectionforSPARSEMEM_VMEMMAPdoes nothing. But even if
we useSPARSEMEM_VMEMMAP, we can unregister thememory_section.So the patch add
unregister_memory_section()into__remove_section().Hi Yasuaki,
Quoted 7 lines
I have a question about these sparse vmemmap memory related patches. Hot
add memory need allocated vmemmap pages, but this time is allocated by buddy system. How can gurantee virtual address is continuous to the address allocated before? If not continuous,page_to_pfnandpfn_to_page
can't work correctly.vmemmap has its virtual address range:
ffffea0000000000- ffffeaffffffffff (=40 bits) virtual memory map (1TB)We allocate memory from buddy system to store struct page, and its virtual
address isn't in this range. So we should update the page table:
kmalloc_section_memmap()
sparse_mem_map_populate()
pfn_to_page()// get the virtual address in the vmemmap rangevmemmap_populate()// we update page table hereQuoted 4 lines
When we use vmemmap,
page_to_pfn()always returns address in the vmemmap
range, not the address thatkmalloc()returns. So the virtual address is continuous.Hi Congyang,
Another question about memory hotplug. During hot remove memory, it will also call
memblock_removeto remove related memblock.
Quoted 8 lines
Quoted 2 lines
IIRC, we don't touch memblock when hot-add/hot-remove memory. memblock is only used for bootmem allocator. I think it isn't used after booting.
In IBM pseries servers.
pseries_remove_memory()
pseries_remove_memblock()
memblock_remove()
It seems that pseries servers don't use ACPI(ACPI is only supported for ia64 and x86 now. arm will be supported in the furture).
I am not ppc expert, and I don't know why we touch memblock when hotadding memory in ppc case. But IIRC, we don't need memblock after the machine has booted up in x86 case. So there is no need to touch it when hotadd/hotremove the memory in x86 case.
Thanks
Wen Congyang
Quoted 40 lines
Furthermore, memblock is set to record available memory ranges get from e820
map(you can check it in memblock_x86_fill())in x86 case, after hot-remove memory, this range of memory can't be available, why not remove them as pseries servers' codes do.Quoted 34 lines
Quoted 10 lines
memblock_remove()
__memblock_remove()memory-hotplug: unregister memory
section onSPARSEMEM_VMEMMAP
memblock_isolate_range()
memblock_remove_region()But
memblock_isolate_range()only record fully contained regions, regions which are partial overlapped just be splitted instead of record. So these partial overlapped regions can't be removed. Where I miss?No,
memblock_isolate_range()can deal with partial overlapped region.
=====================if (rbase < base) { /* * @rgn intersects from below. Split and continue * to process the next region - the new top half. */ rgn->base = base; rgn->size -= base - rbase; type->total_size -= base - rbase; memblock_insert_region(type, i, rbase, base - rbase, memblock_get_region_node(rgn)); } else if (rend > end) { /* * @rgn intersects from above. Split and redo the * current region - the new bottom half. */ rgn->base = end; rgn->size -= end - rbase; type->total_size -= end - rbase; memblock_insert_region(type, i--, rbase, end - rbase, memblock_get_region_node(rgn));=====================
Quoted 61 lines
Quoted 3 lines
If the region is partial overlapped region, we will split the old region into
two regions. After doing this, it is full contained region now.You are right, I misunderstand the codes.
Quoted 53 lines
Thanks
Wen CongyangQuoted 49 lines
Regards,
JaegeukQuoted 45 lines
Thanks
Wen CongyangQuoted 43 lines
Regards,
JaegeukQuoted 40 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- mm/memory_hotplug.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)mm/memory_hotplug.c +8
-5@@ -286,11 +286,14 @@ static int __meminit __add_section(int nid, struct zone *zone,#ifdef CONFIG_SPARSEMEM_VMEMMAP static int __remove_section (struct zone *zone,struct mem_section *ms) { -/* -* XXX: Freeing memmap with vmemmap is not implement yet. -* This should be removed later. -*/ -return -EBUSY ; +int ret = -EINVAL ; + +if (!valid_section (ms)) +return ret; + + ret =unregister_memory_section (ms); + +return ret; }#else
static int __remove_section(struct zone *zone, structmem_section
*ms)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 7/12 memory-hotplug: implement register_page_bootmem_info_section of sparse-vmemmap
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
For removing memmap region of sparse-vmemmap which is allocated bootmem, memmap region of sparse-vmemmap needs to be registered by get_page_bootmem(). So the patch searches pages of virtual mapping and registers the pages by get_page_bootmem().
Note: register_page_bootmem_memmap() is not implemented for ia64, ppc, s390, and sparc.
--- arch/ia64/mm/discontig.c | 6 +++++ arch/powerpc/mm/init_64.c | 6 +++++ arch/s390/mm/vmem.c | 6 +++++ arch/sparc/mm/init_64.c | 6 +++++ arch/x86/mm/init_64.c | 52 ++++++++++++++++++++++++++++++++++++++++++ include/linux/memory_hotplug.h | 11 ++------- include/linux/mm.h | 3 ++- mm/memory_hotplug.c | 37 ++++++++++++++++++++++++++---- 8 files changed, 113 insertions(+), 14 deletions(-)
arch/ia64/mm/discontig.c +6 -0
@@ -822,4 +822,10 @@ int __meminit vmemmap_populate(struct page *start_page, {return vmemmap_populate_basepages (start_page, size, node); } + +void register_page_bootmem_memmap (unsigned long section_nr, +struct page *start_page,unsigned long size) +{ +/* TODO */ +}#endif
arch/powerpc/mm/init_64.c +6 -0
@@ -297,5 +297,11 @@ int __meminit vmemmap_populate(struct page *start_page, return 0; } + +void register_page_bootmem_memmap (unsigned long section_nr, +struct page *start_page,unsigned long size) +{ +/* TODO */ +}#endif /* CONFIG_SPARSEMEM_VMEMMAP */
arch/s390/mm/vmem.c +6 -0
@@ -236,6 +236,12 @@ out:return ret; } +void register_page_bootmem_memmap (unsigned long section_nr, +struct page *start_page,unsigned long size) +{ +/* TODO */ +} +/* * Add memory segment to the segment list if it doesn't overlap with * an already present segment.
arch/sparc/mm/init_64.c +6 -0
@@ -2231,6 +2231,12 @@ void __meminit vmemmap_populate_print_last(void) node_start = 0; } } + +void register_page_bootmem_memmap (unsigned long section_nr, +struct page *start_page,unsigned long size) +{ +/* TODO */ +}#endif /* CONFIG_SPARSEMEM_VMEMMAP */ static void prot_init_common(unsigned long page_none,
arch/x86/mm/init_64.c +52 -0
58 lines not on this page · raw message
include/linux/memory_hotplug.h +2 -9
@@ -163,17 +163,10 @@ static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)#endif /* CONFIG_NUMA */ #endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */ -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static inline void register_page_bootmem_info_node (struct pglist_data *pgdat) -{ -} -static inline void put_page_bootmem (struct page *page) -{ -} -#else extern void register_page_bootmem_info_node (struct pglist_data *pgdat);extern void put_page_bootmem (struct page *page); -#endif +extern void get_page_bootmem (unsigned long ingo,struct page *page, +unsigned long type);/* * Lock for memory hotplug guarantees 1) all callbacks for memory hotplug
include/linux/mm.h +2 -1
@@ -1640,7 +1640,8 @@ int vmemmap_populate_basepages(struct page *start_page, unsigned long pages, int node);int vmemmap_populate (struct page *start_page,unsigned long pages,int node);void vmemmap_populate_print_last (void ); - +void register_page_bootmem_memmap (unsigned long section_nr,struct page *map, +unsigned long size);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,
mm/memory_hotplug.c +33 -4
@@ -91,9 +91,8 @@ static void release_memory_resource(struct resource *res) }#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE -#ifndef CONFIG_SPARSEMEM_VMEMMAP -static void get_page_bootmem(unsigned long info, struct page *page, - unsigned long type) +void get_page_bootmem (unsigned long info,struct page *page, +unsigned long type) { page->lru.next = (struct list_head *) type;SetPagePrivate (page);
@@ -127,6 +126,7 @@ void __ref put_page_bootmem(struct page *page) } +#ifndef CONFIG_SPARSEMEM_VMEMMAP static void register_page_bootmem_info_section (unsigned long start_pfn) {unsigned long *usemap, mapsize, section_nr, i;
@@ -160,6 +160,36 @@ static void register_page_bootmem_info_section(unsigned long start_pfn)get_page_bootmem (section_nr, page,MIX_SECTION_INFO ); } +#else +static void register_page_bootmem_info_section (unsigned long start_pfn) +{ +unsigned long *usemap, mapsize, section_nr, i; +struct mem_section *ms; +struct page *page, *memmap; + +if (!pfn_valid (start_pfn)) +return ; + + section_nr =pfn_to_section_nr (start_pfn); + ms =__nr_to_section (section_nr); + + memmap =sparse_decode_mem_map (ms->section_mem_map, section_nr); + + page =virt_to_page (memmap); + mapsize =sizeof (struct page ) *PAGES_PER_SECTION ; + mapsize =PAGE_ALIGN (mapsize) >>PAGE_SHIFT ; + +register_page_bootmem_memmap (section_nr, memmap,PAGES_PER_SECTION ); + + usemap =__nr_to_section (section_nr)->pageblock_flags; + page =virt_to_page (usemap); + + mapsize =PAGE_ALIGN (usemap_size ()) >>PAGE_SHIFT ; + +for (i =0 ; i < mapsize; i++, page++) +get_page_bootmem (section_nr, page,MIX_SECTION_INFO ); +} +#endif void register_page_bootmem_info_node (struct pglist_data *pgdat) {
@@ -202,7 +232,6 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat)register_page_bootmem_info_section (pfn); } } -#endif /* !CONFIG_SPARSEMEM_VMEMMAP */ static void grow_zone_span (struct zone *zone,unsigned long start_pfn,unsigned long end_pfn)
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 8/12 memory-hotplug: remove memmap of sparse-vmemmap
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
All pages of virtual mapping in removed memory cannot be freed, since some pages used as PGD/PUD includes not only removed memory but also other memory. So the patch checks whether page can be freed or not.
How to check whether page can be freed or not?
1. When removing memory, the page structs of the revmoved memory are filled with 0FD.
2. All page structs are filled with 0xFD on PT/PMD, PT/PMD can be cleared. In this case, the page used as PT/PMD can be freed.
Applying patch, __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is integrated into one. So __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is deleted.
Note: vmemmap_kfree() and vmemmap_free_bootmem() are not implemented for ia64, ppc, s390, and sparc.
--- arch/ia64/mm/discontig.c | 8 ++++ arch/powerpc/mm/init_64.c | 8 ++++ arch/s390/mm/vmem.c | 8 ++++ arch/sparc/mm/init_64.c | 8 ++++ arch/x86/mm/init_64.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 2 + mm/memory_hotplug.c | 17 +------ mm/sparse.c | 5 +- 8 files changed, 158 insertions(+), 17 deletions(-)
arch/ia64/mm/discontig.c +8 -0
@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,return vmemmap_populate_basepages (start_page, size, node); } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {
arch/powerpc/mm/init_64.c +8 -0
@@ -298,6 +298,14 @@ int __meminit vmemmap_populate(struct page *start_page,return 0 ; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {
arch/s390/mm/vmem.c +8 -0
@@ -236,6 +236,14 @@ out:return ret; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {
arch/sparc/mm/init_64.c +8 -0
@@ -2232,6 +2232,14 @@ void __meminit vmemmap_populate_print_last(void) } } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {
arch/x86/mm/init_64.c +119 -0
125 lines not on this page · raw message
include/linux/mm.h +2 -0
@@ -1642,6 +1642,8 @@ int vmemmap_populate(struct page *start_page, unsigned long pages, int node);void vmemmap_populate_print_last (void );void register_page_bootmem_memmap (unsigned long section_nr,struct page *map,unsigned long size); +void vmemmap_kfree (struct page *memmpa,unsigned long nr_pages); +void vmemmap_free_bootmem (struct page *memmpa,unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,
mm/memory_hotplug.c +2 -15
@@ -312,19 +312,6 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static int __remove_section (struct zone *zone,struct mem_section *ms) -{ -int ret = -EINVAL ; - -if (!valid_section (ms)) -return ret; - - ret =unregister_memory_section (ms); - -return ret; -} -#else static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;
@@ -341,9 +328,9 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags); - return 0; + +return ret; } -#endif /* * Reasonably generic function for adding memory. It is
mm/sparse.c +3 -2
@@ -613,12 +613,13 @@ static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid,/* This will make the necessary allocations eventually. */ return sparse_mem_map_populate(pnum, nid); } -static void __kfree_section_memmap (struct page *memmap,unsigned long nr_pages) +static void __kfree_section_memmap (struct page *page,unsigned long nr_pages) { -return ;/* XXX: Not implemented yet */ +vmemmap_kfree (page, nr_pages); }static void free_map_bootmem (struct page *page,unsigned long nr_pages) { +vmemmap_free_bootmem (page, nr_pages); }#else static struct page *__kmalloc_section_memmap (unsigned long nr_pages)
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 08/12] memory-hotplug: remove memmap of sparse-vmemmap
Quoted 301 lines · Wen Congyang
From: Yasuaki Ishimatsu <[email protected]>
All pages of virtual mapping in removed memory cannot be freed, since some pages used as PGD/PUD includes not only removed memory but also other memory. So the patch checks whether page can be freed or not.
How to check whether page can be freed or not?
1. When removing memory, the page structs of the revmoved memory are filled with 0FD.
2. All page structs are filled with0xFDon PT/PMD, PT/PMD can be cleared. In this case, the page used as PT/PMD can be freed.Applying patch,
__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis integrated into one. So__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis deleted.Note:
vmemmap_kfree()andvmemmap_free_bootmem()are not implemented for ia64, ppc, s390, and sparc.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- arch/ia64/mm/discontig.c | 8 ++++ arch/powerpc/mm/init_64.c | 8 ++++ arch/s390/mm/vmem.c | 8 ++++ arch/sparc/mm/init_64.c | 8 ++++ arch/x86/mm/init_64.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 2 + mm/memory_hotplug.c | 17 +------ mm/sparse.c | 5 +- 8 files changed, 158 insertions(+), 17 deletions(-)arch/ia64/mm/discontig.c +8
-0@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,return vmemmap_populate_basepages (start_page, size, node); } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/powerpc/mm/init_64.c +8
-0@@ -298,6 +298,14 @@ int __meminit vmemmap_populate(struct page *start_page,return 0 ; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/s390/mm/vmem.c +8
-0@@ -236,6 +236,14 @@ out:return ret; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/sparc/mm/init_64.c +8
-0@@ -2232,6 +2232,14 @@ void __meminit vmemmap_populate_print_last(void) } } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/x86/mm/init_64.c +119
-0@@ -998,6 +998,125 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)return 0 ; } +#define PAGE_INUSE 0xFD + +unsigned long find_and_clear_pte_page (unsigned long addr,unsigned long end, +struct page **pp,int *page_size) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *pte =NULL ; +void *page_addr; +unsigned long next; + + *pp =NULL ; + + pgd =pgd_offset_k (addr); +if (pgd_none (*pgd)) +return pgd_addr_end (addr, end); + + pud =pud_offset (pgd, addr); +if (pud_none (*pud)) +return pud_addr_end (addr, end); + +if (!cpu_has_pse) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + pte =pte_offset_kernel (pmd, addr); +if (pte_none (*pte)) +return next; + + *page_size =PAGE_SIZE ; + *pp =pte_page (*pte); + }else { + next =pmd_addr_end (addr, end); + + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + *page_size =PMD_SIZE ; + *pp =pmd_page (*pmd); + } + +/* +* Removed page structs are filled with 0xFD. +*/ +memset ((void *)addr,PAGE_INUSE , next - addr); + + page_addr =page_address (*pp); + +/* +* Check the page is filled with 0xFD or not. +* memchr_inv() returns the address. In this case, we cannot +* clear PTE/PUD entry, since the page is used by other. +* So we cannot also free the page. +* +* memchr_inv() returns NULL. In this case, we can clear +* PTE/PUD entry, since the page is not used by other. +* So we can also free the page. +*/ +if (memchr_inv (page_addr,PAGE_INUSE , *page_size)) { + *pp =NULL ; +return next; + } + +if (!cpu_has_pse) +pte_clear (&init_mm, addr, pte); +else +pmd_clear (pmd); + +return next; +} + +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + +free_pages ((unsigned long )page_address (page), +get_order (page_size)); +__flush_tlb_one (addr); + } +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; +unsigned long magic; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + + magic = (unsigned long ) page->lru.next; +if (magic ==SECTION_INFO ) +put_page_bootmem (page); +flush_tlb_kernel_range (addr, end); + } +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {include/linux/mm.h +2
-0@@ -1642,6 +1642,8 @@ int vmemmap_populate(struct page *start_page, unsigned long pages, int node);void vmemmap_populate_print_last (void );void register_page_bootmem_memmap (unsigned long section_nr,struct page *map,unsigned long size); +void vmemmap_kfree (struct page *memmpa,unsigned long nr_pages); +void vmemmap_free_bootmem (struct page *memmpa,unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,mm/memory_hotplug.c +2
-15@@ -312,19 +312,6 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static int __remove_section (struct zone *zone,struct mem_section *ms) -{ -int ret = -EINVAL ; - -if (!valid_section (ms)) -return ret; - - ret =unregister_memory_section (ms); - -return ret; -} -#else static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;@@ -341,9 +328,9 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags); - return 0; + +return ret; } -#endif /* * Reasonably generic function for adding memory. It is mm/sparse.c +0
-0@@ -613,12 +613,13 @@ static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid,/* This will make the necessary allocations eventually. */ return sparse_mem_map_populate (pnum, nid); }
mm/sparse.c static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, · line 623
Quoted 10 lines
mm/sparse.c +3
-2-static void __kfree_section_memmap (struct page *memmap,unsigned long nr_pages) +static void __kfree_section_memmap (struct page *page,unsigned long nr_pages) { -return ;/* XXX: Not implemented yet */ +vmemmap_kfree (page, nr_pages); }static void free_map_bootmem (struct page *page,unsigned long nr_pages) { +vmemmap_free_bootmem (page, nr_pages); }
Hi Congyang,
For vmemmap, nr_pages should be PAGES_PER_SECTION for free_map_bootmem(),
which is passed by free_section_usemap(), right?
But now, nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page)) >> PAGE_SHIFT.
--- mm/sparse.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
mm/sparse.c +4 -0
@@ -713,8 +713,12 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)struct page *memmap_page; memmap_page =virt_to_page (memmap); +#ifdef CONFIG_SPARSEMEM_VMEMMAP + nr_pages =PAGES_PER_SECTION ; +#else nr_pages =PAGE_ALIGN (PAGES_PER_SECTION *sizeof (struct page )) >>PAGE_SHIFT ; +#endif free_map_bootmem (memmap_page, nr_pages); }
Signature · 1 line
1.7.6.1
mm/sparse.c static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, · line 625
Quoted 2 lines
mm/sparse.c +0
-0#else static struct page *__kmalloc_section_memmap (unsigned long nr_pages)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 08/12] memory-hotplug: remove memmap of sparse-vmemmap
At 11/27/2012 01:47 PM, Jianguo Wu Wrote:
Quoted 309 lines · Wen Congyang
Quoted 308 lines
From: Yasuaki Ishimatsu <[email protected]>
All pages of virtual mapping in removed memory cannot be freed, since some pages used as PGD/PUD includes not only removed memory but also other memory. So the patch checks whether page can be freed or not.
How to check whether page can be freed or not?
1. When removing memory, the page structs of the revmoved memory are filled with 0FD.
2. All page structs are filled with0xFDon PT/PMD, PT/PMD can be cleared. In this case, the page used as PT/PMD can be freed.Applying patch,
__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis integrated into one. So__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis deleted.Note:
vmemmap_kfree()andvmemmap_free_bootmem()are not implemented for ia64, ppc, s390, and sparc.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- arch/ia64/mm/discontig.c | 8 ++++ arch/powerpc/mm/init_64.c | 8 ++++ arch/s390/mm/vmem.c | 8 ++++ arch/sparc/mm/init_64.c | 8 ++++ arch/x86/mm/init_64.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 2 + mm/memory_hotplug.c | 17 +------ mm/sparse.c | 5 +- 8 files changed, 158 insertions(+), 17 deletions(-)arch/ia64/mm/discontig.c +8
-0@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,return vmemmap_populate_basepages (start_page, size, node); } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/powerpc/mm/init_64.c +8
-0@@ -298,6 +298,14 @@ int __meminit vmemmap_populate(struct page *start_page,return 0 ; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/s390/mm/vmem.c +8
-0@@ -236,6 +236,14 @@ out:return ret; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/sparc/mm/init_64.c +8
-0@@ -2232,6 +2232,14 @@ void __meminit vmemmap_populate_print_last(void) } } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/x86/mm/init_64.c +119
-0@@ -998,6 +998,125 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)return 0 ; } +#define PAGE_INUSE 0xFD + +unsigned long find_and_clear_pte_page (unsigned long addr,unsigned long end, +struct page **pp,int *page_size) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *pte =NULL ; +void *page_addr; +unsigned long next; + + *pp =NULL ; + + pgd =pgd_offset_k (addr); +if (pgd_none (*pgd)) +return pgd_addr_end (addr, end); + + pud =pud_offset (pgd, addr); +if (pud_none (*pud)) +return pud_addr_end (addr, end); + +if (!cpu_has_pse) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + pte =pte_offset_kernel (pmd, addr); +if (pte_none (*pte)) +return next; + + *page_size =PAGE_SIZE ; + *pp =pte_page (*pte); + }else { + next =pmd_addr_end (addr, end); + + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + *page_size =PMD_SIZE ; + *pp =pmd_page (*pmd); + } + +/* +* Removed page structs are filled with 0xFD. +*/ +memset ((void *)addr,PAGE_INUSE , next - addr); + + page_addr =page_address (*pp); + +/* +* Check the page is filled with 0xFD or not. +* memchr_inv() returns the address. In this case, we cannot +* clear PTE/PUD entry, since the page is used by other. +* So we cannot also free the page. +* +* memchr_inv() returns NULL. In this case, we can clear +* PTE/PUD entry, since the page is not used by other. +* So we can also free the page. +*/ +if (memchr_inv (page_addr,PAGE_INUSE , *page_size)) { + *pp =NULL ; +return next; + } + +if (!cpu_has_pse) +pte_clear (&init_mm, addr, pte); +else +pmd_clear (pmd); + +return next; +} + +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + +free_pages ((unsigned long )page_address (page), +get_order (page_size)); +__flush_tlb_one (addr); + } +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; +unsigned long magic; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + + magic = (unsigned long ) page->lru.next; +if (magic =SECTION_INFO ) +put_page_bootmem (page); +flush_tlb_kernel_range (addr, end); + } +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {include/linux/mm.h +2
-0@@ -1642,6 +1642,8 @@ int vmemmap_populate(struct page *start_page, unsigned long pages, int node);void vmemmap_populate_print_last (void );void register_page_bootmem_memmap (unsigned long section_nr,struct page *map,unsigned long size); +void vmemmap_kfree (struct page *memmpa,unsigned long nr_pages); +void vmemmap_free_bootmem (struct page *memmpa,unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,mm/memory_hotplug.c +2
-15@@ -312,19 +312,6 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static int __remove_section (struct zone *zone,struct mem_section *ms) -{ -int ret = -EINVAL ; - -if (!valid_section (ms)) -return ret; - - ret =unregister_memory_section (ms); - -return ret; -} -#else static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;@@ -341,9 +328,9 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags); - return 0; + +return ret; } -#endif /* * Reasonably generic function for adding memory. It is mm/sparse.c +2
-2@@ -613,12 +613,13 @@ static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid,/* This will make the necessary allocations eventually. */ return sparse_mem_map_populate (pnum, nid); } -static void __kfree_section_memmap (struct page *memmap,unsigned long nr_pages) +static void __kfree_section_memmap (struct page *page,unsigned long nr_pages) { -return ;/* XXX: Not implemented yet */ +vmemmap_kfree (page, nr_pages); }
Quoted 8 lines
mm/sparse.c static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, · line 623
Quoted 4 lines
mm/sparse.c +1
-0static void free_map_bootmem (struct page *page,unsigned long nr_pages) { +vmemmap_free_bootmem (page, nr_pages); }Hi Congyang,
For vmemmap,nr_pagesshould bePAGES_PER_SECTIONforfree_map_bootmem(),
which is passed byfree_section_usemap(), right?
Yes, you are right. I will merge it into my patchset.
I will sent the new patchset later today.
Thanks
Wen Congyang
Quoted 24 lines
But now,
nr_pages=PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))>>PAGE_SHIFT.Signed-off-by Jianguo Wu <[email protected]>--- mm/sparse.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)mm/sparse.c +4
-0@@ -713,8 +713,12 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)struct page *memmap_page; memmap_page =virt_to_page (memmap); +#ifdef CONFIG_SPARSEMEM_VMEMMAP + nr_pages =PAGES_PER_SECTION ; +#else nr_pages =PAGE_ALIGN (PAGES_PER_SECTION *sizeof (struct page )) >>PAGE_SHIFT ; +#endif free_map_bootmem (memmap_page, nr_pages); }
Re: [PATCH v3 08/12] memory-hotplug: remove memmap of sparse-vmemmap
In reply to Jianguo WuAt 11/27/2012 01:47 PM, Jianguo Wu Wrote:
Quoted 329 lines · Wen Congyang
Quoted 302 lines
From: Yasuaki Ishimatsu <[email protected]>
All pages of virtual mapping in removed memory cannot be freed, since some pages used as PGD/PUD includes not only removed memory but also other memory. So the patch checks whether page can be freed or not.
How to check whether page can be freed or not?
1. When removing memory, the page structs of the revmoved memory are filled with 0FD.
2. All page structs are filled with0xFDon PT/PMD, PT/PMD can be cleared. In this case, the page used as PT/PMD can be freed.Applying patch,
__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis integrated into one. So__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis deleted.Note:
vmemmap_kfree()andvmemmap_free_bootmem()are not implemented for ia64, ppc, s390, and sparc.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- arch/ia64/mm/discontig.c | 8 ++++ arch/powerpc/mm/init_64.c | 8 ++++ arch/s390/mm/vmem.c | 8 ++++ arch/sparc/mm/init_64.c | 8 ++++ arch/x86/mm/init_64.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 2 + mm/memory_hotplug.c | 17 +------ mm/sparse.c | 5 +- 8 files changed, 158 insertions(+), 17 deletions(-)arch/ia64/mm/discontig.c +8
-0@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,return vmemmap_populate_basepages (start_page, size, node); } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/powerpc/mm/init_64.c +8
-0@@ -298,6 +298,14 @@ int __meminit vmemmap_populate(struct page *start_page,return 0 ; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/s390/mm/vmem.c +8
-0@@ -236,6 +236,14 @@ out:return ret; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/sparc/mm/init_64.c +8
-0@@ -2232,6 +2232,14 @@ void __meminit vmemmap_populate_print_last(void) } } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/x86/mm/init_64.c +119
-0@@ -998,6 +998,125 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)return 0 ; } +#define PAGE_INUSE 0xFD + +unsigned long find_and_clear_pte_page (unsigned long addr,unsigned long end, +struct page **pp,int *page_size) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *pte =NULL ; +void *page_addr; +unsigned long next; + + *pp =NULL ; + + pgd =pgd_offset_k (addr); +if (pgd_none (*pgd)) +return pgd_addr_end (addr, end); + + pud =pud_offset (pgd, addr); +if (pud_none (*pud)) +return pud_addr_end (addr, end); + +if (!cpu_has_pse) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + pte =pte_offset_kernel (pmd, addr); +if (pte_none (*pte)) +return next; + + *page_size =PAGE_SIZE ; + *pp =pte_page (*pte); + }else { + next =pmd_addr_end (addr, end); + + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + *page_size =PMD_SIZE ; + *pp =pmd_page (*pmd); + } + +/* +* Removed page structs are filled with 0xFD. +*/ +memset ((void *)addr,PAGE_INUSE , next - addr); + + page_addr =page_address (*pp); + +/* +* Check the page is filled with 0xFD or not. +* memchr_inv() returns the address. In this case, we cannot +* clear PTE/PUD entry, since the page is used by other. +* So we cannot also free the page. +* +* memchr_inv() returns NULL. In this case, we can clear +* PTE/PUD entry, since the page is not used by other. +* So we can also free the page. +*/ +if (memchr_inv (page_addr,PAGE_INUSE , *page_size)) { + *pp =NULL ; +return next; + } + +if (!cpu_has_pse) +pte_clear (&init_mm, addr, pte); +else +pmd_clear (pmd); + +return next; +} + +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + +free_pages ((unsigned long )page_address (page), +get_order (page_size)); +__flush_tlb_one (addr); + } +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; +unsigned long magic; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + + magic = (unsigned long ) page->lru.next; +if (magic ==SECTION_INFO ) +put_page_bootmem (page); +flush_tlb_kernel_range (addr, end); + } +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {include/linux/mm.h +2
-0@@ -1642,6 +1642,8 @@ int vmemmap_populate(struct page *start_page, unsigned long pages, int node);void vmemmap_populate_print_last (void );void register_page_bootmem_memmap (unsigned long section_nr,struct page *map,unsigned long size); +void vmemmap_kfree (struct page *memmpa,unsigned long nr_pages); +void vmemmap_free_bootmem (struct page *memmpa,unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,mm/memory_hotplug.c +2
-15@@ -312,19 +312,6 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static int __remove_section (struct zone *zone,struct mem_section *ms) -{ -int ret = -EINVAL ; - -if (!valid_section (ms)) -return ret; - - ret =unregister_memory_section (ms); - -return ret; -} -#else static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;@@ -341,9 +328,9 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags); - return 0; + +return ret; } -#endif /* * Reasonably generic function for adding memory. It is mm/sparse.c +0
-0@@ -613,12 +613,13 @@ static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid,/* This will make the necessary allocations eventually. */ return sparse_mem_map_populate (pnum, nid); }mm/sparse.c static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, · line 623
Quoted 10 lines
mm/sparse.c +3
-2-static void __kfree_section_memmap (struct page *memmap,unsigned long nr_pages) +static void __kfree_section_memmap (struct page *page,unsigned long nr_pages) { -return ;/* XXX: Not implemented yet */ +vmemmap_kfree (page, nr_pages); }static void free_map_bootmem (struct page *page,unsigned long nr_pages) { +vmemmap_free_bootmem (page, nr_pages); }Hi Congyang,
For vmemmap,nr_pagesshould bePAGES_PER_SECTIONforfree_map_bootmem(),
which is passed byfree_section_usemap(), right?
But now,nr_pages=PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))>>PAGE_SHIFT.Signed-off-by Jianguo Wu <[email protected]>--- mm/sparse.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)mm/sparse.c +0
-0
mm/sparse.c static void free_section_usemap(struct page *memmap, unsigned long *usemap) · line 721
Quoted 9 lines
mm/sparse.c +4
-0@@ -713,8 +713,12 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)struct page *memmap_page; memmap_page =virt_to_page (memmap); +#ifdef CONFIG_SPARSEMEM_VMEMMAP + nr_pages =PAGES_PER_SECTION ; +#else nr_pages =PAGE_ALIGN (PAGES_PER_SECTION *sizeof (struct page )) >>PAGE_SHIFT ; +#endif
Hmm, to avoid using ifdef, I think we can pass PAGE_PER_SECTION to free_map_bootmem(), and calculate how many pages is used to store struct page.
Thanks
Wen Congyang
mm/sparse.c static void free_section_usemap(struct page *memmap, unsigned long *usemap) · line 724
Quoted 3 lines
mm/sparse.c +0
-0free_map_bootmem (memmap_page, nr_pages); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 08/12] memory-hotplug: remove memmap of sparse-vmemmap
Quoted 333 lines · Wen Congyang
At 11/27/2012 01:47 PM, Jianguo Wu Wrote:
Quoted 332 lines · Wen Congyang
Quoted 302 lines
From: Yasuaki Ishimatsu <[email protected]>
All pages of virtual mapping in removed memory cannot be freed, since some pages used as PGD/PUD includes not only removed memory but also other memory. So the patch checks whether page can be freed or not.
How to check whether page can be freed or not?
1. When removing memory, the page structs of the revmoved memory are filled with 0FD.
2. All page structs are filled with0xFDon PT/PMD, PT/PMD can be cleared. In this case, the page used as PT/PMD can be freed.Applying patch,
__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis integrated into one. So__remove_section()ofCONFIG_SPARSEMEM_VMEMMAPis deleted.Note:
vmemmap_kfree()andvmemmap_free_bootmem()are not implemented for ia64, ppc, s390, and sparc.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Wen Congyang <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>--- arch/ia64/mm/discontig.c | 8 ++++ arch/powerpc/mm/init_64.c | 8 ++++ arch/s390/mm/vmem.c | 8 ++++ arch/sparc/mm/init_64.c | 8 ++++ arch/x86/mm/init_64.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 2 + mm/memory_hotplug.c | 17 +------ mm/sparse.c | 5 +- 8 files changed, 158 insertions(+), 17 deletions(-)arch/ia64/mm/discontig.c +8
-0@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,return vmemmap_populate_basepages (start_page, size, node); } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/powerpc/mm/init_64.c +8
-0@@ -298,6 +298,14 @@ int __meminit vmemmap_populate(struct page *start_page,return 0 ; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/s390/mm/vmem.c +8
-0@@ -236,6 +236,14 @@ out:return ret; } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/sparc/mm/init_64.c +8
-0@@ -2232,6 +2232,14 @@ void __meminit vmemmap_populate_print_last(void) } } +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {arch/x86/mm/init_64.c +119
-0@@ -998,6 +998,125 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)return 0 ; } +#define PAGE_INUSE 0xFD + +unsigned long find_and_clear_pte_page (unsigned long addr,unsigned long end, +struct page **pp,int *page_size) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *pte =NULL ; +void *page_addr; +unsigned long next; + + *pp =NULL ; + + pgd =pgd_offset_k (addr); +if (pgd_none (*pgd)) +return pgd_addr_end (addr, end); + + pud =pud_offset (pgd, addr); +if (pud_none (*pud)) +return pud_addr_end (addr, end); + +if (!cpu_has_pse) { + next = (addr +PAGE_SIZE ) &PAGE_MASK ; + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + pte =pte_offset_kernel (pmd, addr); +if (pte_none (*pte)) +return next; + + *page_size =PAGE_SIZE ; + *pp =pte_page (*pte); + }else { + next =pmd_addr_end (addr, end); + + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return next; + + *page_size =PMD_SIZE ; + *pp =pmd_page (*pmd); + } + +/* +* Removed page structs are filled with 0xFD. +*/ +memset ((void *)addr,PAGE_INUSE , next - addr); + + page_addr =page_address (*pp); + +/* +* Check the page is filled with 0xFD or not. +* memchr_inv() returns the address. In this case, we cannot +* clear PTE/PUD entry, since the page is used by other. +* So we cannot also free the page. +* +* memchr_inv() returns NULL. In this case, we can clear +* PTE/PUD entry, since the page is not used by other. +* So we can also free the page. +*/ +if (memchr_inv (page_addr,PAGE_INUSE , *page_size)) { + *pp =NULL ; +return next; + } + +if (!cpu_has_pse) +pte_clear (&init_mm, addr, pte); +else +pmd_clear (pmd); + +return next; +} + +void vmemmap_kfree (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + +free_pages ((unsigned long )page_address (page), +get_order (page_size)); +__flush_tlb_one (addr); + } +} + +void vmemmap_free_bootmem (struct page *memmap,unsigned long nr_pages) +{ +unsigned long addr = (unsigned long )memmap; +unsigned long end = (unsigned long )(memmap + nr_pages); +unsigned long next; +struct page *page; +int page_size; +unsigned long magic; + +for (; addr < end; addr = next) { + page =NULL ; + page_size =0 ; + next =find_and_clear_pte_page (addr, end, &page, &page_size); +if (!page) +continue ; + + magic = (unsigned long ) page->lru.next; +if (magic =SECTION_INFO ) +put_page_bootmem (page); +flush_tlb_kernel_range (addr, end); + } +} +void register_page_bootmem_memmap (unsigned long section_nr,struct page *start_page,unsigned long size) {include/linux/mm.h +2
-0@@ -1642,6 +1642,8 @@ int vmemmap_populate(struct page *start_page, unsigned long pages, int node);void vmemmap_populate_print_last (void );void register_page_bootmem_memmap (unsigned long section_nr,struct page *map,unsigned long size); +void vmemmap_kfree (struct page *memmpa,unsigned long nr_pages); +void vmemmap_free_bootmem (struct page *memmpa,unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,mm/memory_hotplug.c +2
-15@@ -312,19 +312,6 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -static int __remove_section (struct zone *zone,struct mem_section *ms) -{ -int ret = -EINVAL ; - -if (!valid_section (ms)) -return ret; - - ret =unregister_memory_section (ms); - -return ret; -} -#else static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;@@ -341,9 +328,9 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags); - return 0; + +return ret; } -#endif /* * Reasonably generic function for adding memory. It is mm/sparse.c +0
-0@@ -613,12 +613,13 @@ static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid,/* This will make the necessary allocations eventually. */ return sparse_mem_map_populate (pnum, nid); }mm/sparse.c static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, · line 623
Quoted 10 lines
mm/sparse.c +3
-2-static void __kfree_section_memmap (struct page *memmap,unsigned long nr_pages) +static void __kfree_section_memmap (struct page *page,unsigned long nr_pages) { -return ;/* XXX: Not implemented yet */ +vmemmap_kfree (page, nr_pages); }static void free_map_bootmem (struct page *page,unsigned long nr_pages) { +vmemmap_free_bootmem (page, nr_pages); }Hi Congyang,
For vmemmap,nr_pagesshould bePAGES_PER_SECTIONforfree_map_bootmem(),
which is passed byfree_section_usemap(), right?
But now,nr_pages=PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))>>PAGE_SHIFT.Signed-off-by Jianguo Wu <[email protected]>--- mm/sparse.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)mm/sparse.c +0
-0@@ -713,8 +713,12 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)struct page *memmap_page; memmap_page =virt_to_page (memmap);
Quoted 10 lines
mm/sparse.c static void free_section_usemap(struct page *memmap, unsigned long *usemap) · line 721
Quoted 6 lines
mm/sparse.c +4
-0+#ifdef CONFIG_SPARSEMEM_VMEMMAP + nr_pages =PAGES_PER_SECTION ; +#else nr_pages =PAGE_ALIGN (PAGES_PER_SECTION *sizeof (struct page )) >>PAGE_SHIFT ; +#endif Hmm, to avoid using ifdef, I think we can pass
PAGE_PER_SECTIONtofree_map_bootmem(), and calculate how many pages is used to store struct page.
yes, it is ugly to use ifdef. Or we can remove parameter--nr_pages of free_map_bootmem(), and calculate nr_pages in free_map_bootmem() directly.
Quoted 10 lines
Thanks
Wen Congyangmm/sparse.c static void free_section_usemap(struct page *memmap, unsigned long *usemap) · line 724
Quoted 3 lines
mm/sparse.c +0
-0free_map_bootmem (memmap_page, nr_pages); }.
PATCH v3 9/12 memory-hotplug: remove page table of x86_64 architecture
In reply to Wen CongyangFor hot removing memory, we sholud remove page table about the memory. So the patch searches a page table about the removed memory, and clear page table.
--- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/init_64.c | 231 +++++++++++++++++++++++++++++++++++ arch/x86/mm/pageattr.c | 47 +++---- 3 files changed, 257 insertions(+), 22 deletions(-)
arch/x86/include/asm/pgtable_types.h +1 -0
@@ -332,6 +332,7 @@ static inline void update_page_count(int level, unsigned long pages) { }* as a pte too. */ extern pte_t *lookup_address (unsigned long address,unsigned int *level); +extern int __split_large_page (pte_t *kpte,unsigned long address,pte_t *pbase);#endif /* !__ASSEMBLY__ */
arch/x86/mm/init_64.c +231 -0
243 lines not on this page · raw message
arch/x86/mm/pageattr.c +25 -22
73 lines not on this page · raw message
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 10/12 memory-hotplug: memory_hotplug: clear zone when removing the memory
In reply to Wen CongyangFrom: Yasuaki Ishimatsu <[email protected]>
When a memory is added, we update zone's and pgdat's start_pfn and spanned_pages in the function __add_zone(). So we should revert them when the memory is removed.
The patch adds a new function __remove_zone() to do this.
--- mm/memory_hotplug.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+)
mm/memory_hotplug.c +207 -0
@@ -312,10 +312,213 @@ static int __meminit __add_section(int nid, struct zone *zone,return register_new_memory (nid,__pfn_to_section (phys_start_pfn)); } +/* find the smallest valid pfn in the range [start_pfn, end_pfn) */ +static int find_smallest_section_pfn (int nid,struct zone *zone, +unsigned long start_pfn, +unsigned long end_pfn) +{ +struct mem_section *ms; + +for (; start_pfn < end_pfn; start_pfn +=PAGES_PER_SECTION ) { + ms =__pfn_to_section (start_pfn); + +if (unlikely (!valid_section (ms))) +continue ; + +if (unlikely (pfn_to_nid (start_pfn) != nid)) +continue ; + +if (zone && zone !=page_zone (pfn_to_page (start_pfn))) +continue ; + +return start_pfn; + } + +return 0 ; +} + +/* find the biggest valid pfn in the range [start_pfn, end_pfn). */ +static int find_biggest_section_pfn (int nid,struct zone *zone, +unsigned long start_pfn, +unsigned long end_pfn) +{ +struct mem_section *ms; +unsigned long pfn; + +/* pfn is the end pfn of a memory section. */ + pfn = end_pfn -1 ; +for (; pfn >= start_pfn; pfn -=PAGES_PER_SECTION ) { + ms =__pfn_to_section (pfn); + +if (unlikely (!valid_section (ms))) +continue ; + +if (unlikely (pfn_to_nid (pfn) != nid)) +continue ; + +if (zone && zone !=page_zone (pfn_to_page (pfn))) +continue ; + +return pfn; + } + +return 0 ; +} + +static void shrink_zone_span (struct zone *zone,unsigned long start_pfn, +unsigned long end_pfn) +{ +unsigned long zone_start_pfn = zone->zone_start_pfn; +unsigned long zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages; +unsigned long pfn; +struct mem_section *ms; +int nid =zone_to_nid (zone); + +zone_span_writelock (zone); +if (zone_start_pfn == start_pfn) { +/* +* If the section is smallest section in the zone, it need +* shrink zone->zone_start_pfn and zone->zone_spanned_pages. +* In this case, we find second smallest valid mem_section +* for shrinking zone. +*/ + pfn =find_smallest_section_pfn (nid, zone, end_pfn, + zone_end_pfn); +if (pfn) { + zone->zone_start_pfn = pfn; + zone->spanned_pages = zone_end_pfn - pfn; + } + }else if (zone_end_pfn == end_pfn) { +/* +* If the section is biggest section in the zone, it need +* shrink zone->spanned_pages. +* In this case, we find second biggest valid mem_section for +* shrinking zone. +*/ + pfn =find_biggest_section_pfn (nid, zone, zone_start_pfn, + start_pfn); +if (pfn) + zone->spanned_pages = pfn - zone_start_pfn +1 ; + } + +/* +* The section is not biggest or smallest mem_section in the zone, it +* only creates a hole in the zone. So in this case, we need not +* change the zone. But perhaps, the zone has only hole data. Thus +* it check the zone has only hole or not. +*/ + pfn = zone_start_pfn; +for (; pfn < zone_end_pfn; pfn +=PAGES_PER_SECTION ) { + ms =__pfn_to_section (pfn); + +if (unlikely (!valid_section (ms))) +continue ; + +if (page_zone (pfn_to_page (pfn)) != zone) +continue ; + +/* If the section is current section, it continues the loop */ +if (start_pfn == pfn) +continue ; + +/* If we find valid section, we have nothing to do */ +zone_span_writeunlock (zone); +return ; + } + +/* The zone has no valid section */ + zone->zone_start_pfn =0 ; + zone->spanned_pages =0 ; +zone_span_writeunlock (zone); +} + +static void shrink_pgdat_span (struct pglist_data *pgdat, +unsigned long start_pfn,unsigned long end_pfn) +{ +unsigned long pgdat_start_pfn = pgdat->node_start_pfn; +unsigned long pgdat_end_pfn = + pgdat->node_start_pfn + pgdat->node_spanned_pages; +unsigned long pfn; +struct mem_section *ms; +int nid = pgdat->node_id; + +if (pgdat_start_pfn == start_pfn) { +/* +* If the section is smallest section in the pgdat, it need +* shrink pgdat->node_start_pfn and pgdat->node_spanned_pages. +* In this case, we find second smallest valid mem_section +* for shrinking zone. +*/ + pfn =find_smallest_section_pfn (nid,NULL , end_pfn, + pgdat_end_pfn); +if (pfn) { + pgdat->node_start_pfn = pfn; + pgdat->node_spanned_pages = pgdat_end_pfn - pfn; + } + }else if (pgdat_end_pfn == end_pfn) { +/* +* If the section is biggest section in the pgdat, it need +* shrink pgdat->node_spanned_pages. +* In this case, we find second biggest valid mem_section for +* shrinking zone. +*/ + pfn =find_biggest_section_pfn (nid,NULL , pgdat_start_pfn, + start_pfn); +if (pfn) + pgdat->node_spanned_pages = pfn - pgdat_start_pfn +1 ; + } + +/* +* If the section is not biggest or smallest mem_section in the pgdat, +* it only creates a hole in the pgdat. So in this case, we need not +* change the pgdat. +* But perhaps, the pgdat has only hole data. Thus it check the pgdat +* has only hole or not. +*/ + pfn = pgdat_start_pfn; +for (; pfn < pgdat_end_pfn; pfn +=PAGES_PER_SECTION ) { + ms =__pfn_to_section (pfn); + +if (unlikely (!valid_section (ms))) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ; + +/* If the section is current section, it continues the loop */ +if (start_pfn == pfn) +continue ; + +/* If we find valid section, we have nothing to do */ +return ; + } + +/* The pgdat has no valid section */ + pgdat->node_start_pfn =0 ; + pgdat->node_spanned_pages =0 ; +} + +static void __remove_zone (struct zone *zone,unsigned long start_pfn) +{ +struct pglist_data *pgdat = zone->zone_pgdat; +int nr_pages =PAGES_PER_SECTION ; +int zone_type; +unsigned long flags; + + zone_type = zone - pgdat->node_zones; + +pgdat_resize_lock (zone->zone_pgdat, &flags); +shrink_zone_span (zone, start_pfn, start_pfn + nr_pages); +shrink_pgdat_span (pgdat, start_pfn, start_pfn + nr_pages); +pgdat_resize_unlock (zone->zone_pgdat, &flags); +} +static int __remove_section (struct zone *zone,struct mem_section *ms) {unsigned long flags;struct pglist_data *pgdat = zone->zone_pgdat; +unsigned long start_pfn; +int scn_nr;int ret = -EINVAL ;if (!valid_section (ms))
@@ -325,6 +528,10 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)if (ret)return ret; + scn_nr =__section_nr (ms); + start_pfn =section_nr_to_pfn (scn_nr); +__remove_zone (zone, start_pfn); +pgdat_resize_lock (pgdat, &flags);sparse_remove_one_section (zone, ms);pgdat_resize_unlock (pgdat, &flags);
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 11/12 memory-hotplug: remove sysfs file of node
In reply to Wen CongyangThis patch introduces a new function try_offline_node() to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.
--- drivers/acpi/acpi_memhotplug.c | 8 +++++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 58 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-)
drivers/acpi/acpi_memhotplug.c +7 -1
@@ -310,7 +310,9 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; +int node; + node =acpi_get_node (mem_device->device->handle);/* * Ask the VM to offline this memory range.
@@ -318,7 +320,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result; }
include/linux/memory_hotplug.h +1 -1
@@ -231,7 +231,7 @@ extern int arch_add_memory(int nid, u64 start, u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);
mm/memory_hotplug.c +56 -2
82 lines not on this page · raw message
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 11/12] memory-hotplug: remove sysfs file of node
Hi Wen,
This patch cannot be applied, if I apply latest acpi framework's patch-set:
https://lkml.org/lkml/2012/11/15/21
Because acpi_memory_disable_device() is gone by the patch-set.
I updated the patch and attached it on the mail.
Quoted 143 lines · Wen Congyang
This patch introduces a new function
try_offline_node()to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 8 +++++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 58 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-)drivers/acpi/acpi_memhotplug.c +7
-1@@ -310,7 +310,9 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; +int node; + node =acpi_get_node (mem_device->device->handle);/* * Ask the VM to offline this memory range. @@ -318,7 +320,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result; }include/linux/memory_hotplug.h +1
-1@@ -231,7 +231,7 @@ extern int arch_add_memory(int nid, u64 start, u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);mm/memory_hotplug.c +55
-1@@ -29,6 +29,7 @@#include <linux/suspend.h> #include <linux/mm_inline.h> #include <linux/firmware-map.h> +#include <linux/stop_machine.h> #include <asm/tlbflush.h> @@ -1299,7 +1300,58 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)return ret; } -int __ref remove_memory (u64 start,u64 size) +static int check_cpu_on_node (void *data) +{ +struct pglist_data *pgdat = data; +int cpu; + +for_each_present_cpu (cpu) { +if (cpu_to_node (cpu) == pgdat->node_id) +/* +* the cpu on this node isn't removed, and we can't +* offline this node. +*/ +return -EBUSY ; + } + +return 0 ; +} + +/* offline the node if all memory sections of this node are removed */ +static void try_offline_node (int nid) +{ +unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; +unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long pfn; + +for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { +unsigned long section_nr =pfn_to_section_nr (pfn); + +if (!present_section_nr (section_nr)) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ; + +/* +* some memory sections of this node are not removed, and we +* can't offline node now. +*/ +return ; + } + +if (stop_machine (check_cpu_on_node,NODE_DATA (nid),NULL )) +return ; + +/* +* all memory/cpu of this node are removed, we can offline this +* node now. +*/ +node_set_offline (nid); +unregister_one_node (nid); +} + +int __ref remove_memory (int nid,u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;@@ -1346,6 +1398,8 @@ repeat:arch_remove_memory (start, size); +try_offline_node (nid); +unlock_memory_hotplug ();return 0 ;
mm/memory_hotplug.c int offline_pages(unsigned long start_pfn, unsigned long nr_pages) · line 1415
Quoted 8 lines
mm/memory_hotplug.c +1
-1@@ -1355,7 +1409,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) {return -EINVAL ; } -int remove_memory (u64 start,u64 size) +int remove_memory (int nid,u64 start,u64 size) {return -EINVAL ; }
---
This patch introduces a new function try_offline_node() to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.
--- drivers/acpi/acpi_memhotplug.c | 9 +++++- include/linux/memory_hotplug.h | 2 - mm/memory_hotplug.c | 58 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 4 deletions(-)
drivers/acpi/acpi_memhotplug.c +8 -1
@@ -295,6 +295,9 @@ static int acpi_memory_remove_memory(str {int result =0 ;struct acpi_memory_info *info, *n; +int node; + + node =acpi_get_node (mem_device->device->handle);list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->failed)
@@ -308,7 +311,11 @@ static int acpi_memory_remove_memory(str*/ return -EBUSY ; - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result;
include/linux/memory_hotplug.h +1 -1
@@ -242,7 +242,7 @@ extern int arch_add_memory(int nid, u64extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);
mm/memory_hotplug.c +56 -2
82 lines not on this page · raw message
Re: [PATCH v3 11/12] memory-hotplug: remove sysfs file of node
At 11/19/2012 06:08 PM, Yasuaki Ishimatsu Wrote:
Quoted 7 lines
Hi Wen,
This patch cannot be applied, if I apply latest acpi framework's patch-set:
https://lkml.org/lkml/2012/11/15/21
Because
acpi_memory_disable_device()is gone by the patch-set.
The patchset is not for pm tree, so I don't apply the patchset in pm tree before generating this patchset.
Thanks
Wen Congyang
Quoted 301 lines
I updated the patch and attached it on the mail.
Quoted 143 lines · Wen Congyang
This patch introduces a new function
try_offline_node()to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 8 +++++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 58 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-)drivers/acpi/acpi_memhotplug.c +7
-1@@ -310,7 +310,9 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; +int node; + node =acpi_get_node (mem_device->device->handle);/* * Ask the VM to offline this memory range. @@ -318,7 +320,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result; }include/linux/memory_hotplug.h +1
-1@@ -231,7 +231,7 @@ extern int arch_add_memory(int nid, u64 start, u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);mm/memory_hotplug.c +55
-1@@ -29,6 +29,7 @@#include <linux/suspend.h> #include <linux/mm_inline.h> #include <linux/firmware-map.h> +#include <linux/stop_machine.h> #include <asm/tlbflush.h> @@ -1299,7 +1300,58 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)return ret; } -int __ref remove_memory (u64 start,u64 size) +static int check_cpu_on_node (void *data) +{ +struct pglist_data *pgdat = data; +int cpu; + +for_each_present_cpu (cpu) { +if (cpu_to_node (cpu) == pgdat->node_id) +/* +* the cpu on this node isn't removed, and we can't +* offline this node. +*/ +return -EBUSY ; + } + +return 0 ; +} + +/* offline the node if all memory sections of this node are removed */ +static void try_offline_node (int nid) +{ +unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; +unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long pfn; + +for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { +unsigned long section_nr =pfn_to_section_nr (pfn); + +if (!present_section_nr (section_nr)) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ; + +/* +* some memory sections of this node are not removed, and we +* can't offline node now. +*/ +return ; + } + +if (stop_machine (check_cpu_on_node,NODE_DATA (nid),NULL )) +return ; + +/* +* all memory/cpu of this node are removed, we can offline this +* node now. +*/ +node_set_offline (nid); +unregister_one_node (nid); +} + +int __ref remove_memory (int nid,u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;@@ -1346,6 +1398,8 @@ repeat:arch_remove_memory (start, size); +try_offline_node (nid); +unlock_memory_hotplug ();return 0 ;mm/memory_hotplug.c int offline_pages(unsigned long start_pfn, unsigned long nr_pages) · line 1415
Quoted 8 lines
mm/memory_hotplug.c +1
-1@@ -1355,7 +1409,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) {return -EINVAL ; } -int remove_memory (u64 start,u64 size) +int remove_memory (int nid,u64 start,u64 size) {return -EINVAL ; }---
This patch introduces a new functiontry_offline_node()to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 9 +++++- include/linux/memory_hotplug.h | 2 - mm/memory_hotplug.c | 58 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 4 deletions(-)Index:
linux-3.7-rc6/drivers/acpi/acpi_memhotplug.c
===================================================================drivers/acpi/acpi_memhotplug.c +8
-1@@ -295,6 +295,9 @@ static int acpi_memory_remove_memory(str {int result =0 ;struct acpi_memory_info *info, *n; +int node; + + node =acpi_get_node (mem_device->device->handle);list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->failed)@@ -308,7 +311,11 @@ static int acpi_memory_remove_memory(str*/ return -EBUSY ; - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result;Index:
linux-3.7-rc6/include/linux/memory_hotplug.h
===================================================================include/linux/memory_hotplug.h +1
-1@@ -242,7 +242,7 @@ extern int arch_add_memory(int nid, u64extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);Index:
linux-3.7-rc6/mm/memory_hotplug.c
===================================================================mm/memory_hotplug.c +55
-1@@ -29,6 +29,7 @@#include <linux/suspend.h> #include <linux/mm_inline.h> #include <linux/firmware-map.h> +#include <linux/stop_machine.h> #include <asm/tlbflush.h> @@ -1652,7 +1653,58 @@ static int is_memblock_offlined_cb(strucreturn ret; } -int __ref remove_memory (u64 start,u64 size) +static int check_cpu_on_node (void *data) +{ +struct pglist_data *pgdat = data; +int cpu; + +for_each_present_cpu (cpu) { +if (cpu_to_node (cpu) == pgdat->node_id) +/* +* the cpu on this node isn't removed, and we can't +* offline this node. +*/ +return -EBUSY ; + } + +return 0 ; +} + +/* offline the node if all memory sections of this node are removed */ +static void try_offline_node (int nid) +{ +unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; +unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long pfn; + +for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { +unsigned long section_nr =pfn_to_section_nr (pfn); + +if (!present_section_nr (section_nr)) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ; + +/* +* some memory sections of this node are not removed, and we +* can't offline node now. +*/ +return ; + } + +if (stop_machine (check_cpu_on_node,NODE_DATA (nid),NULL )) +return ; + +/* +* all memory/cpu of this node are removed, we can offline this +* node now. +*/ +node_set_offline (nid); +unregister_one_node (nid); +} + +int __ref remove_memory (int nid,u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;@@ -1699,6 +1751,8 @@ repeat:arch_remove_memory (start, size); +try_offline_node (nid); +unlock_memory_hotplug ();return 0 ;
mm/memory_hotplug.c int offline_pages(unsigned long start_pf · line 1768
Quoted 8 lines
mm/memory_hotplug.c +1
-1@@ -1708,7 +1762,7 @@ int offline_pages(unsigned long start_pf {return -EINVAL ; } -int remove_memory (u64 start,u64 size) +int remove_memory (int nid,u64 start,u64 size) {return -EINVAL ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 11/12] memory-hotplug: remove sysfs file of node
In reply to Wen CongyangQuoted 109 lines · Wen Congyang
This patch introduces a new function
try_offline_node()to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 8 +++++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 58 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-)drivers/acpi/acpi_memhotplug.c +7
-1@@ -310,7 +310,9 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; +int node; + node =acpi_get_node (mem_device->device->handle);/* * Ask the VM to offline this memory range. @@ -318,7 +320,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result; }include/linux/memory_hotplug.h +1
-1@@ -231,7 +231,7 @@ extern int arch_add_memory(int nid, u64 start, u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);mm/memory_hotplug.c +33
-1@@ -29,6 +29,7 @@#include <linux/suspend.h> #include <linux/mm_inline.h> #include <linux/firmware-map.h> +#include <linux/stop_machine.h> #include <asm/tlbflush.h> @@ -1299,7 +1300,58 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)return ret; } -int __ref remove_memory (u64 start,u64 size) +static int check_cpu_on_node (void *data) +{ +struct pglist_data *pgdat = data; +int cpu; + +for_each_present_cpu (cpu) { +if (cpu_to_node (cpu) == pgdat->node_id) +/* +* the cpu on this node isn't removed, and we can't +* offline this node. +*/ +return -EBUSY ; + } + +return 0 ; +} + +/* offline the node if all memory sections of this node are removed */ +static void try_offline_node (int nid) +{ +unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; +unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long pfn; + +for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { +unsigned long section_nr =pfn_to_section_nr (pfn); + +if (!present_section_nr (section_nr)) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ;
mm/memory_hotplug.c static int is_memblock_offlined_cb(struct memory_block *mem, void *arg) · line 1344
Quoted 10 lines
mm/memory_hotplug.c +10
-0+ +/* +* some memory sections of this node are not removed, and we +* can't offline node now. +*/ +return ; + } + +if (stop_machine (check_cpu_on_node,NODE_DATA (nid),NULL )) +return ;
how about:
if (nr_cpus_node(nid)) return;
Quoted 32 lines
mm/memory_hotplug.c +13
-1+ +/* +* all memory/cpu of this node are removed, we can offline this +* node now. +*/ +node_set_offline (nid); +unregister_one_node (nid); +} + +int __ref remove_memory (int nid,u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;@@ -1346,6 +1398,8 @@ repeat:arch_remove_memory (start, size); +try_offline_node (nid); +unlock_memory_hotplug ();return 0 ;@@ -1355,7 +1409,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) {return -EINVAL ; } -int remove_memory (u64 start,u64 size) +int remove_memory (int nid,u64 start,u64 size) {return -EINVAL ; }
Re: [PATCH v3 11/12] memory-hotplug: remove sysfs file of node
At 11/26/2012 10:27 PM, Jianguo Wu Wrote:
Quoted 122 lines · Wen Congyang
Quoted 109 lines
This patch introduces a new function
try_offline_node()to remove sysfs file of node when all memory sections of this node are removed. If some memory sections of this node are not removed, this function does nothing.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 8 +++++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 58 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-)drivers/acpi/acpi_memhotplug.c +7
-1@@ -310,7 +310,9 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; +int node; + node =acpi_get_node (mem_device->device->handle);/* * Ask the VM to offline this memory range. @@ -318,7 +320,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { - result =remove_memory (info->start_addr, info->length); +if (node <0 ) + node =memory_add_physaddr_to_nid ( + info->start_addr); + result =remove_memory (node, info->start_addr, + info->length);if (result)return result; }include/linux/memory_hotplug.h +1
-1@@ -231,7 +231,7 @@ extern int arch_add_memory(int nid, u64 start, u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages);extern int offline_memory_block (struct memory_block *mem);extern bool is_memblock_offlined (struct memory_block *mem); -extern int remove_memory (u64 start,u64 size); +extern int remove_memory (int node,u64 start,u64 size);extern int sparse_add_one_section (struct zone *zone,unsigned long start_pfn,int nr_pages);extern void sparse_remove_one_section (struct zone *zone,struct mem_section *ms);mm/memory_hotplug.c +33
-1@@ -29,6 +29,7 @@#include <linux/suspend.h> #include <linux/mm_inline.h> #include <linux/firmware-map.h> +#include <linux/stop_machine.h> #include <asm/tlbflush.h> @@ -1299,7 +1300,58 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)return ret; } -int __ref remove_memory (u64 start,u64 size) +static int check_cpu_on_node (void *data) +{ +struct pglist_data *pgdat = data; +int cpu; + +for_each_present_cpu (cpu) { +if (cpu_to_node (cpu) == pgdat->node_id) +/* +* the cpu on this node isn't removed, and we can't +* offline this node. +*/ +return -EBUSY ; + } + +return 0 ; +} + +/* offline the node if all memory sections of this node are removed */ +static void try_offline_node (int nid) +{ +unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; +unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long pfn; + +for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) { +unsigned long section_nr =pfn_to_section_nr (pfn); + +if (!present_section_nr (section_nr)) +continue ; + +if (pfn_to_nid (pfn) != nid) +continue ;mm/memory_hotplug.c static int is_memblock_offlined_cb(struct memory_block *mem, void *arg) · line 1344
Quoted 10 lines
mm/memory_hotplug.c +10
-0+ +/* +* some memory sections of this node are not removed, and we +* can't offline node now. +*/ +return ; + } + +if (stop_machine (check_cpu_on_node,NODE_DATA (nid),NULL )) +return ;how about:
Quoted 1 line
if (nr_cpus_node(nid))
If all cpus on the node is offlined, but not removed, nr_cpus_node(nid) will return 0. In this case, we still can't offline the node.
Another purpose to use stop_machine() is to prevent cpu hotplug. We can't lock cpuhotplug here.
Thanks
Wen Congyang
Quoted 22 lines
return;Quoted 21 lines
mm/memory_hotplug.c +12
-0+ +/* +* all memory/cpu of this node are removed, we can offline this +* node now. +*/ +node_set_offline (nid); +unregister_one_node (nid); +} + +int __ref remove_memory (int nid,u64 start,u64 size) {unsigned long start_pfn, end_pfn;int ret =0 ;@@ -1346,6 +1398,8 @@ repeat:arch_remove_memory (start, size); +try_offline_node (nid); +unlock_memory_hotplug ();
Quoted 13 lines
mm/memory_hotplug.c int offline_pages(unsigned long start_pfn, unsigned long nr_pages) · line 1415
Quoted 11 lines
mm/memory_hotplug.c +1
-1return 0 ;@@ -1355,7 +1409,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) {return -EINVAL ; } -int remove_memory (u64 start,u64 size) +int remove_memory (int nid,u64 start,u64 size) {return -EINVAL ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 12/12 memory-hotplug: free node_data when a node is offlined
In reply to Wen CongyangWe call hotadd_new_pgdat() to allocate memory to store node_data. So we should free it when removing a node.
--- mm/memory_hotplug.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +19 -1
@@ -1320,9 +1320,12 @@ static int check_cpu_on_node(void *data)/* offline the node if all memory sections of this node are removed */ static void try_offline_node (int nid) { +pg_data_t *pgdat =NODE_DATA (nid);unsigned long start_pfn =NODE_DATA (nid)->node_start_pfn; -unsigned long end_pfn = start_pfn +NODE_DATA (nid)->node_spanned_pages; +unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;unsigned long pfn; +struct page *pgdat_page =virt_to_page (pgdat); +int i;for (pfn = start_pfn; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) {unsigned long section_nr =pfn_to_section_nr (pfn);
@@ -1349,6 +1352,21 @@ static void try_offline_node(int nid)*/ node_set_offline (nid);unregister_one_node (nid); + +if (!PageSlab (pgdat_page) && !PageCompound (pgdat_page)) +/* node data is allocated from boot memory */ +return ; + +/* free waittable in each zone */ +for (i =0 ; i <MAX_NR_ZONES ; i++) { +struct zone *zone = pgdat->node_zones + i; + +if (zone->wait_table) +vfree (zone->wait_table); + } + +arch_refresh_nodedata (nid,NULL ); +arch_free_nodedata (pgdat); }int __ref remove_memory (int nid,u64 start,u64 size)
Signature · 7 lines
1.8.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Ping
At 11/01/2012 05:44 PM, Wen Congyang Wrote:
Quoted 105 lines
The patch-set was divided from following thread's patch-set.
https://lkml.org/lkml/2012/9/5/201The last version of this patchset:
https://lkml.org/lkml/2012/10/23/213If you want to know the reason, please read following thread.
https://lkml.org/lkml/2012/10/2/83
The patch-set has only the function of kernel core side for physical memory hot remove. So if you use the patch, please apply following patches.
- bug fix for memory hot remove
https://lkml.org/lkml/2012/10/31/269- acpi framework
https://lkml.org/lkml/2012/10/26/175The patches can free/remove the following things:
-
/sys/firmware/memmap/X/{end, start, type} : [PATCH 2/10]- mem_section and related sysfs files : [PATCH 3-4/10] - memmap of sparse-vmemmap : [PATCH 5-7/10] - page table of removed memory : [RFC PATCH 8/10] - node and related sysfs files : [RFC PATCH 9-10/10]* [PATCH 2/10] checks whether the memory can be removed or not.
If you find lack of function for physical memory hot-remove, please let me know.
How to test this patchset?
1. apply this patchset and build the kernel.MEMORY_HOTPLUG,MEMORY_HOTREMOVE,ACPI_HOTPLUG_MEMORYmust be selected.
2. load the moduleacpi_memhotplug
3. hotplug the memory device(it depends on your hardware)
You will see the memory device under the directory/sys/bus/acpi/devices/. Its name is PNP0C80:XX.
4. online/offline pages provided by this memory device
You can write online/offline to/sys/devices/system/memory/memoryX/stateto online/offline pages provided by this memory device
5. hotremove the memory device
You can hotremove the memory device by the hardware, or writing 1 to /sys/bus/acpi/devices/PNP0C80:XX/eject.Note: if the memory provided by the memory device is used by the kernel, it can't be offlined. It is not a bug.
Known problems:
1. hotremoving memory device may cause kernel panicked This bug will be fixed by Liu Jiang's patch:https://lkml.org/lkml/2012/7/3/1Changelogs from v2 to v3:
Patch9: callsync_global_pgds()if pgd is changed
Patch10: fix a problem int the patchChangelogs from v1 to v2:
Patch1: new patch, offline memory twice. 1st iterate: offline every non primary
memory block. 2nd iterate: offline primary (i.e. first added) memory block.Patch3: new patch, no logical change, just remove reduntant codes.
Patch9: merge the patch from wujianguo into this patch. flush tlb on all cpu
after the pagetable is changed.Patch12: new patch, free
node_datawhen a node is offlinedWen Congyang (6):
memory-hotplug: try to offline the memory twice to avoid dependence
memory-hotplug: remove redundant codes
memory-hotplug: introduce new functionarch_remove_memory()for
removing page table depends on architecture
memory-hotplug: remove page table ofx86_64architecture
memory-hotplug: remove sysfs file of node
memory-hotplug: freenode_datawhen a node is offlinedYasuaki Ishimatsu (6):
memory-hotplug: check whether all memory blocks are offlined or not
when removing memory
memory-hotplug: remove/sys/firmware/memmap/Xsysfs
memory-hotplug: unregister memory section onSPARSEMEM_VMEMMAP
memory-hotplug: implementregister_page_bootmem_info_sectionof
sparse-vmemmap
memory-hotplug: remove memmap of sparse-vmemmap
memory-hotplug:memory_hotplug: clear zone when removing the memoryarch/ia64/mm/discontig.c | 14 ++ arch/ia64/mm/init.c | 18 ++ arch/powerpc/mm/init_64.c | 14 ++ arch/powerpc/mm/mem.c | 12 + arch/s390/mm/init.c | 12 + arch/s390/mm/vmem.c | 14 ++ arch/sh/mm/init.c | 17 ++ arch/sparc/mm/init_64.c | 14 ++ arch/tile/mm/init.c | 8 + arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/init_32.c | 12 + arch/x86/mm/init_64.c | 417 +++++++++++++++++++++++++++++++++++ arch/x86/mm/pageattr.c | 47 ++-- drivers/acpi/acpi_memhotplug.c | 8 +-
Quoted 9 lines
drivers/base/memory.c | 6 + drivers/firmware/memmap.c | 98 +++++++- include/linux/firmware-map.h | 6 + include/linux/memory_hotplug.h | 15 +- include/linux/mm.h | 5 +- mm/memory_hotplug.c | 409 ++++++++++++++++++++++++++++++++-- mm/sparse.c | 5 +- 21 files changed, 1095 insertions(+), 57 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi Andrew,
The patch-set aims to linux-3.8. So we would like you to merge the patch-set into your tree.
The patch-set applied many comments. Currently there is no comment to the patch-set.
Additionally, we have spent a lot of time on the verification of the patch-set. And we found many bugs, and fixed them.
So we believe that Linux on x86_64 can support memory hot remove by the patch-set.
Thanks,
Yasuaki Ishimatsu
Quoted 105 lines · Wen Congyang
The patch-set was divided from following thread's patch-set.
https://lkml.org/lkml/2012/9/5/201The last version of this patchset:
https://lkml.org/lkml/2012/10/23/213If you want to know the reason, please read following thread.
https://lkml.org/lkml/2012/10/2/83
The patch-set has only the function of kernel core side for physical memory hot remove. So if you use the patch, please apply following patches.
- bug fix for memory hot remove
https://lkml.org/lkml/2012/10/31/269- acpi framework
https://lkml.org/lkml/2012/10/26/175The patches can free/remove the following things:
-
/sys/firmware/memmap/X/{end, start, type} : [PATCH 2/10]- mem_section and related sysfs files : [PATCH 3-4/10] - memmap of sparse-vmemmap : [PATCH 5-7/10] - page table of removed memory : [RFC PATCH 8/10] - node and related sysfs files : [RFC PATCH 9-10/10]* [PATCH 2/10] checks whether the memory can be removed or not.
If you find lack of function for physical memory hot-remove, please let me know.
How to test this patchset?
1. apply this patchset and build the kernel.MEMORY_HOTPLUG,MEMORY_HOTREMOVE,ACPI_HOTPLUG_MEMORYmust be selected.
2. load the moduleacpi_memhotplug
3. hotplug the memory device(it depends on your hardware)
You will see the memory device under the directory/sys/bus/acpi/devices/. Its name is PNP0C80:XX.
4. online/offline pages provided by this memory device
You can write online/offline to/sys/devices/system/memory/memoryX/stateto online/offline pages provided by this memory device
5. hotremove the memory device
You can hotremove the memory device by the hardware, or writing 1 to /sys/bus/acpi/devices/PNP0C80:XX/eject.Note: if the memory provided by the memory device is used by the kernel, it can't be offlined. It is not a bug.
Known problems:
1. hotremoving memory device may cause kernel panicked This bug will be fixed by Liu Jiang's patch:
https://lkml.org/lkml/2012/7/3/1Changelogs from v2 to v3:
Patch9: callsync_global_pgds()if pgd is changed
Patch10: fix a problem int the patchChangelogs from v1 to v2:
Patch1: new patch, offline memory twice. 1st iterate: offline every non primary
memory block. 2nd iterate: offline primary (i.e. first added) memory block.Patch3: new patch, no logical change, just remove reduntant codes.
Patch9: merge the patch from wujianguo into this patch. flush tlb on all cpu
after the pagetable is changed.Patch12: new patch, free
node_datawhen a node is offlinedWen Congyang (6):
memory-hotplug: try to offline the memory twice to avoid dependence
memory-hotplug: remove redundant codes
memory-hotplug: introduce new functionarch_remove_memory()for
removing page table depends on architecture
memory-hotplug: remove page table ofx86_64architecture
memory-hotplug: remove sysfs file of node
memory-hotplug: freenode_datawhen a node is offlinedYasuaki Ishimatsu (6):
memory-hotplug: check whether all memory blocks are offlined or not
when removing memory
memory-hotplug: remove/sys/firmware/memmap/Xsysfs
memory-hotplug: unregister memory section onSPARSEMEM_VMEMMAP
memory-hotplug: implementregister_page_bootmem_info_sectionof
sparse-vmemmap
memory-hotplug: remove memmap of sparse-vmemmap
memory-hotplug:memory_hotplug: clear zone when removing the memoryarch/ia64/mm/discontig.c | 14 ++ arch/ia64/mm/init.c | 18 ++ arch/powerpc/mm/init_64.c | 14 ++ arch/powerpc/mm/mem.c | 12 + arch/s390/mm/init.c | 12 + arch/s390/mm/vmem.c | 14 ++ arch/sh/mm/init.c | 17 ++ arch/sparc/mm/init_64.c | 14 ++ arch/tile/mm/init.c | 8 + arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/init_32.c | 12 + arch/x86/mm/init_64.c | 417 +++++++++++++++++++++++++++++++++++ arch/x86/mm/pageattr.c | 47 ++-- drivers/acpi/acpi_memhotplug.c | 8 +-
Quoted 9 lines
drivers/base/memory.c | 6 + drivers/firmware/memmap.c | 98 +++++++- include/linux/firmware-map.h | 6 + include/linux/memory_hotplug.h | 15 +- include/linux/mm.h | 5 +- mm/memory_hotplug.c | 409 ++++++++++++++++++++++++++++++++-- mm/sparse.c | 5 +- 21 files changed, 1095 insertions(+), 57 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>