questions about memory hotplug
Subsystems (5)
We want to handle the following 2 use cases we have on some of our (ARM) platforms:
1. A platform where part of the memory may be powered off. The location and size of this memory is not known until the kernel parses the memory tags (there aren't any non-standard tags used, but the memory layout and a memory bank size which is obtained from HW are used to figure out where and how large this memory is). All of this memory must either be on or off. For a given configuration the location of this memory can't be moved.
2. A (different) platform where part of the memory is occasionally needed as a large physically contiguous block, but usually is not (and then should be usable by the kernel as normal memory). When the memory is needed for the contiguous block, the pages in this range currently being used by the kernel will need to be migrated out.
The size of this is known at compile time and can be placed at any reasonable place in memory (but should be SPARSEMEM section aligned -- its size may however not be a power of 2 and thus this memory could span more than one section). This memory will not be powered off, but must either be completely used for one purpose or the other.
The size of memory in question for #1 is generally much larger than that of #2.
Memory hotplug/hotremove (logical and physical for #1, only logical for #2) approximately solves these problems, but there is some functionality we need that AFAIK is not present:
* The memory in #1 and #2 above must be in a movable zone so that the chance of migration is maximized. I'm familiar with the kernelcore= and movablecore= commandline options, but they don't do what is necessary here, because we need control on where the movable zone is formed as well as the size. Also the location and size of these special memory areas is not known until the kernel comes up (in #1 it is conceivable that the bootloader could locate the memory that can be powered on and off and pass it in via some commandline option, but AFAICT this won't work at all for #2).
One could hack up find_zone_movable_pfns_for_nodes() presumably, but I wonder if there is an already existing way of doing this (or at least a clean extension to the current functionality that someone might suggest).
Would CONFIG_ARCH_POPULATES_NODE_MAP help here? Does anyone use this? It doesn't seem to be in any defconfig or Kconfig on 3.0 (or earlier versions I've looked at).
Perhaps CMA (which is not merged yet and AFAIK still has some issues on ARM) might handle #2 better than memory hotplug/hotremove. Or is there a better way to handle #2 than either CMA or memory hotplug?
Thanks.
Larry
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 53 lines · Larry Bassel
We want to handle the following 2 use cases we have on some of our (ARM) platforms:
1. A platform where part of the memory may be powered off. The location and size of this memory is not known until the kernel parses the memory tags (there aren't any non-standard tags used, but the memory layout and a memory bank size which is obtained from HW are used to figure out where and how large this memory is). All of this memory must either be on or off. For a given configuration the location of this memory can't be moved.
2. A (different) platform where part of the memory is occasionally needed as a large physically contiguous block, but usually is not (and then should be usable by the kernel as normal memory). When the memory is needed for the contiguous block, the pages in this range currently being used by the kernel will need to be migrated out.
The size of this is known at compile time and can be placed at any reasonable place in memory (but should be SPARSEMEM section aligned -- its size may however not be a power of 2 and thus this memory could span more than one section). This memory will not be powered off, but must either be completely used for one purpose or the other.
The size of memory in question for #1 is generally much larger than that of #2.
Memory hotplug/hotremove (logical and physical for #1, only logical for #2) approximately solves these problems, but there is some functionality we need that AFAIK is not present:
* The memory in #1 and #2 above must be in a movable zone so that the chance of migration is maximized. I'm familiar with the kernelcore= and movablecore= commandline options, but they don't do what is necessary here, because we need control on where the movable zone is formed as well as the size. Also the location and size of these special memory areas is not known until the kernel comes up (in #1 it is conceivable that the bootloader could locate the memory that can be powered on and off and pass it in via some commandline option, but AFAICT this won't work at all for #2).
One could hack up
find_zone_movable_pfns_for_nodes()presumably, but I wonder if there is an already existing way of doing this (or at least a clean extension to the current functionality that someone might suggest).
Quoted 8 lines
Would
CONFIG_ARCH_POPULATES_NODE_MAPhelp here? Does anyone use this? It doesn't seem to be in any defconfig orKconfigon 3.0 (or earlier versions I've looked at).Perhaps CMA (which is not merged yet and AFAIK still has some issues on ARM) might handle #2 better than memory hotplug/hotremove. Or is there a better way to handle #2 than either CMA or memory hotplug?
is such memory always at the end of memory? if yes, such memory can be added to MOVABLE_ZONE.
or if such memory can be at the middle of memory, maybe we can add a new mirgate type, the migrate type is movable but other type allocation can't fallback into.
Thanks,
Shaohua
Quoted 58 lines · Shaohua Li
Quoted 57 lines · Larry Bassel
We want to handle the following 2 use cases we have on some of our (ARM) platforms:
1. A platform where part of the memory may be powered off. The location and size of this memory is not known until the kernel parses the memory tags (there aren't any non-standard tags used, but the memory layout and a memory bank size which is obtained from HW are used to figure out where and how large this memory is). All of this memory must either be on or off. For a given configuration the location of this memory can't be moved.
2. A (different) platform where part of the memory is occasionally needed as a large physically contiguous block, but usually is not (and then should be usable by the kernel as normal memory). When the memory is needed for the contiguous block, the pages in this range currently being used by the kernel will need to be migrated out.
The size of this is known at compile time and can be placed at any reasonable place in memory (but should be SPARSEMEM section aligned -- its size may however not be a power of 2 and thus this memory could span more than one section). This memory will not be powered off, but must either be completely used for one purpose or the other.
The size of memory in question for #1 is generally much larger than that of #2.
Memory hotplug/hotremove (logical and physical for #1, only logical for #2) approximately solves these problems, but there is some functionality we need that AFAIK is not present:
* The memory in #1 and #2 above must be in a movable zone so that the chance of migration is maximized. I'm familiar with the kernelcore= and movablecore= commandline options, but they don't do what is necessary here, because we need control on where the movable zone is formed as well as the size. Also the location and size of these special memory areas is not known until the kernel comes up (in #1 it is conceivable that the bootloader could locate the memory that can be powered on and off and pass it in via some commandline option, but AFAICT this won't work at all for #2).
One could hack up
find_zone_movable_pfns_for_nodes()presumably, but I wonder if there is an already existing way of doing this (or at least a clean extension to the current functionality that someone might suggest).Would
CONFIG_ARCH_POPULATES_NODE_MAPhelp here? Does anyone use this? It doesn't seem to be in any defconfig orKconfigon 3.0 (or earlier versions I've looked at).
Quoted 6 lines
Quoted 4 lines
Perhaps CMA (which is not merged yet and AFAIK still has some issues on ARM) might handle #2 better than memory hotplug/hotremove. Or is there a better way to handle #2 than either CMA or memory hotplug?
is such memory always at the end of memory? if yes, such memory can be added to
MOVABLE_ZONE.
In use case #1 yes, maybe not in #2 (we can arrange it to be at the end of memory, but then might waste memory as it may not be aligned on a SPARSEMEM section boundary and so would need to be padded).
Quoted 6 lines
or if such memory can be at the middle of memory, maybe we can add a new mirgate type, the migrate type is movable but other type allocation can't fallback into.
Thanks,
Shaohua
Larry
Quoted 7 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo at kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> email at kvack.org </a>
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 5 lines · Larry Bassel
In use case #1 yes, maybe not in #2 (we can arrange it to be at the end of memory, but then might waste memory as it may not be aligned on a SPARSEMEM section boundary and so would need to be padded).
then maybe the new migrate type I suggested can help here for the non-aligned memory. Anyway, let me do an experiment.
Thanks,
Shaohua
Quoted 8 lines · Shaohua Li
Quoted 5 lines · Larry Bassel
In use case #1 yes, maybe not in #2 (we can arrange it to be at the end of memory, but then might waste memory as it may not be aligned on a SPARSEMEM section boundary and so would need to be padded).
then maybe the new migrate type I suggested can help here for the non-aligned memory. Anyway, let me do an experiment.
so your problem is to offline memory in arbitrary address and size (eg, might not be at the end, and maybe smaller than a section)
I had a hack. In my machine, I have DMA, DMA32, and NORMAL zone. At boot time, I mark 500M~600M ranges as MOVABLE_NOFB. the range is in DMA32 and not section size aligned. MOVABLE_NOFB is a new migrate type I added. That range memory is movable, but other type of allocation can't fallback into such ranges. so such range memory can only be used by userspace.
I then run a memory stress test and do memory online/offline for the range at runtime, the offline always success.
Does this meet your usage? If yes, I'll cook it up a little bit.
--- include/linux/gfp.h | 5 +- include/linux/mmzone.h | 7 +- mm/memory_hotplug.c | 117 ++++++++++++++++++++++++++++++++++--------------- mm/page_alloc.c | 94 +++++++++++++++++++++++++++++++++------ mm/vmstat.c | 1 5 files changed, 171 insertions(+), 53 deletions(-)
include/linux/gfp.h +3 -2
@@ -155,8 +155,9 @@ static inline int allocflags_to_migratetreturn MIGRATE_UNMOVABLE ;/* Group based on mobility */ -return (((gfp_flags & __GFP_MOVABLE) !=0 ) <<1 ) | - ((gfp_flags & __GFP_RECLAIMABLE) !=0 ); +if ((gfp_flags & __GFP_MOVABLE) !=0 ) +return MIGRATE_MOVABLE_NOFB ; +return (gfp_flags & __GFP_RECLAIMABLE) !=0 ; }#ifdef CONFIG_HIGHMEM
include/linux/mmzone.h +4 -3
@@ -39,9 +39,10 @@#define MIGRATE_RECLAIMABLE 1#define MIGRATE_MOVABLE 2#define MIGRATE_PCPTYPES 3/* the number of types on the pcp lists */ -#define MIGRATE_RESERVE 3 -#define MIGRATE_ISOLATE 4/* can't allocate from here */ -#define MIGRATE_TYPES 5 +#define MIGRATE_MOVABLE_NOFB 3 +#define MIGRATE_RESERVE 4 +#define MIGRATE_ISOLATE 5/* can't allocate from here */ +#define MIGRATE_TYPES 6#define for_each_migratetype_order (order, type) \ for (order = 0; order < MAX_ORDER; order++) \
mm/page_alloc.c +81 -13
172 lines not on this page · raw message
mm/vmstat.c +1 -0
@@ -612,6 +612,7 @@ static char * const migratetype_names[MI"Unmovable" ,"Reclaimable" ,"Movable" , +"Movable-nofb" ,"Reserve" , "Isolate", };
mm/memory_hotplug.c +82 -35
159 lines not on this page · raw message
Quoted 11 lines · Shaohua Li
Quoted 8 lines · Shaohua Li
Quoted 5 lines · Larry Bassel
In use case #1 yes, maybe not in #2 (we can arrange it to be at the end of memory, but then might waste memory as it may not be aligned on a SPARSEMEM section boundary and so would need to be padded).
then maybe the new migrate type I suggested can help here for the non-aligned memory. Anyway, let me do an experiment.
so your problem is to offline memory in arbitrary address and size (eg, might not be at the end, and maybe smaller than a section)
Yes (and online it again). Also the decision to (attempt to) on/offline must be done from userspace (as memory hotplug does already).
Quoted 4 lines
I had a hack. In my machine, I have DMA, DMA32, and NORMAL zone. At boot time, I mark 500M~600M ranges as
MOVABLE_NOFB. the range is in DMA32 and not section size aligned.
A few questions:
* You still use SPARSEMEM though, correct?
* Would there be any problem using NORMAL memory as MOVABLE_NOFB?
* So you don't use ZONE_MOVABLE or kernelcore= or movablecore= at all?
* Do you online/offline using the /sys/devices/system/memory files? If so, does the kernel still attempt to on/offline the entire section (as it does now) or only the MOVABLE_NOFB part? If not, how do you on/offline memory?
Quoted 4 lines
MOVABLE_NOFBis a new migrate type I
added. That range memory is movable, but other type of allocation can't fallback into such ranges. so such range memory can only be used by userspace.
And the kernel will not reserve memory from it either (I had to put a hack in an earlier version of what I'm doing to not allow reserving from the movable zone because otherwise the existence of these reserved pages would block logical hotremove), correct?
Quoted 3 lines
I then run a memory stress test and do memory online/offline for the range at runtime, the offline always success.
Does this meet your usage? If yes, I'll cook it up a little bit.
Yes, this looks very promising.
Do you see any reason this can't be backported to 2.6.38?
Thank you very much for your help here.
Larry
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 3 lines · Larry Bassel
Would
CONFIG_ARCH_POPULATES_NODE_MAPhelp here? Does anyone use this? It doesn't seem to be in any defconfig orKconfig
I want to clarify this, I meant used on ARM -- I see it is being used on other architectures (and that movablecore= and kernelcore= require this config option).
Quoted 2 lines
on 3.0 (or earlier versions I've looked at).
Larry
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.