Re: [PATCH V8] mm: memory hot-add: hot-added memory can not be added to movable zone by default
在 2015/11/5 0:31, Dave Hansen 写道: On 11/04/2015 12:23 AM, liuchangsheng wrote: After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL, and we need using the udev rules to online the memory automatically: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online_movable" The memory block onlined by udev must be adjacent to ZONE_MOVABLE. The events of memory section are notified to udev asynchronously, so it can not ensure that the memory block onlined by udev is adjacent to ZONE_MOVABLE.So it can't ensure memory online always success. But we want the whole node to be added to ZONE_MOVABLE by default. I'm still a bit confused about the whole scenario here. Is the core problem: 1. We add memory in a new node and that node can not be made entirely movable? As I know, System will not ensure that the node can be made entirely movable if the memory of the node is assigned to ZONE_NORMAL or 2. We add memory to an existing zone that has some non-movable memory and we want the new memory to be movable? It will work if we want to let the memroy movable by using movable_node @@ -1201,6 +1201,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ This comment is describing what the code does, but is rather sparse on why. This scenario is pretty convoluted and I can barely make sense of why it is doing this today while looking at the whole changelog, much less in a few years when the original changelog will be harder to come by. Also please put the comment next to the new if() statement. It's really hard to match the comment to the code the way you have it now. static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1208,6 +1211,10 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() && (zone_end_pfn(pre_zone) <= start_pfn)) + return 1; if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V8] mm: memory hot-add: hot-added memory can not be added to movable zone by default
在 2015/11/5 0:31, Dave Hansen 写道: On 11/04/2015 12:23 AM, liuchangsheng wrote: After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL, and we need using the udev rules to online the memory automatically: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online_movable" The memory block onlined by udev must be adjacent to ZONE_MOVABLE. The events of memory section are notified to udev asynchronously, so it can not ensure that the memory block onlined by udev is adjacent to ZONE_MOVABLE.So it can't ensure memory online always success. But we want the whole node to be added to ZONE_MOVABLE by default. I'm still a bit confused about the whole scenario here. Is the core problem: 1. We add memory in a new node and that node can not be made entirely movable? As I know, System will not ensure that the node can be made entirely movable if the memory of the node is assigned to ZONE_NORMAL or 2. We add memory to an existing zone that has some non-movable memory and we want the new memory to be movable? It will work if we want to let the memroy movable by using movable_node @@ -1201,6 +1201,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ This comment is describing what the code does, but is rather sparse on why. This scenario is pretty convoluted and I can barely make sense of why it is doing this today while looking at the whole changelog, much less in a few years when the original changelog will be harder to come by. Also please put the comment next to the new if() statement. It's really hard to match the comment to the code the way you have it now. static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1208,6 +1211,10 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() && (zone_end_pfn(pre_zone) <= start_pfn)) + return 1; if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V5] mm: memory hot-add: memory can not be added to movable zone defaultly
On 11/4 2015 0:13, Yasuaki Ishimatsu wrote: Hi Changsheng, According to the following thread, Tang has no objection to change kernel behavior since udev cannot online memory as movable. https://lkml.org/lkml/2015/10/21/159 So how about reposting the v5 patch? I have a comment about the patch. Please see below. Thanks,I will update the patch and repost it On Tue, 15 Sep 2015 03:49:58 -0400 Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Xiaofeng Yan Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d39dbb0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1190,6 +1190,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1200,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() + && zone_end_pfn(pre_zone) <= start_pfn) + return 1; if (movable_node_is_enabled() && (zone_end_pfn(pre_zone) <= start_pfn)) Thanks, Yasuaki Ishimatsu if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V5] mm: memory hot-add: memory can not be added to movable zone defaultly
On 11/4 2015 0:13, Yasuaki Ishimatsu wrote: Hi Changsheng, According to the following thread, Tang has no objection to change kernel behavior since udev cannot online memory as movable. https://lkml.org/lkml/2015/10/21/159 So how about reposting the v5 patch? I have a comment about the patch. Please see below. Thanks,I will update the patch and repost it On Tue, 15 Sep 2015 03:49:58 -0400 Changsheng Liu <liuchangsh...@inspur.com> wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d39dbb0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1190,6 +1190,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1200,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() + && zone_end_pfn(pre_zone) <= start_pfn) + return 1; if (movable_node_is_enabled() && (zone_end_pfn(pre_zone) <= start_pfn)) Thanks, Yasuaki Ishimatsu if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V7] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/10/15 0:18, Vlastimil Babka 写道: On 10/12/2015 08:58 AM, Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL and ZONE_NORMAL will be created firstly. But we want the whole node to be added to ZONE_MOVABLE by default. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable is 1 and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and then the whole node will be added to ZONE_MOVABLE by default. If we want the node to be assigned to ZONE_NORMAL, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" By the patch, the behavious of kernel is changed by sysctl, user can automatically create movable memory by only the following udev rule: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" I'm sorry for replying you so late due to the busy business trip. So just to be clear, we are adding a new sysctl, because the existing movable_node kernel option, which is checked by movable_node_is_enabled(), and does the same thing for non-hot-added-memory (?) cannot be reused for hot-added memory, as that would be a potentially surprising behavior change? Correct? Then this should be mentioned in the changelog too, and wherever "movable_node" is documented should also mention the new sysctl. Personally, I would expect movable_node to affect hot-added memory as well, and would be surprised that it doesn't... I think it can let the user decides when to use this feature. The user can enable the feature when making the hot_added memory of a node movable and make the feature disable to assign the hot_added memory of the next node to ZONE_NORMAL . Signed-off-by: Changsheng Liu Signed-off-by: Xiaofeng Yan Tested-by: Dongdong Fan Cc: Wang Nan Cc: Dave Hansen Cc: Yinghai Lu Cc: Tang Chen Cc: Yasuaki Ishimatsu Cc: Toshi Kani Cc: Xishi Qiu --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 24 3 files changed, 43 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7ac7485 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE by default. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..16b1501 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE by default.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..eca5512 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -37,6 +37,11 @@ #include "internal.h" +/*If the global variable value is 1, + * the hot added memory will be assigned to ZONE_MOVABLE by default + */ +int hotadd_memory_as_movab
Re: [PATCH V7] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/10/15 0:18, Vlastimil Babka 写道: On 10/12/2015 08:58 AM, Changsheng Liu wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL and ZONE_NORMAL will be created firstly. But we want the whole node to be added to ZONE_MOVABLE by default. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable is 1 and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and then the whole node will be added to ZONE_MOVABLE by default. If we want the node to be assigned to ZONE_NORMAL, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" By the patch, the behavious of kernel is changed by sysctl, user can automatically create movable memory by only the following udev rule: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" I'm sorry for replying you so late due to the busy business trip. So just to be clear, we are adding a new sysctl, because the existing movable_node kernel option, which is checked by movable_node_is_enabled(), and does the same thing for non-hot-added-memory (?) cannot be reused for hot-added memory, as that would be a potentially surprising behavior change? Correct? Then this should be mentioned in the changelog too, and wherever "movable_node" is documented should also mention the new sysctl. Personally, I would expect movable_node to affect hot-added memory as well, and would be surprised that it doesn't... I think it can let the user decides when to use this feature. The user can enable the feature when making the hot_added memory of a node movable and make the feature disable to assign the hot_added memory of the next node to ZONE_NORMAL . Signed-off-by: Changsheng Liu <liuchangsh...@inspur.com> Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> Cc: Wang Nan <wangn...@huawei.com> Cc: Dave Hansen <dave.han...@intel.com> Cc: Yinghai Lu <ying...@kernel.org> Cc: Tang Chen <tangc...@cn.fujitsu.com> Cc: Yasuaki Ishimatsu <isimatu.yasu...@jp.fujitsu.com> Cc: Toshi Kani <toshi.k...@hp.com> Cc: Xishi Qiu <qiuxi...@huawei.com> --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 24 3 files changed, 43 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7ac7485 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE by default. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..16b1501 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE by default.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_
[PATCH V7] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL and ZONE_NORMAL will be created firstly. But we want the whole node to be added to ZONE_MOVABLE by default. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable is 1 and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and then the whole node will be added to ZONE_MOVABLE by default. If we want the node to be assigned to ZONE_NORMAL, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" By the patch, the behavious of kernel is changed by sysctl, user can automatically create movable memory by only the following udev rule: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" Signed-off-by: Changsheng Liu Signed-off-by: Xiaofeng Yan Tested-by: Dongdong Fan Cc: Wang Nan Cc: Dave Hansen Cc: Yinghai Lu Cc: Tang Chen Cc: Yasuaki Ishimatsu Cc: Toshi Kani Cc: Xishi Qiu --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 24 3 files changed, 43 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7ac7485 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE by default. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..16b1501 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE by default.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..eca5512 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -37,6 +37,11 @@ #include "internal.h" +/*If the global variable value is 1, + * the hot added memory will be assigned to ZONE_MOVABLE by default + */ +int hotadd_memory_as_movable; + /* * online_page_callback contains pointer to current page onlining function. * Initially it is generic_online_page(). If it is required it could be @@ -1190,6 +1195,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system config CONFIG_MOVABLE_NODE and set the sysctl parameter + * "hotadd_memory_as_movable" and added memory does not overlap the zone + * before MOVABLE_ZONE,the memory will be added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1205,22 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_M
Re: [PATCH V6] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/10/12 9:45, Tang Chen 写道: Hi Ishimatsu, On 10/10/2015 02:13 AM, Yasuaki Ishimatsu wrote: Hi Tang, On Fri, 9 Oct 2015 15:59:38 +0800 Tang Chen wrote: Hi, I don't mean to offend, but I really think it is not necessary to do this. hot-added memory will be added to ZONE_NORMAL by default. You can modify it when you online memory. I think it is enough for users. But we cannot automatically create movable memory even if we use udev rules. Thus user must create original scrip to online memory as movable. Do you think every user understand the rule that ZONE_NORMAL must be on the left side of ZONE_MOVABLE? I think memory hotplug users should understand this. If we can change the behavir of kernel by sysctl, user can create movable memory by only the following udev rule. SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" OK, that is fine. And I think it is better to add this to the commit message. Thanks, I will update the patch. Thanks. Thanks, Yasuaki Ishimatsu And a sysctl interface is also unnecessary. I think one default behaviour is enough for kernel. We'd better keep it in the current way, or change it and document it. It just makes no sense to enable users to modify it. Can you please share any use case of this sysctl interface ? I suggest just keep the current implement. But I'm OK with that if other reviewers or users could clarify it is useful. :) And BTW, please don't cc the following reviewers. Their email addresses have changed. Cc: Zhang Yanfei Cc: Hu Tao Cc: Lai Jiangshan Cc: Gu Zheng Thanks. :) On 10/09/2015 03:12 PM, Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Changsheng Liu Signed-off-by: Xiaofeng Yan Tested-by: Dongdong Fan Cc: Wang Nan Cc: Zhang Yanfei Cc: Dave Hansen Cc: Yinghai Lu Cc: Tang Chen Cc: Hu Tao Cc: Lai Jiangshan Cc: Yasuaki Ishimatsu Cc: Gu Zheng Cc: Toshi Kani Cc: Xishi Qiu Signed-off-by: Andrew Morton --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 23 +++ 3 files changed, 42 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7e6b4f4 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE defautly. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..855c48e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY-1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler= timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE defautly.*/ +#ifdef CON
Re: [PATCH V6] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/10/12 9:45, Tang Chen 写道: Hi Ishimatsu, On 10/10/2015 02:13 AM, Yasuaki Ishimatsu wrote: Hi Tang, On Fri, 9 Oct 2015 15:59:38 +0800 Tang Chen <tangc...@cn.fujitsu.com> wrote: Hi, I don't mean to offend, but I really think it is not necessary to do this. hot-added memory will be added to ZONE_NORMAL by default. You can modify it when you online memory. I think it is enough for users. But we cannot automatically create movable memory even if we use udev rules. Thus user must create original scrip to online memory as movable. Do you think every user understand the rule that ZONE_NORMAL must be on the left side of ZONE_MOVABLE? I think memory hotplug users should understand this. If we can change the behavir of kernel by sysctl, user can create movable memory by only the following udev rule. SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" OK, that is fine. And I think it is better to add this to the commit message. Thanks, I will update the patch. Thanks. Thanks, Yasuaki Ishimatsu And a sysctl interface is also unnecessary. I think one default behaviour is enough for kernel. We'd better keep it in the current way, or change it and document it. It just makes no sense to enable users to modify it. Can you please share any use case of this sysctl interface ? I suggest just keep the current implement. But I'm OK with that if other reviewers or users could clarify it is useful. :) And BTW, please don't cc the following reviewers. Their email addresses have changed. Cc: Zhang Yanfei<zhangyan...@cn.fujitsu.com> Cc: Hu Tao<hu...@cn.fujitsu.com> Cc: Lai Jiangshan<la...@cn.fujitsu.com> Cc: Gu Zheng<guz.f...@cn.fujitsu.com> Thanks. :) On 10/09/2015 03:12 PM, Changsheng Liu wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Changsheng Liu <liuchangsh...@inspur.com> Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> Cc: Wang Nan <wangn...@huawei.com> Cc: Zhang Yanfei <zhangyan...@cn.fujitsu.com> Cc: Dave Hansen <dave.han...@intel.com> Cc: Yinghai Lu <ying...@kernel.org> Cc: Tang Chen <tangc...@cn.fujitsu.com> Cc: Hu Tao <hu...@cn.fujitsu.com> Cc: Lai Jiangshan <la...@cn.fujitsu.com> Cc: Yasuaki Ishimatsu <isimatu.yasu...@jp.fujitsu.com> Cc: Gu Zheng <guz.f...@cn.fujitsu.com> Cc: Toshi Kani <toshi.k...@hp.com> Cc: Xishi Qiu <qiuxi...@huawei.com> Signed-off-by: Andrew Morton <a...@linux-foundation.org> --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 23 +++ 3 files changed, 42 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7e6b4f4 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE defautly. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysc
[PATCH V7] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including ZONE_MOVABLE are empty, so the memory that was hot added will be assigned to ZONE_NORMAL and ZONE_NORMAL will be created firstly. But we want the whole node to be added to ZONE_MOVABLE by default. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable is 1 and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and then the whole node will be added to ZONE_MOVABLE by default. If we want the node to be assigned to ZONE_NORMAL, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" By the patch, the behavious of kernel is changed by sysctl, user can automatically create movable memory by only the following udev rule: SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online" Signed-off-by: Changsheng Liu <liuchangsh...@inspur.com> Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> Cc: Wang Nan <wangn...@huawei.com> Cc: Dave Hansen <dave.han...@intel.com> Cc: Yinghai Lu <ying...@kernel.org> Cc: Tang Chen <tangc...@cn.fujitsu.com> Cc: Yasuaki Ishimatsu <isimatu.yasu...@jp.fujitsu.com> Cc: Toshi Kani <toshi.k...@hp.com> Cc: Xishi Qiu <qiuxi...@huawei.com> --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 24 3 files changed, 43 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7ac7485 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE by default. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..16b1501 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE by default.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..eca5512 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -37,6 +37,11 @@ #include "internal.h" +/*If the global variable value is 1, + * the hot added memory will be assigned to ZONE_MOVABLE by default + */ +int hotadd_memory_as_movable; + /* * online_page_callback contains pointer to current page onlining function. * Initially it is generic_online_page(). If it is required it could be @@ -1190,6 +1195,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system config CONFIG_MOVABLE_NODE and set the sysctl parameter + * "hotadd_memory_as_movable" and added memory does not overlap the zone + * before MOVABLE_ZONE,the memory will be added as movable. * Without this check, movable zone may overlap with other zone. */ stati
[PATCH V6] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Changsheng Liu Signed-off-by: Xiaofeng Yan Tested-by: Dongdong Fan Cc: Wang Nan Cc: Zhang Yanfei Cc: Dave Hansen Cc: Yinghai Lu Cc: Tang Chen Cc: Hu Tao Cc: Lai Jiangshan Cc: Yasuaki Ishimatsu Cc: Gu Zheng Cc: Toshi Kani Cc: Xishi Qiu Signed-off-by: Andrew Morton --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 23 +++ 3 files changed, 42 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7e6b4f4 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE defautly. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..855c48e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE defautly.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..5bcaf74 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -37,6 +37,10 @@ #include "internal.h" +/*If the global variable value is 1, + * the hot added memory will be assigned to ZONE_MOVABLE defautly*/ +int hotadd_memory_as_movable; + /* * online_page_callback contains pointer to current page onlining function. * Initially it is generic_online_page(). If it is required it could be @@ -1190,6 +1194,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system config CONFIG_MOVABLE_NODE and set the sysctl parameter + * "hotadd_memory_as_movable" and added memory does not overlap the zone + * before MOVABLE_ZONE,the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1204,22 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); +
[PATCH V6] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and sysctl parameter hotadd_memory_as_movable and the ZONE_NORMAL is empty or the pfn of the hot-added memory is after the end of the ZONE_NORMAL it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Changsheng Liu <liuchangsh...@inspur.com> Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> Cc: Wang Nan <wangn...@huawei.com> Cc: Zhang Yanfei <zhangyan...@cn.fujitsu.com> Cc: Dave Hansen <dave.han...@intel.com> Cc: Yinghai Lu <ying...@kernel.org> Cc: Tang Chen <tangc...@cn.fujitsu.com> Cc: Hu Tao <hu...@cn.fujitsu.com> Cc: Lai Jiangshan <la...@cn.fujitsu.com> Cc: Yasuaki Ishimatsu <isimatu.yasu...@jp.fujitsu.com> Cc: Gu Zheng <guz.f...@cn.fujitsu.com> Cc: Toshi Kani <toshi.k...@hp.com> Cc: Xishi Qiu <qiuxi...@huawei.com> Signed-off-by: Andrew Morton <a...@linux-foundation.org> --- Documentation/memory-hotplug.txt |5 - kernel/sysctl.c | 15 +++ mm/memory_hotplug.c | 23 +++ 3 files changed, 42 insertions(+), 1 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ce2cfcf..7e6b4f4 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -277,7 +277,7 @@ And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: After this, memory block XXX's state will be 'online' and the amount of available memory will be increased. -Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). +Currently, newly added memory is added as ZONE_NORMAL or ZONE_MOVABLE (for powerpc, ZONE_DMA). This may be changed in future. @@ -319,6 +319,9 @@ creates ZONE_MOVABLE as following. Size of memory not for movable pages (not for offline) is TOTAL - . Size of memory for movable pages (for offline) is . +And a sysctl parameter for assigning the hot added memory to ZONE_MOVABLE is +supported. If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added +memory will be assigned to ZONE_MOVABLE defautly. Note: Unfortunately, there is no information to show which memory block belongs to ZONE_MOVABLE. This is TBD. diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 19b62b5..855c48e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -166,6 +166,10 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; #endif +#ifdef CONFIG_MOVABLE_NODE +extern int hotadd_memory_as_movable; +#endif + #ifdef CONFIG_PROC_SYSCTL #define SYSCTL_WRITES_LEGACY -1 @@ -1139,6 +1143,17 @@ static struct ctl_table kern_table[] = { .proc_handler = timer_migration_handler, }, #endif +/*If the value of "kernel/hotadd_memory_as_movable" is 1,the hot added + * memory will be assigned to ZONE_MOVABLE defautly.*/ +#ifdef CONFIG_MOVABLE_NODE + { + .procname = "hotadd_memory_as_movable", + .data = _memory_as_movable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..5bcaf74 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -37,6 +37,10 @@ #include "internal.h" +/*If the global variable value is 1, + * the hot added memory will be assigned to ZONE_MOVABLE defautly*/ +int hotadd_memory_as_movable; + /* * online_page_callback contains pointer to current page onlining function. * Initially it is generic_online_page(). If it is required it could be @@ -1190,6 +1194,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system config CONFIG_MOVABLE_NODE and set the sysctl parameter + * "hotadd_memory_as_movable" and added memory does not overlap the zone + * before MOVABLE_ZONE,the memory is added as movable. * Without t
[PATCH V5] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Xiaofeng Yan Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d39dbb0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1190,6 +1190,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1200,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() + && zone_end_pfn(pre_zone) <= start_pfn) + return 1; if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V5] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" Signed-off-by: Xiaofeng Yan <yanxiaof...@inspur.com> Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d39dbb0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1190,6 +1190,9 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_node and config CONFIG_MOVABLE_NOD and + * added memory does not overlap the zone before MOVABLE_ZONE, + * the memory is added as movable * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1197,6 +1200,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *pre_zone = pgdat->node_zones + (ZONE_MOVABLE - 1); + + if (movable_node_is_enabled() + && zone_end_pfn(pre_zone) <= start_pfn) + return 1; if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 9/1/2015 23:37, Yasuaki Ishimatsu wrote: On Mon, 31 Aug 2015 01:58:40 -0400 Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Reviewed-by: Yasuaki Ishimatsu Reviewed-by: Vlastimil Babka Reviewed-by: Xiaofeng Yan Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; If system boots up without movable_node, kernel behavior is changed by the patch. And you syould consider other zone. How about it. The patch is no build and test. --- mm/memory_hotplug.c | 36 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6da82bc..321595d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,8 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_zone and added memory does not overlap + * other zone except for movable zone, the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1205,14 +1207,40 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *zone; + enum zone_type zt = ZONE_MOVABLE - 1; + + /* +* If memory is added after ZONE_MOVALBE, the memory is managed as +* movable. +*/ + if (!zone_is_empty(movable_zone) && + (movable_zone->zone_start_pfn <= start_pfn)) + return 1; - if (zone_is_empty(movable_zone)) + if (!movable_node_is_enabled()) return 0; - if (movable_zone->zone_start_pfn <= start_pfn) - return 1; + /* +* Find enabled zone and check the added memory. +* If the memory is added after the enabled zone, the memory is +* managed as movable. +* +* If all zones are empty, the memory is also managed as movable. +*/ + for (; zt >= ZONE_DMA; zt--) { + zone = pgdat->node_zones + zt; - return 0; + if (zone_is_empty(zone)) + continue; + + if (zone_end_pfn(zone) <= start_pfn) + return 1; + else + return 0; + } + + return 1; } The function zone_for_memory() adds the memory to ZONE_NORMAL(x86_64)/ZONE_HIGH(x86_32) defaultly, So I think the system just need check the added-memory is whether after the ZONE_NORMAL/ZONE_HIGH int zone_for_memory(int nid, u64 start, u64 size, int zone_default) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 9/1/2015 23:37, Yasuaki Ishimatsu wrote: On Mon, 31 Aug 2015 01:58:40 -0400 Changsheng Liu <liuchangsh...@inspur.com> wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton <a...@linux-foundation.org> Reviewed-by: Yasuaki Ishimatsu <yasu.isim...@gmail.com> Reviewed-by: Vlastimil Babka <vba...@suse.cz> Reviewed-by: Xiaofeng Yan <yanxiaof...@inspur.com> Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; If system boots up without movable_node, kernel behavior is changed by the patch. And you syould consider other zone. How about it. The patch is no build and test. --- mm/memory_hotplug.c | 36 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6da82bc..321595d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,8 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_zone and added memory does not overlap + * other zone except for movable zone, the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1205,14 +1207,40 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *zone; + enum zone_type zt = ZONE_MOVABLE - 1; + + /* +* If memory is added after ZONE_MOVALBE, the memory is managed as +* movable. +*/ + if (!zone_is_empty(movable_zone) && + (movable_zone->zone_start_pfn <= start_pfn)) + return 1; - if (zone_is_empty(movable_zone)) + if (!movable_node_is_enabled()) return 0; - if (movable_zone->zone_start_pfn <= start_pfn) - return 1; + /* +* Find enabled zone and check the added memory. +* If the memory is added after the enabled zone, the memory is +* managed as movable. +* +* If all zones are empty, the memory is also managed as movable. +*/ + for (; zt >= ZONE_DMA; zt--) { + zone = pgdat->node_zones + zt; - return 0; + if (zone_is_empty(zone)) + continue; + + if (zone_end_pfn(zone) <= start_pfn) + return 1; + else + return 0; + } + + return 1; } The function zone_for_memory() adds the memory to ZONE_NORMAL(x86_64)/ZONE_HIGH(x86_32) defaultly, So I think the system just need check the added-memory is whether after the ZONE_NORMAL/ZONE_HIGH int zone_for_memory(int nid, u64 start, u64 size, int zone_default) -- To unsubscribe from this list: send the line "
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 9/1/2015 23:37, Yasuaki Ishimatsu wrote: On Mon, 31 Aug 2015 01:58:40 -0400 Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Reviewed-by: Yasuaki Ishimatsu Reviewed-by: Vlastimil Babka Reviewed-by: Xiaofeng Yan Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; If system boots up without movable_node, kernel behavior is changed by the patch. And you syould consider other zone. How about it. The patch is no build and test. Thanks for your suggestion. We will test the patch on our platform --- mm/memory_hotplug.c | 36 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6da82bc..321595d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,8 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_zone and added memory does not overlap + * other zone except for movable zone, the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1205,14 +1207,40 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *zone; + enum zone_type zt = ZONE_MOVABLE - 1; + + /* +* If memory is added after ZONE_MOVALBE, the memory is managed as +* movable. +*/ + if (!zone_is_empty(movable_zone) && + (movable_zone->zone_start_pfn <= start_pfn)) + return 1; - if (zone_is_empty(movable_zone)) + if (!movable_node_is_enabled()) return 0; - if (movable_zone->zone_start_pfn <= start_pfn) - return 1; + /* +* Find enabled zone and check the added memory. +* If the memory is added after the enabled zone, the memory is +* managed as movable. +* +* If all zones are empty, the memory is also managed as movable. +*/ + for (; zt >= ZONE_DMA; zt--) { + zone = pgdat->node_zones + zt; - return 0; + if (zone_is_empty(zone)) + continue; + + if (zone_end_pfn(zone) <= start_pfn) + return 1; + else + return 0; + } + + return 1; } int zone_for_memory(int nid, u64 start, u64 size, int zone_default) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 9/1/2015 23:37, Yasuaki Ishimatsu wrote: On Mon, 31 Aug 2015 01:58:40 -0400 Changsheng Liu <liuchangsh...@inspur.com> wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton <a...@linux-foundation.org> Reviewed-by: Yasuaki Ishimatsu <yasu.isim...@gmail.com> Reviewed-by: Vlastimil Babka <vba...@suse.cz> Reviewed-by: Xiaofeng Yan <yanxiaof...@inspur.com> Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; If system boots up without movable_node, kernel behavior is changed by the patch. And you syould consider other zone. How about it. The patch is no build and test. Thanks for your suggestion. We will test the patch on our platform --- mm/memory_hotplug.c | 36 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6da82bc..321595d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,8 @@ static int check_hotplug_memory_range(u64 start, u64 size) /* * If movable zone has already been setup, newly added memory should be check. * If its address is higher than movable zone, it should be added as movable. + * And if system boots up with movable_zone and added memory does not overlap + * other zone except for movable zone, the memory is added as movable. * Without this check, movable zone may overlap with other zone. */ static int should_add_memory_movable(int nid, u64 start, u64 size) @@ -1205,14 +1207,40 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *zone; + enum zone_type zt = ZONE_MOVABLE - 1; + + /* +* If memory is added after ZONE_MOVALBE, the memory is managed as +* movable. +*/ + if (!zone_is_empty(movable_zone) && + (movable_zone->zone_start_pfn <= start_pfn)) + return 1; - if (zone_is_empty(movable_zone)) + if (!movable_node_is_enabled()) return 0; - if (movable_zone->zone_start_pfn <= start_pfn) - return 1; + /* +* Find enabled zone and check the added memory. +* If the memory is added after the enabled zone, the memory is +* managed as movable. +* +* If all zones are empty, the memory is also managed as movable. +*/ + for (; zt >= ZONE_DMA; zt--) { + zone = pgdat->node_zones + zt; - return 0; + if (zone_is_empty(zone)) + continue; + + if (zone_end_pfn(zone) <= start_pfn) + return 1; + else + return 0; + } + + return 1; } int zone_for_memory(int nid, u64 start, u64 size, int zone_default) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 8/31/2015 21:08, Vlastimil Babka wrote: On 08/31/2015 07:58 AM, Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Reviewed-by: Yasuaki Ishimatsu Reviewed-by: Vlastimil Babka Reviewed-by: Xiaofeng Yan Thanks for the credit for commenting on the previous versions of the patch. However, "Reviewed-by" currently means that the reviewer believes the patch is OK, so you can add it only if the reviewer offers it explicitly. See Documentation/SubmittingPatches section 13. There was a discussion on ksummit-discuss about adding a new tag for this case, but nothing was decided yet AFAIK. I'm sorry about it and thanks for your review,I will update the patch. Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; +struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + +if (movable_node_is_enabled() +&& (zone_end_pfn(normal_zone) <= start_pfn)) +return 1; I wonder if the condition is true and ZONE_NORMAL exists (but it's empty?) if you intend to only add movable memory to a node, so you can still hot-remove it all with this patch? Yes if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
On 8/31/2015 21:08, Vlastimil Babka wrote: On 08/31/2015 07:58 AM, Changsheng Liu wrote: From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton <a...@linux-foundation.org> Reviewed-by: Yasuaki Ishimatsu <yasu.isim...@gmail.com> Reviewed-by: Vlastimil Babka <vba...@suse.cz> Reviewed-by: Xiaofeng Yan <yanxiaof...@inspur.com> Thanks for the credit for commenting on the previous versions of the patch. However, "Reviewed-by" currently means that the reviewer believes the patch is OK, so you can add it only if the reviewer offers it explicitly. See Documentation/SubmittingPatches section 13. There was a discussion on ksummit-discuss about adding a new tag for this case, but nothing was decided yet AFAIK. I'm sorry about it and thanks for your review,I will update the patch. Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; +struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + +if (movable_node_is_enabled() +&& (zone_end_pfn(normal_zone) <= start_pfn)) +return 1; I wonder if the condition is true and ZONE_NORMAL exists (but it's empty?) if you intend to only add movable memory to a node, so you can still hot-remove it all with this patch? Yes if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Reviewed-by: Yasuaki Ishimatsu Reviewed-by: Vlastimil Babka Reviewed-by: Xiaofeng Yan Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V4] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu <liuchangch...@inspur.com> After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton <a...@linux-foundation.org> Reviewed-by: Yasuaki Ishimatsu <yasu.isim...@gmail.com> Reviewed-by: Vlastimil Babka <vba...@suse.cz> Reviewed-by: Xiaofeng Yan <yanxiaof...@inspur.com> Signed-off-by: Changsheng Liu <liuchangch...@inspur.com> Tested-by: Dongdong Fan <fa...@inspur.com> --- mm/memory_hotplug.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..d1149ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,6 +1197,11 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) unsigned long start_pfn = start >> PAGE_SHIFT; pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + struct zone *normal_zone = pgdat->node_zones + ZONE_NORMAL; + + if (movable_node_is_enabled() + && (zone_end_pfn(normal_zone) <= start_pfn)) + return 1; if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V3] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/8/27 17:29, Vlastimil Babka 写道: On 08/27/2015 10:54 AM, Changsheng Liu wrote: From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. OK it seems current behavior indeed goes against the expectations of setting movable_node. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. Was this tested to really work as well? Per Yasuaki's explanation in v2, you shouldn't create ZONE_MOVABLE before ZONE_NORMAL. We will test it more fully. There is on limit written in Documentation/memory-hotplug.txt when move the memory from movable zone to normal zone: echo online_kernel > /sys/devices/system/memory/memoryXXX/state (NOTE: current limit: this memory block must be adjacent to ZONE_NORMAL) The zone will be created as follows: First,all zones have been initialized,but all zones are empty, then the should_add_memory_movable() return 1 so the movable is created and add the whole node to movable zone. empty whole node's memory |---|---|--- ZONE_NORMAL ZONE_MOVABLE when we move the memory to normal zone empty whole node's memory ||:---| one memory block ajacent to ZONE_NORMAL : ZONE_NORMAL ZONE_MOVABLE: : one memory block :whole node - one memory block |-|---| ZONE_NORMAL ZONE_MOVABLE But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Interesting... Signed-off-by: Changsheng Liu i Tested-by: Dongdong Fan --- mm/memory_hotplug.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..b5f14fa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,9 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; +if (movable_node_is_enabled()) +return 1; + if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V3] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: "echo online_kernel > /sys/devices/system/memory/memoryXXX/state" If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton Signed-off-by: Changsheng Liu i Tested-by: Dongdong Fan --- mm/memory_hotplug.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..b5f14fa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,9 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; + if (movable_node_is_enabled()) + return 1; + if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V3] mm: memory hot-add: memory can not be added to movable zone defaultly
在 2015/8/27 17:29, Vlastimil Babka 写道: On 08/27/2015 10:54 AM, Changsheng Liu wrote: From: Changsheng Liu liuchangch...@inspur.com After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. OK it seems current behavior indeed goes against the expectations of setting movable_node. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: echo online_kernel /sys/devices/system/memory/memoryXXX/state If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. Was this tested to really work as well? Per Yasuaki's explanation in v2, you shouldn't create ZONE_MOVABLE before ZONE_NORMAL. We will test it more fully. There is on limit written in Documentation/memory-hotplug.txt when move the memory from movable zone to normal zone: echo online_kernel /sys/devices/system/memory/memoryXXX/state (NOTE: current limit: this memory block must be adjacent to ZONE_NORMAL) The zone will be created as follows: First,all zones have been initialized,but all zones are empty, then the should_add_memory_movable() return 1 so the movable is created and add the whole node to movable zone. empty whole node's memory |---|---|--- ZONE_NORMAL ZONE_MOVABLE when we move the memory to normal zone empty whole node's memory ||:---| one memory block ajacent to ZONE_NORMAL : ZONE_NORMAL ZONE_MOVABLE: : one memory block :whole node - one memory block |-|---| ZONE_NORMAL ZONE_MOVABLE But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton a...@linux-foundation.org Interesting... Signed-off-by: Changsheng Liu liuchangch...@inspur.comi Tested-by: Dongdong Fan fa...@inspur.com --- mm/memory_hotplug.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..b5f14fa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,9 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; +if (movable_node_is_enabled()) +return 1; + if (zone_is_empty(movable_zone)) return 0; . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V3] mm: memory hot-add: memory can not be added to movable zone defaultly
From: Changsheng Liu liuchangch...@inspur.com After the user config CONFIG_MOVABLE_NODE and movable_node kernel option, When the memory is hot added, should_add_memory_movable() return 0 because all zones including movable zone are empty, so the memory that was hot added will be added to the normal zone and the normal zone will be created firstly. But we want the whole node to be added to movable zone defaultly. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE and movable_node kernel option it will always return 1 and all zones is empty at the same time, so that the movable zone will be created firstly and then the whole node will be added to movable zone defaultly. If we want the node to be added to normal zone, we can do it as follows: echo online_kernel /sys/devices/system/memory/memoryXXX/state If the memory is added to movable zone defaultly, the user can offline it and add it to other zone again. But if the memory is added to normal zone defaultly, the user will not offline the memory used by kernel. Reviewed-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Changsheng Liu liuchangch...@inspur.comi Tested-by: Dongdong Fan fa...@inspur.com --- mm/memory_hotplug.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..b5f14fa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,6 +1198,9 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; + if (movable_node_is_enabled()) + return 1; + if (zone_is_empty(movable_zone)) return 0; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
在 2015/8/26 14:12, Vlastimil Babka 写道: On 26.8.2015 2:36, Changsheng Liu wrote: 在 2015/8/25 19:13, Vlastimil Babka 写道: On 08/25/2015 12:25 PM, Changsheng Liu wrote: Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: So you agree to drop the patch from -mm? The system add memory to normal zone defaultly so that it can be used by kernel and then we can not move the memory to movable zone. The patch can add the memory to movable zone directlly. I thought that you confirmed that the following works? echo online_movable > /sys/devices/system/memory/memoryXXX/state If you want it to be the default, there's the node_movable kernel boot option. Does it work for you? . It does not work when memory is hot added. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
在 2015/8/26 14:12, Vlastimil Babka 写道: On 26.8.2015 2:36, Changsheng Liu wrote: 在 2015/8/25 19:13, Vlastimil Babka 写道: On 08/25/2015 12:25 PM, Changsheng Liu wrote: Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: So you agree to drop the patch from -mm? The system add memory to normal zone defaultly so that it can be used by kernel and then we can not move the memory to movable zone. The patch can add the memory to movable zone directlly. I thought that you confirmed that the following works? echo online_movable /sys/devices/system/memory/memoryXXX/state If you want it to be the default, there's the node_movable kernel boot option. Does it work for you? . It does not work when memory is hot added. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V2] mm:memory hot-add: memory can not been added to movable zone
First, thanks very much for your review, I will update codes according to your suggestion On 2015/8/25 21:12, Yasuaki Ishimatsu wrote: On Thu, 20 Aug 2015 03:28:05 -0400 Changsheng Liu wrote: From: Changsheng Liu When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) - return 0; - + return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone->zone_start_pfn <= start_pfn) return 1; Currently, kernel allows to create ZONE_MOVABLE after ZONE_NORMAL as follows: PFN low high ---|-|-|--- ZONE_NORMAL ZONE_MOVABLE But kernel does not allow to create ZONE_MOVABLE before ZONE_NORMAL as follows: PFN low high ---|-|-|--- ZONE_MOVABLE ZONE_NORMAL Also, kernel does not allow to create ZONE_MOVABLE in ZOME_NORMAL as follows: PFN low high ---|-|-|-|--- ZONE_NORMAL ZONE_MOVABLE ZONE_NORMAL So should_add_memory_movable() checks them. Accoring to your patch, when movable_zone is empty, the hot added memory is always managed to ZONE_MOVABLE. It means that ZONE_MOVALBE will puts before/in ZONE_NORMAL. You must prevent from creating ZONE_MOVABLE before/in ZONE_NORMAL. Thanks, Yasuaki Ishimatsu -- 1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majord...@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: mailto:"d...@kvack.org;> em...@kvack.org . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
在 2015/8/25 19:13, Vlastimil Babka 写道: On 08/25/2015 12:25 PM, Changsheng Liu wrote: Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: So you agree to drop the patch from -mm? The system add memory to normal zone defaultly so that it can be used by kernel and then we can not move the memory to movable zone. The patch can add the memory to movable zone directlly. Hi On Thu, 20 Aug 2015 14:15:13 +0800 Changsheng Liu wrote: Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestio 在 2015/8/20 7:50, Andrew Morton 写道: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu wrote: From: Changsheng Liu When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the "even if we want to remove the memory". This is hot-add, not hot-remove. What do you mean here? After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. For this, we prepared online_movable. When memory is onlined by online_movable, the memory move from ZONE_NORMAL to ZONE_MOVABLE. Ex. # echo online_movable > /sys/devices/system/memory/memoryXXX/state Thanks, Yasuaki Ishimatsu we checked the value of the file under some memory blocks as follows: "cat /sys/devices/system/memory/ memory***/removable" When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; -if (zone_is_empty(movable_zone)) +if (zone_is_empty(movable_zone)) { +#ifdef CONFIG_MOVABLE_NODE +return 1; +#else return 0; - +#endif +} if (movable_zone->zone_start_pfn <= start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; -if (zone_is_empty(movable_zone)) { -#ifdef CONFIG_MOVABLE_NODE -return 1; -#else -return 0; -#endif -} +if (zone_is_empty(movable_zone)) +return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone->zone_start_pfn <= start_pfn) return 1; _ . . . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: Hi On Thu, 20 Aug 2015 14:15:13 +0800 Changsheng Liu wrote: Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestio 在 2015/8/20 7:50, Andrew Morton 写道: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu wrote: From: Changsheng Liu When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the "even if we want to remove the memory". This is hot-add, not hot-remove. What do you mean here? After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. For this, we prepared online_movable. When memory is onlined by online_movable, the memory move from ZONE_NORMAL to ZONE_MOVABLE. Ex. # echo online_movable > /sys/devices/system/memory/memoryXXX/state Thanks, Yasuaki Ishimatsu we checked the value of the file under some memory blocks as follows: "cat /sys/devices/system/memory/ memory***/removable" When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone->zone_start_pfn <= start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) { - #ifdef CONFIG_MOVABLE_NODE - return 1; - #else - return 0; - #endif - } + if (zone_is_empty(movable_zone)) + return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone->zone_start_pfn <= start_pfn) return 1; _ . . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: Hi On Thu, 20 Aug 2015 14:15:13 +0800 Changsheng Liu liuchangsh...@inspur.com wrote: Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestio 在 2015/8/20 7:50, Andrew Morton 写道: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu liuchangsh...@inspur.com wrote: From: Changsheng Liu liuchangch...@inspur.com When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the even if we want to remove the memory. This is hot-add, not hot-remove. What do you mean here? After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. For this, we prepared online_movable. When memory is onlined by online_movable, the memory move from ZONE_NORMAL to ZONE_MOVABLE. Ex. # echo online_movable /sys/devices/system/memory/memoryXXX/state Thanks, Yasuaki Ishimatsu we checked the value of the file under some memory blocks as follows: cat /sys/devices/system/memory/ memory***/removable When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone-zone_start_pfn = start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) { - #ifdef CONFIG_MOVABLE_NODE - return 1; - #else - return 0; - #endif - } + if (zone_is_empty(movable_zone)) + return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone-zone_start_pfn = start_pfn) return 1; _ . . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
在 2015/8/25 19:13, Vlastimil Babka 写道: On 08/25/2015 12:25 PM, Changsheng Liu wrote: Thanks very much for your review, I can move the memory from normal zone to movable zone succesfully. And thank you for let me understand the memory mechanism better. 在 2015/8/25 3:15, Yasuaki Ishimatsu 写道: So you agree to drop the patch from -mm? The system add memory to normal zone defaultly so that it can be used by kernel and then we can not move the memory to movable zone. The patch can add the memory to movable zone directlly. Hi On Thu, 20 Aug 2015 14:15:13 +0800 Changsheng Liu liuchangsh...@inspur.com wrote: Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestio 在 2015/8/20 7:50, Andrew Morton 写道: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu liuchangsh...@inspur.com wrote: From: Changsheng Liu liuchangch...@inspur.com When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the even if we want to remove the memory. This is hot-add, not hot-remove. What do you mean here? After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. For this, we prepared online_movable. When memory is onlined by online_movable, the memory move from ZONE_NORMAL to ZONE_MOVABLE. Ex. # echo online_movable /sys/devices/system/memory/memoryXXX/state Thanks, Yasuaki Ishimatsu we checked the value of the file under some memory blocks as follows: cat /sys/devices/system/memory/ memory***/removable When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; -if (zone_is_empty(movable_zone)) +if (zone_is_empty(movable_zone)) { +#ifdef CONFIG_MOVABLE_NODE +return 1; +#else return 0; - +#endif +} if (movable_zone-zone_start_pfn = start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; -if (zone_is_empty(movable_zone)) { -#ifdef CONFIG_MOVABLE_NODE -return 1; -#else -return 0; -#endif -} +if (zone_is_empty(movable_zone)) +return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone-zone_start_pfn = start_pfn) return 1; _ . . . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V2] mm:memory hot-add: memory can not been added to movable zone
First, thanks very much for your review, I will update codes according to your suggestion On 2015/8/25 21:12, Yasuaki Ishimatsu wrote: On Thu, 20 Aug 2015 03:28:05 -0400 Changsheng Liu liuchangsh...@inspur.com wrote: From: Changsheng Liu liuchangch...@inspur.com When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Changsheng Liu liuchangch...@inspur.com Tested-by: Dongdong Fan fa...@inspur.com --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) - return 0; - + return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone-zone_start_pfn = start_pfn) return 1; Currently, kernel allows to create ZONE_MOVABLE after ZONE_NORMAL as follows: PFN low high ---|-|-|--- ZONE_NORMAL ZONE_MOVABLE But kernel does not allow to create ZONE_MOVABLE before ZONE_NORMAL as follows: PFN low high ---|-|-|--- ZONE_MOVABLE ZONE_NORMAL Also, kernel does not allow to create ZONE_MOVABLE in ZOME_NORMAL as follows: PFN low high ---|-|-|-|--- ZONE_NORMAL ZONE_MOVABLE ZONE_NORMAL So should_add_memory_movable() checks them. Accoring to your patch, when movable_zone is empty, the hot added memory is always managed to ZONE_MOVABLE. It means that ZONE_MOVALBE will puts before/in ZONE_NORMAL. You must prevent from creating ZONE_MOVABLE before/in ZONE_NORMAL. Thanks, Yasuaki Ishimatsu -- 1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majord...@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: a href=mailto:d...@kvack.org; em...@kvack.org /a . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V2] mm:memory hot-add: memory can not been added to movable zone
On 08/20/201515:41, Vlastimil Babka wrote: On 08/20/2015 09:28 AM, Changsheng Liu wrote: From: Changsheng Liu When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. I'm not expert on memory hot-plug, but since you CC'd me, I wonder... the function has this comment: " * If movable zone has already been setup, newly added memory should be check." So I read it like "if you want movable memory *at all*, you should do some setup first" (but don't ask me what setup). After your patch, every hot-added memory would be automatically movable? Isn't that silently changing behavior against user expectations? What about those that don't want to hot-remove and don't want movable zones (which limit what kind of allocations are possible), is there a way to prevent memory being movable after your patch? After the system startup, we hot added one cpu with memory, The function arch_add_memory() will add the memory to normal zone defaultly but now all zones including normal zone and movable zone are empty.So If we want to add the memory to movable zone we need change should_add_memory_movable(). So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) -return 0; - +return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone->zone_start_pfn <= start_pfn) return 1; . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2] mm:memory hot-add: memory can not been added to movable zone
From: Changsheng Liu When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton Signed-off-by: Changsheng Liu Tested-by: Dongdong Fan --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) - return 0; - + return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone->zone_start_pfn <= start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestion After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. we checked the value of the file under some memory blocks as follows: "cat /sys/devices/system/memory/ memory***/removable" When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added On Wed, 20 Aug 2015 7:50, Andrew Morton wrote: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu wrote: From: Changsheng Liu When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the "even if we want to remove the memory". This is hot-add, not hot-remove. What do you mean here? --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone->zone_start_pfn <= start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) { - #ifdef CONFIG_MOVABLE_NODE - return 1; - #else - return 0; - #endif - } + if (zone_is_empty(movable_zone)) + return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone->zone_start_pfn <= start_pfn) return 1; _ . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Memory hot added,The memory can not been added to movable zone
Hi Andrew Morton: First, thanks very much for your review, I will update codes according to your suggestion After the system startup, we hot added one memory. After some time we wanted to hot remove the memroy that was hot added, but we could not offline some memory blocks successfully because the memory was added to normal zone defaultly and the value of the file named removable under some memory blocks is 0. we checked the value of the file under some memory blocks as follows: cat /sys/devices/system/memory/ memory***/removable When memory being hot added we let the memory be added to movable zone, so we will be able to hot remove the memory that have been hot added On Wed, 20 Aug 2015 7:50, Andrew Morton wrote: On Wed, 19 Aug 2015 04:18:26 -0400 Changsheng Liu liuchangsh...@inspur.com wrote: From: Changsheng Liu liuchangch...@inspur.com When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty I cleaned this up a bit: : Subject: mm: memory hot-add: memory can not been added to movable zone : : When memory is hot added, should_add_memory_movable() always returns 0 : because the movable zone is empty, so the memory that was hot added will : add to the normal zone even if we want to remove the memory. : : So we change should_add_memory_movable(): if the user config : CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. But I don't understand the even if we want to remove the memory. This is hot-add, not hot-remove. What do you mean here? --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone-zone_start_pfn = start_pfn) return 1; Cleaner: --- a/mm/memory_hotplug.c~memory-hot-addedthe-memory-can-not-been-added-to-movable-zone-fix +++ a/mm/memory_hotplug.c @@ -1181,13 +1181,9 @@ static int should_add_memory_movable(int pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) { - #ifdef CONFIG_MOVABLE_NODE - return 1; - #else - return 0; - #endif - } + if (zone_is_empty(movable_zone)) + return IS_ENABLED(CONFIG_MOVABLE_NODE); + if (movable_zone-zone_start_pfn = start_pfn) return 1; _ . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2] mm:memory hot-add: memory can not been added to movable zone
From: Changsheng Liu liuchangch...@inspur.com When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Changsheng Liu liuchangch...@inspur.com Tested-by: Dongdong Fan fa...@inspur.com --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) - return 0; - + return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone-zone_start_pfn = start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V2] mm:memory hot-add: memory can not been added to movable zone
On 08/20/201515:41, Vlastimil Babka wrote: On 08/20/2015 09:28 AM, Changsheng Liu wrote: From: Changsheng Liu liuchangch...@inspur.com When memory is hot added, should_add_memory_movable() always returns 0 because the movable zone is empty, so the memory that was hot added will add to the normal zone even if we want to remove the memory. I'm not expert on memory hot-plug, but since you CC'd me, I wonder... the function has this comment: * If movable zone has already been setup, newly added memory should be check. So I read it like if you want movable memory *at all*, you should do some setup first (but don't ask me what setup). After your patch, every hot-added memory would be automatically movable? Isn't that silently changing behavior against user expectations? What about those that don't want to hot-remove and don't want movable zones (which limit what kind of allocations are possible), is there a way to prevent memory being movable after your patch? After the system startup, we hot added one cpu with memory, The function arch_add_memory() will add the memory to normal zone defaultly but now all zones including normal zone and movable zone are empty.So If we want to add the memory to movable zone we need change should_add_memory_movable(). So we change should_add_memory_movable(): if the user config CONFIG_MOVABLE_NODE it will return 1 when the movable zone is empty. Reviewed-by: Andrew Morton a...@linux-foundation.org Signed-off-by: Changsheng Liu liuchangch...@inspur.com Tested-by: Dongdong Fan fa...@inspur.com --- mm/memory_hotplug.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..ff658f2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1199,8 +1199,7 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; if (zone_is_empty(movable_zone)) -return 0; - +return IS_ENABLED(CONFIG_MOVABLE_NODE); if (movable_zone-zone_start_pfn = start_pfn) return 1; . -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Memory hot added,The memory can not been added to movable zone
From: Changsheng Liu When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty Signed-off-by: Changsheng Liu --- mm/memory_hotplug.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..2b0aec4 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone->zone_start_pfn <= start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Memory hot added to normal zone defaultlly in kernel 4.1.0 The memory hot added to normal zone defaultlly so we need let the memory be added to movable zone if we need remove the added memory
From: Changsheng Liu --- mm/memory_hotplug.c |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..f5bcd03 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,8 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) - return 0; + if (zone_is_empty(movable_zone)){ +#ifdef CONFIG_MOVABLE_NODE +return 1; +#else +return 0; +#endif + } if (movable_zone->zone_start_pfn <= start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Memory hot added to normal zone defaultlly in kernel 4.1.0 The memory hot added to normal zone defaultlly so we need let the memory be added to movable zone if we need remove the added memory
From: Changsheng Liu liuchangch...@inspur.com --- mm/memory_hotplug.c |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..f5bcd03 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,8 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) - return 0; + if (zone_is_empty(movable_zone)){ +#ifdef CONFIG_MOVABLE_NODE +return 1; +#else +return 0; +#endif + } if (movable_zone-zone_start_pfn = start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Memory hot added,The memory can not been added to movable zone
From: Changsheng Liu liuchangch...@inspur.com When memory hot added, the function should_add_memory_movable always return 0,because the movable zone is empty, so the memory that hot added will add to normal zone even if we want to remove the memory. So we change the function should_add_memory_movable,if the user config CONFIG_MOVABLE_NODE it will return 1 when movable zone is empty Signed-off-by: Changsheng Liu liuchangch...@inspur.com --- mm/memory_hotplug.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 26fbba7..2b0aec4 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1198,9 +1198,13 @@ static int should_add_memory_movable(int nid, u64 start, u64 size) pg_data_t *pgdat = NODE_DATA(nid); struct zone *movable_zone = pgdat-node_zones + ZONE_MOVABLE; - if (zone_is_empty(movable_zone)) + if (zone_is_empty(movable_zone)) { + #ifdef CONFIG_MOVABLE_NODE + return 1; + #else return 0; - + #endif + } if (movable_zone-zone_start_pfn = start_pfn) return 1; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/