memcg weighted interleave mempolicy control
Subsystems (6)
v4 cover memcg weighted interleave mempolicy control
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
The il_weight of a node is used by mempolicy to implement weighted interleave when numactl --interleave=... is invoked. By default il_weight for a node is always 1, which preserves the default round robin interleave behavior.
Interleave weights denote the number of pages that should be allocated from the node when interleaving occurs and have a range of 1-255. The weight of a node can never be 0, and instead the preferred way to prevent allocation is to remove the node from the cpuset or mempolicy altogether.
For example, if a node's interleave weight is set to 5, 5 pages will be allocated from that node before the next node is scheduled for allocations.
# Set node weight for node 0 to 5
echo 0:5 > /sys/fs/cgroup/user.slice/memory.interleave_weights
# Set node weight for node 1 to 3
echo 1:3 > /sys/fs/cgroup/user.slice/memory.interleave_weights
# View the currently set weights
cat /sys/fs/cgroup/user.slice/memory.interleave_weights 0:5,1:3
Weights will only be displayed for possible nodes.
With this it becomes possible to set an interleaving strategy that fits the available bandwidth for the devices available on the system. An example system:
Node 0 - CPU+DRAM, 400GB/s BW (200 cross socket) Node 1 - CXL Memory. 64GB/s BW, on Node 0 root complex
In this setup, the effective weights for a node set of [0,1] may be may be [86, 14] (86% of memory on Node 0, 14% on node 1) or some smaller fraction thereof to encourge quicker rounds for better overall distribution.
This spreads memory out across devices which all have different latency and bandwidth attributes in a way that can maximize the available resources.
~Gregory
=============
Version Notes:
= v4 notes
Moved interleave weights to cgroups from nodes.
Omitted them from the root cgroup for initial testing/comment, but it seems like it may be a reasonable idea to place them there too.
== Weighted interleave
mm/mempolicy: modify interleave mempolicy to use node weights
The mempolicy MPOL_INTERLEAVE utilizes the node weights defined in the cgroup memory.interleave_weights interfaces to implement weighted interleave. By default, since all nodes default to a weight of 1, the original interleave behavior is retained.
============
RFC History
Node based weights
By: Gregory Price
https://lore.kernel.org/linux-mm/[email protected]/
Memory-tier based weights
By: Ravi Shankar
https://lore.kernel.org/all/[email protected]/
Mempolicy multi-node weighting w/ set_mempolicy2:
By: Gregory Price
https://lore.kernel.org/all/[email protected]/
Hasan Al Maruf: N:M weighting in mempolicy
https://lore.kernel.org/linux-mm/YqD0%[email protected]/T/
Huang, Ying's presentation in lpc22, 16th slide in
https://lpc.events/event/16/contributions/1209/attachments/1042/1995/\
Live%20In%20a%20World%20With%20Multiple%20Memory%20Types.pdf
===================
Gregory Price (3):
mm/memcontrol: implement memcg.interleave_weights mm/mempolicy: implement weighted interleave
Documentation: sysfs entries for cgroup.memory.interleave_weights
Documentation/admin-guide/cgroup-v2.rst | 45 +++++ .../admin-guide/mm/numa_memory_policy.rst | 11 ++ include/linux/memcontrol.h | 31 ++++ include/linux/mempolicy.h | 3 + mm/memcontrol.c | 172 ++++++++++++++++++ mm/mempolicy.c | 153 +++++++++++++--- 6 files changed, 387 insertions(+), 28 deletions(-)
Signature · 1 line
2.39.1
RFC PATCH v4 1/3 mm/memcontrol: implement memcg.interleave_weights
Create an RCU-protected array of unsigned char[MAX_NUMNODES] where interleave weights can be stored. The intent of these weights are to be used by mempolicy to implement weighted interleave for bandwidth optimization.
Node weights assigned via cgroup/memory.interleave_weights
Example: Set a 3:1 weighting ratio for nodes 0 and 1 respectively.
echo 0:3 > cgroup/memory.interleave_weights
echo 1:1 > cgroup/memory.interleave_weights
Example output:
cat cgroup/memory.interleave_weights
0:3,1:1
Child cgroups inherit parent interleave weights and may override them.
To revert weights to inheriting from the parent, write "-1:0"
Example:
echo -1:0 > cgroup/memory.interleave_weights
--- include/linux/memcontrol.h | 31 +++++++ mm/memcontrol.c | 172 +++++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+)
include/linux/memcontrol.h +31 -0
@@ -21,6 +21,8 @@#include <linux/vmstat.h> #include <linux/writeback.h> #include <linux/page-flags.h> +#include <linux/numa.h> +#include <linux/nodemask.h> struct mem_cgroup ;struct obj_cgroup ;
@@ -167,6 +169,15 @@ struct mem_cgroup_thresholds {struct mem_cgroup_threshold_ary *spare; }; +/* For mempolicy information */ +struct mem_cgroup_mempolicy { +/* +* When interleaving is applied, do allocations on each node by the +* weight value. Size is always MAX_NUMNODES. Protected by RCU. +*/ +unsigned char *il_weights; +}; +/* * Remember four most recent foreign writebacks with dirty pages in this * cgroup. Inode sharing is expected to be uncommon and, even if we miss
@@ -265,6 +276,12 @@ struct mem_cgroup {/* thresholds for mem+swap usage. RCU-protected */ struct mem_cgroup_thresholds memsw_thresholds; +/* protect the mempolicy settings */ +struct mutex mempolicy_lock; + +/* mempolicy defaults for tasks */ +struct mem_cgroup_mempolicy mempolicy; +/* For oom notifier event fd */ struct list_head oom_notify;
@@ -1159,6 +1176,12 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,gfp_t gfp_mask, unsigned long *total_scanned); + +unsigned char mem_cgroup_get_il_weight (unsigned int nid); + +unsigned int mem_cgroup_get_il_weights (nodemask_t *nodes, +unsigned char *weights); +#else /* CONFIG_MEMCG */ #define MEM_CGROUP_ID_SHIFT 0
@@ -1591,6 +1614,14 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, {return 0 ; } + +static unsigned char mem_cgroup_get_il_weight (unsigned int nid) {return 0 ; } + +static unsigned int mem_cgroup_get_il_weights (nodemask_t *nodes, +unsigned char *weights) +{ +return 0 ; +}#endif /* CONFIG_MEMCG */ static inline void __inc_lruvec_kmem_state (void *p,enum node_stat_item idx)
mm/memcontrol.c +172 -0
190 lines not on this page · raw message
Signature · 1 line
2.39.1
kernel test robot
build botRe: [RFC PATCH v4 1/3] mm/memcontrol: implement memcg.interleave_weights
kernel test robot noticed the following build errors:
Hi Gregory,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on cxl/next]
[also build test ERROR on tj-cgroup/for-next cxl/pending v6.6] [cannot apply to akpm-mm/mm-everything linus/master next-20231109] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/mm-mempolicy-implement-weighted-interleave/20231109-092543 base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next patch link: https://lore.kernel.org/r/20231109002517.106829-2-gregory.price%40memverge.com patch subject: [RFC PATCH v4 1/3] mm/memcontrol: implement memcg.interleave_weights config: alpha-allnoconfig (https://download.01.org/0day-ci/archive/20231109/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231109/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
arch/alpha/mm/init.c:261:1: warning: no previous prototype for 'srm_paging_stop' [-Wmissing-prototypes]
261 | srm_paging_stop (void)
| ^~~~~~~~~~~~~~~
In file included from include/linux/swap.h:9,
from arch/alpha/mm/init.c:20:
>> include/linux/memcontrol.h:1620:21: error: 'mem_cgroup_get_il_weights' defined but not used [-Werror=unused-function]
1620 | static unsigned int mem_cgroup_get_il_weights(nodemask_t *nodes,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/memcontrol.h:1618:22: error: 'mem_cgroup_get_il_weight' defined but not used [-Werror=unused-function]
1618 | static unsigned char mem_cgroup_get_il_weight(unsigned int nid) { return 0; }
| ^~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
vim +/mem_cgroup_get_il_weights +1620 include/linux/memcontrol.h
1617
> 1618 static unsigned char mem_cgroup_get_il_weight(unsigned int nid) { return 0; }
1619
> 1620 static unsigned int mem_cgroup_get_il_weights(nodemask_t *nodes, 1621 unsigned char *weights)
1622 {
1623 return 0;
1624 }
1625 #endif /* CONFIG_MEMCG */
1626
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
RFC PATCH v4 2/3 mm/mempolicy: implement weighted interleave
In reply to Gregory PriceImplements interleave weighting for bandwidth optimization.
The mempolicy MPOL_INTERLEAVE utilizes the node weights to implement weighted interleave.
There are 3 integration points:
interleave_nodes:
Counts the number of allocations as they occur, and applies the weight for the current node. When the weight reaches 0, switch to the next node.
offset_il_node:
Gets the total weight of the nodemask as well as each individual node weight, then calculates the node based on the given index n.
bulk_array_interleave:
Gets the total weight of the nodemask as well as each individual node weight, then calculates the number of "interleave rounds" as well as any delta ("partial round"). Calculates the number of pages for each node and allocates them.
If a node was scheduled for interleave via interleave_nodes, the current weight (pol->cur_weight) will be allocated first, before the remaining bulk calculation is done. This simplifies the calculation at the cost of an additional allocation call.
The functions mempolicy_get_il_weight and mempolicy_get_il_weights were added so that should mempolicy be extended in the future to include local mempolicy weights, there is a clear integration point.
--- include/linux/mempolicy.h | 3 + mm/mempolicy.c | 153 +++++++++++++++++++++++++++++++------- 2 files changed, 128 insertions(+), 28 deletions(-)
include/linux/mempolicy.h +3 -0
@@ -48,6 +48,9 @@ struct mempolicy {nodemask_t nodes;/* interleave/bind/perfer */ int home_node;/* Home node to use for MPOL_BIND and MPOL_PREFERRED_MANY */ +unsigned char cur_weight;/* weight of current il node */ +unsigned char il_weights[MAX_NUMNODES ];/* used during allocation */ +union {nodemask_t cpuset_mems_allowed;/* relative to these nodes */ nodemask_t user_nodemask;/* nodemask passed by user */
mm/mempolicy.c +125 -28
210 lines not on this page · raw message
Signature · 1 line
2.39.1
kernel test robot
build botRe: [RFC PATCH v4 2/3] mm/mempolicy: implement weighted interleave
kernel test robot noticed the following build errors:
Hi Gregory,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on cxl/next]
[also build test ERROR on tj-cgroup/for-next cxl/pending v6.6] [cannot apply to akpm-mm/mm-everything linus/master next-20231109] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/mm-mempolicy-implement-weighted-interleave/20231109-092543 base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next patch link: https://lore.kernel.org/r/20231109002517.106829-3-gregory.price%40memverge.com patch subject: [RFC PATCH v4 2/3] mm/mempolicy: implement weighted interleave config: arm64-randconfig-004-20231109 (https://download.01.org/0day-ci/archive/20231109/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231109/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
aarch64-linux-ld: Unexpected GOT/PLT entries detected!
aarch64-linux-ld: Unexpected run-time procedure linkages detected!
aarch64-linux-ld: mm/mempolicy.o: in function `interleave_nodes':
>> mempolicy.c:(.text+0xfe0): undefined reference to `mem_cgroup_get_il_weight' >> aarch64-linux-ld: mempolicy.c:(.text+0x1054): undefined reference to `mem_cgroup_get_il_weight' aarch64-linux-ld: mm/mempolicy.o: in function `alloc_pages_bulk_array_interleave': >> mempolicy.c:(.text+0x1110): undefined reference to `mem_cgroup_get_il_weights'
aarch64-linux-ld: mm/mempolicy.o: in function `offset_il_node':
mempolicy.c:(.text+0x1554): undefined reference to `mem_cgroup_get_il_weights'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [RFC PATCH v4 2/3] mm/mempolicy: implement weighted interleave
In reply to Gregory PriceQuoted 29 lines
Gregory Price wrote:
Implements interleave weighting for bandwidth optimization.
The mempolicy
MPOL_INTERLEAVEutilizes the node weights to implement weighted interleave.There are 3 integration points:
interleave_nodes:
Counts the number of allocations as they occur, and applies the weight for the current node. When the weight reaches 0, switch to the next node.
offset_il_node:
Gets the total weight of the nodemask as well as each individual node weight, then calculates the node based on the given index n.
bulk_array_interleave:
Gets the total weight of the nodemask as well as each individual node weight, then calculates the number of "interleave rounds" as well as any delta ("partial round"). Calculates the number of pages for each node and allocates them.If a node was scheduled for interleave via
interleave_nodes, the current weight (pol->cur_weight) will be allocated first, before the remaining bulk calculation is done. This simplifies the calculation at the cost of an additional allocation call.
Quoted 5 lines
The functions
mempolicy_get_il_weightandmempolicy_get_il_weightswere added so that should mempolicy be extended in the future to include local mempolicy weights, there is a clear integration point.Signed-off-by Gregory Price <[email protected]>
Thank you for the collaboration.
Please add the following signatures to this commit.
--
Best Regards,
Ravi Jonnalagadda
RFC PATCH v4 3/3 Documentation: sysfs entries for cgroup.memory.interleave_weights
In reply to Gregory Pricecgroup.memory.interleave_weights is an array of numa node weights to be used for interleaving when mempolicy utilizes MPOL_F_IL_WEIGHTING.
By default, weights are set to 1, and are only displayed for possible numa nodes (ones which are or may become online).
Node weights are set individually, and by default are inherited from the parent cgroup. Inherited weights may be overridden, and overridden weights may be reverted to inherit from the parent.
--- Documentation/admin-guide/cgroup-v2.rst | 45 +++++++++++++++++++ .../admin-guide/mm/numa_memory_policy.rst | 11 +++++ 2 files changed, 56 insertions(+)
Documentation/admin-guide/cgroup-v2.rst +45 -0
@@ -1640,6 +1640,51 @@ PAGE_SIZE multiple when read back. Shows pressure stall information for memory. See :ref:`Documentation/accounting/psi.rst <psi>` for details. + memory.interleave_weights + An array of weights to be used for the interleave mempolicy. + + By default, weights are set to 1, and are only displayed for + possible numa nodes (ones which are or may become online). + + Example:: + + cat memory.interleave_weights + 0:1,1:1 + + Here both nodes 0 and 1 are set to weight 1. Node weights are + set individually. + + Example:: + + echo "0:3" > memory.interleave_weights + echo "1:1" > memory.interleave_weights + + Here we set a 3:1 ratio for nodes 0 and 1. Mempolicy will + allocate 3 pages on node 0 before allocating 1 page on node 1. + + Child cgroups inherit weights from their parent and may override + them or revert back to inheriting the parent weights by writing + -1:0 to memory.interleave_weights. + + Example:: + + echo "0:3" > parent/memory.interleave_weights + echo "1:1" > parent/memory.interleave_weights + + # Child cgroup inherits these weights + cat parent/child/memory.interleave_weights + 0:3,1:1 + + # Override the weights + echo "0:5" > parent/child/memory.interleave_weights + echo "1:2" > parent/child/memory.interleave_weights + cat parent/child/memory.interleave_weights + 0:5,1:2 + + # Revert the child back to inheriting the parent weights + echo "-1:0" > parent/child/memory.interleave_weights + cat parent/child/memory.interleave_weights + 0:3,1:1 Usage Guidelines ~~~~~~~~~~~~~~~~
Documentation/admin-guide/mm/numa_memory_policy.rst +11 -0
@@ -243,6 +243,17 @@ MPOL_INTERLEAVED address range or file. During system boot up, the temporary interleaved system default policy works in this mode. + The default interleave behavior is round-robin, however cgroups + implement an interleave_weights feature which can be used to + change the interleave distribution. When weights are used, + the behavior above remains the same, but placement adheres to + weights such that multiple allocations will respected the set + weights. For example, if the weights for nodes 0 and 1 are + 3 and 1 respectively (0:3,1:1), then 3 pages will be allocated + on node 0 for every 1 page allocated on node 1. + + For more details, see `Documentation/admin-guide/cgroup-v2.rst` + MPOL_PREFERRED_MANY This mode specifies that the allocation should be preferably satisfied from the nodemask specified in the policy. If there is
Signature · 1 line
2.39.1
Michal Hocko
reviewerQuoted 2 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
Why have you chosen memory controler rather than cpuset controller? TBH I do not think memcg is the best fit because traditionally memcg accounts consumption rather than memory placement. This means that the memory is already allocated when it is charged for a memcg. On the other hand cpuset controller is the one to control the allocation placement so it would seem a better fit.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 4 lines · Michal Hocko
Quoted 2 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
Quoted 9 lines
Why have you chosen memory controler rather than cpuset controller? TBH I do not think memcg is the best fit because traditionally memcg accounts consumption rather than memory placement. This means that the memory is already allocated when it is charged for a memcg. On the other hand cpuset controller is the one to control the allocation placement so it would seem a better fit.
Signature · 2 lines
Michal Hocko SUSE Labs
Wasn't sure between the two, so i tossed it in memcg. Easy relocation, and the ode should remain basically the same, so I will wait a bit before throwing out an update. Assuming we've found the right place for it, i'll probably drop RFC at that point.
~Gregory
Quoted 4 lines · Michal Hocko
Quoted 2 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
Quoted 9 lines
Why have you chosen memory controler rather than cpuset controller? TBH I do not think memcg is the best fit because traditionally memcg accounts consumption rather than memory placement. This means that the memory is already allocated when it is charged for a memcg. On the other hand cpuset controller is the one to control the allocation placement so it would seem a better fit.
Signature · 2 lines
Michal Hocko SUSE Labs
Actually going to walk back my last email, memcg actually feels more correct than cpuset, if only because of what the admin-guide says:
"""
The "memory" controller regulates distribution of memory. [... snip ...]
While not completely water-tight, all major memory usages by a given cgroup are tracked so that the total memory consumption can be accounted and controlled to a reasonable extent.
"""
'And controlled to a reasonable extent' seems to fit the description of this mechanism better than the cpuset description:
"""
The "cpuset" controller provides a mechanism for constraining the CPU and memory node placement of tasks to only the resources specified in the cpuset interface files in a task's current cgroup.
"""
This is not a constraining interface... it's "more of a suggestion". In particular, anything not using interleave doesn't even care about these weights at all.
The distribution is only enforced for allocation, it does not cause migrations... thought that would be a neat idea. This is explicitly why the interface does not allow a weight of 0 (the not should be omitted from the policy nodemask or cpuset instead).
Even if this were designed to enforce a particular distribution of memory, I'm not certain that would belong in cpusets either - but I suppose that is a separate discussion. It's possible this array of weights could be used to do both, but it seems (at least on the surface) that making this a hard control is an excellent way to induce OOMs where you may not want them.
Anyway, summarizing: After a bit of reading, this does seem to map better to the "accounting consumption" subsystem than the "constrain" subsystem. However, if you think it's better suited for cpuset, I'm happy to push in that direction.
~Gregory
Michal Hocko
reviewerOn Thu 09-11-23 11:34:01, Gregory Price wrote:
[...]
Quoted 4 lines
Anyway, summarizing: After a bit of reading, this does seem to map better to the "accounting consumption" subsystem than the "constrain" subsystem. However, if you think it's better suited for cpuset, I'm happy to push in that direction.
Maybe others see it differently but I stick with my previous position. Memcg is not a great fit for reasons already mentioned - most notably that the controller doesn't control the allocation but accounting what has been already allocated. Cpusets on the other hand constrains the allocations and that is exactly what you want to achieve.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 7 lines · Michal Hocko
On Thu 09-11-23 11:34:01, Gregory Price wrote:
[...]Quoted 4 lines
Anyway, summarizing: After a bit of reading, this does seem to map better to the "accounting consumption" subsystem than the "constrain" subsystem. However, if you think it's better suited for cpuset, I'm happy to push in that direction.
Quoted 8 lines
Maybe others see it differently but I stick with my previous position. Memcg is not a great fit for reasons already mentioned - most notably that the controller doesn't control the allocation but accounting what has been already allocated. Cpusets on the other hand constrains the allocations and that is exactly what you want to achieve.
Signature · 2 lines
Michal Hocko SUSE Labs
Digging in a bit, placing it in cpusets has locking requirements that concerns me. Maybe I'm being a bit over-cautious, so if none of this matters, then I'll go ahead and swap the code over to cpusets. Otherwise, just more food for thought in cpusets vs memcg.
In cpusets.c it states when acquiring read-only access, we have to acquire the (global) callback lock:
https://github.com/torvalds/linux/blob/master/kernel/cgroup/cpuset.c#L391
* There are two global locks guarding cpuset structures - cpuset_mutex and
* callback_lock. We also require taking task_lock() when dereferencing a
* task's cpuset pointer. See "The task_lock() exception", at the end of this
* comment.
Examples:
cpuset_node_allowed:
https://github.com/torvalds/linux/blob/master/kernel/cgroup/cpuset.c#L4780
spin_lock_irqsave(&callback_lock, flags);
rcu_read_lock();
cs = nearest_hardwall_ancestor(task_cs(current)); <-- walks parents
allowed = node_isset(node, cs->mems_allowed);
rcu_read_unlock();
spin_unlock_irqrestore(&callback_lock, flags);cpuset_mems_allowed:
https://github.com/torvalds/linux/blob/master/kernel/cgroup/cpuset.c#L4679
spin_lock_irqsave(&callback_lock, flags);
rcu_read_lock();
guarantee_online_mems(task_cs(tsk), &mask); <-- walks parents
rcu_read_unlock();
spin_unlock_irqrestore(&callback_lock, flags);Seems apparent that any form of parent walk in cpusets will require the acquisition of &callback_lock. This does not appear true of memcg.
Implementing a similar inheritance structure as described in this patch set would therefore cause the acquisition of the callback lock during node selection. So if we want this in cpuset, we're going to eat that lock acquisition, despite not really needing it.
I'm was not intending to do checks against cpusets.mems_allowed when acquiring weights, as this is already enforced between cpusets and mempolicy on hotplug and mask changes, as well as in the allocators via read_mems_allowed_begin/retry..
This is why I said this was *not* a constraining feature. Additionally, if the node selected by mpol is exhausted, the allocator will simply acquire memory from another (allowed) node, disregarding the weights entirely (which is the correct / expected behavior). Another example of "this is more of a suggestion" rather than a constraint.
So I'm contending here that putting it in cpusets is overkill. But if it likewise doesn't fit in memcg, is it insane to suggest that maybe we should consider adding cgroup.mpol, and maybe consider migrating features from mempolicy.c into cgroups (while keeping mpol the way it is).
~Gregory
Quoted 2 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
<snip>
We at Micron think this capability is really important, and moving it into cgroups introduces important flexibility that was missing from prior versions of the patchset.
To me this mainly represents the antidote to having system bios programming the memory map to be heterogeneously interleaved - which I expect will be an option, and some customers seem to want it. But that approach will affect all apps (and also the kernel), and will hide at least the interleaved numa nodes from Linux' view of the topology. There is a lot not to like about that approach...
This approach checks all the important boxes: it only applies to apps where it's enabled, the weighting can vary from one app to another, the kernel is not affected, and the numa topology is not buried.
I see Michal's comment about cpuset vs. memory, and have no opinion there.
Thumbs up!
John Groves at Micron
[email protected]
maintainerHello,
Quoted 3 lines · John Groves
This approach checks all the important boxes: it only applies to apps where it's enabled, the weighting can vary from one app to another, the kernel is not affected, and the numa topology is not buried.
Can't it be a mempol property which is inherited by child processes? Then all you'll need is e.g. adding systemd support to configure this at service unit level. I'm having a bit of hard time seeing why this needs to be a cgroup feature when it doesn't involve dynamic resource accounting / enforcement at all.
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · On Fri, Nov 10, 2023 at 12:05:59PM -1000, [email protected] wrote:
Hello,
Quoted 3 lines · John Groves
This approach checks all the important boxes: it only applies to apps where it's enabled, the weighting can vary from one app to another, the kernel is not affected, and the numa topology is not buried.
Quoted 10 lines
Can't it be a mempol property which is inherited by child processes? Then all you'll need is e.g. adding systemd support to configure this at service unit level. I'm having a bit of hard time seeing why this needs to be a cgroup feature when it doesn't involve dynamic resource accounting / enforcement at all.
Thanks.
Signature · 1 line
tejun
I did originally implement it this way, but note that it will either require some creative extension of set_mempolicy or even set_mempolicy2 as proposed here:
https://lore.kernel.org/all/[email protected]/
One of the problems to consider is task migration. If a task is migrated from one socket to another, for example by being moved to a new cgroup with a different cpuset - the weights might be completely nonsensical for the new allowed topology.
Unfortunately mpol has no way of being changed from outside the task itself once it's applied, other than changing its nodemasks via cpusets.
So one concrete use case: kubernetes might like change cpusets or move tasks from one cgroup to another, or a vm might be migrated from one set of nodes to enother (technically not mutually exclusive here). Some memory policy settings (like weights) may no longer apply when this happens, so it would be preferable to have a way to change them.
~Gregory
[email protected]
maintainerHello, Gregory.
Quoted 6 lines · Gregory Price
I did originally implement it this way, but note that it will either require some creative extension of
set_mempolicyor evenset_mempolicy2as proposed here:
Quoted 7 lines
One of the problems to consider is task migration. If a task is migrated from one socket to another, for example by being moved to a new cgroup with a different cpuset - the weights might be completely nonsensical for the new allowed topology.
Unfortunately mpol has no way of being changed from outside the task itself once it's applied, other than changing its nodemasks via cpusets.
Maybe it's time to add one?
Quoted 5 lines
So one concrete use case: kubernetes might like change cpusets or move tasks from one cgroup to another, or a vm might be migrated from one set of nodes to enother (technically not mutually exclusive here). Some memory policy settings (like weights) may no longer apply when this happens, so it would be preferable to have a way to change them.
Neither covers all use cases. As you noted in your mempolicy message, if the application wants finer grained control, cgroup interface isn't great. In general, any changes which are dynamically initiated by the application itself isn't a great fit for cgroup.
I'm generally pretty awry of adding non-resource group configuration interface especially when they don't have counter part in the regular per-process/thread API for a few reasons:
1. The reason why people try to add those through cgroup somtimes is because it seems easier to add those new features through cgroup, which may be true to some degree, but shortcuts often aren't very conducive to long term maintainability.
2. As noted above, just having cgroup often excludes a signficant portion of use cases. Not all systems enable cgroups and programatic accesses from target processes / threads are coarse-grained and can be really awakward.
3. Cgroup can be convenient when group config change is necessary. However, we really don't want to keep adding kernel interface just for changing configs for a group of threads. For config changes which aren't high frequency, userspace iterating the member processes and applying the changes if possible is usually good enough which usually involves looping until no new process is found. If the looping is problematic, cgroup freezer can be used to atomically stop all member threads to provide atomicity too.
Thanks.
Signature · 1 line
tejun
Quoted 8 lines · On Fri, Nov 10, 2023 at 05:05:50PM -1000, [email protected] wrote:
Hello, Gregory.
Quoted 2 lines · Gregory Price
Unfortunately mpol has no way of being changed from outside the task itself once it's applied, other than changing its nodemasks via cpusets.
Maybe it's time to add one?
I've been considering this as well, but there's more context here being lost. It's not just about being able to toggle the policy of a single task, or related tasks, but actually in support of a more global data interleaving strategy that makes use of bandwidth more effectively as we begin to memory expansion and bandwidth expansion occur on the PCIE/CXL bus.
If the memory landscape of a system changes, for example due to a hotplug event, you actually want to change the behavior of *every* task that is using interleaving. The fundamental bandwidth distribution of the entire system changed, so the behavior of every task using that memory should change with it.
We've explored adding weights to: mempolicy, memory tiers, nodes, memcg, and now additionally cpusets. In the last email, I'd asked whether it might actually be worth adding a new mpol component of cgroups to aggregate these issues, rather than jam them into either component. I would love your thoughts on that.
Quoted 11 lines
Quoted 5 lines
So one concrete use case: kubernetes might like change cpusets or move tasks from one cgroup to another, or a vm might be migrated from one set of nodes to enother (technically not mutually exclusive here). Some memory policy settings (like weights) may no longer apply when this happens, so it would be preferable to have a way to change them.
Neither covers all use cases. As you noted in your mempolicy message, if the application wants finer grained control, cgroup interface isn't great. In general, any changes which are dynamically initiated by the application itself isn't a great fit for cgroup.
It is certainly simple enough to add weights to mempolicy, but there are limitations. In particular, mempolicy is extremely current task focused, and significant refactor work would need to be done to allow external tasks the ability to toggle a target task's mempolicy.
In particular I worry about the potential concurrency issues since mempolicy can be in the hot allocation path.
(additionally, as you note below, you would have to hit every child thread separately to make effective changes, since it is per-task).
I'm not opposed to this, but it was suggested to me that maybe there is a better place to place these weights. Maybe it can be managed mostly through RCU, though, so maybe the concern is overblow.
Anyway...
It's certainly my intent to add weights to mempolicy, as that's where I started. If that is the preferred starting point from the perspective of the mm community, I will revert to proposing set_mempolicy2 and/or full on converting mempolicy into a sys/procfs friendly mechanism.
The goal here is to enable mempolicy, or something like it, to acquire additional flexibility in a heterogeneous memory world, considering how threads may be migrated, checkpointed/restored, and how use cases like bandwidth expansion may be insufficiently serviced by something as fine grained as per-task mempolicies.
Quoted 9 lines
I'm generally pretty awry of adding non-resource group configuration interface especially when they don't have counter part in the regular per-process/thread API for a few reasons:
1. The reason why people try to add those through cgroup somtimes is because it seems easier to add those new features through cgroup, which may be true to some degree, but shortcuts often aren't very conducive to long term maintainability.
Concur. That's why i originally proposed the mempolicy extension, since I wasn't convinced by global settings, but I've been brought around by the fact that migrations and hotplug events may want to affect mass changes across a large number of unrelated tasks.
Quoted 4 lines
2. As noted above, just having cgroup often excludes a signficant portion of use cases. Not all systems enable cgroups and programatic accesses from target processes / threads are coarse-grained and can be really awakward.
Quoted 9 lines
3. Cgroup can be convenient when group config change is necessary. However, we really don't want to keep adding kernel interface just for changing configs for a group of threads. For config changes which aren't high frequency, userspace iterating the member processes and applying the changes if possible is usually good enough which usually involves looping until no new process is found. If the looping is problematic, cgroup freezer can be used to atomically stop all member threads to provide atomicity too.
If I can ask, do you think it would be out of line to propose a major refactor to mempolicy to enable external task's the ability to change a running task's mempolicy *as well as* a cgroup-wide mempolicy component?
As you've alluded to here, I don't think either mechanism on their own is sufficient to handle all use cases, but the two combined does seem sufficient.
I do appreciate the feedback here, thank you. I think we are getting to the bottom of how/where such new mempolicy mechanisms should be implemented.
Gregory:
[email protected]
maintainerHello,
Quoted 1 line · Gregory Price
On Fri, Nov 10, 2023 at 05:05:50PM -1000, [email protected] wrote:
...
Quoted 13 lines
I've been considering this as well, but there's more context here being lost. It's not just about being able to toggle the policy of a single task, or related tasks, but actually in support of a more global data interleaving strategy that makes use of bandwidth more effectively as we begin to memory expansion and bandwidth expansion occur on the PCIE/CXL bus.
If the memory landscape of a system changes, for example due to a hotplug event, you actually want to change the behavior of *every* task that is using interleaving. The fundamental bandwidth distribution of the entire system changed, so the behavior of every task using that memory should change with it.
Quoted 5 lines
We've explored adding weights to: mempolicy, memory tiers, nodes, memcg, and now additionally cpusets. In the last email, I'd asked whether it might actually be worth adding a new mpol component of cgroups to aggregate these issues, rather than jam them into either component. I would love your thoughts on that.
As for CXL and the changing memory landscape, I think some caution is necessary as with any expected "future" technology changes. The recent example with non-volatile memory isn't too far from CXL either. Note that this is not to say that we shouldn't change anything until the hardware is wildly popular but more that we need to be cognizant of the speculative nature and the possibility of overbuilding for it.
I don't have a golden answer but here are general suggestions: Build something which is small and/or useful even outside the context of the expected hardware landscape changes. Enable the core feature which is absolutely required in a minimal manner. Avoid being maximalist in feature and convenience coverage.
Here, even if CXL actually becomes popular, how many are going to use memory hotplug and need to dynamically rebalance memory in actively running workloads? What's the scenario? Are there going to be an army of data center technicians going around plugging and unplugging CXL devices depending on system memory usage?
Maybe there are some cases this is actually useful but for those niche use cases, isn't per-task interface with iteration enough? How often are these hotplug events going to be?
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
So one concrete use case: kubernetes might like change cpusets or move tasks from one cgroup to another, or a vm might be migrated from one set of nodes to enother (technically not mutually exclusive here). Some memory policy settings (like weights) may no longer apply when this happens, so it would be preferable to have a way to change them.
Neither covers all use cases. As you noted in your mempolicy message, if the application wants finer grained control, cgroup interface isn't great. In general, any changes which are dynamically initiated by the application itself isn't a great fit for cgroup.
Quoted 7 lines
It is certainly simple enough to add weights to mempolicy, but there are limitations. In particular, mempolicy is extremely
current taskfocused, and significant refactor work would need to be done to allow external tasks the ability to toggle a target task's mempolicy.In particular I worry about the potential concurrency issues since mempolicy can be in the hot allocation path.
Changing mpol from outside the task is a feature which is inherently useful regardless of CXL and I don't quite understand why hot path concurrency issues would be different whether the configuration is coming from mempol or cgroup but that could easily be me not being familiar with the involved code.
...
Quoted 10 lines
Quoted 9 lines
3. Cgroup can be convenient when group config change is necessary. However, we really don't want to keep adding kernel interface just for changing configs for a group of threads. For config changes which aren't high frequency, userspace iterating the member processes and applying the changes if possible is usually good enough which usually involves looping until no new process is found. If the looping is problematic, cgroup freezer can be used to atomically stop all member threads to provide atomicity too.
Quoted 3 lines
If I can ask, do you think it would be out of line to propose a major refactor to mempolicy to enable external task's the ability to change a running task's mempolicy *as well as* a cgroup-wide mempolicy component?
I don't think these group configurations fit cgroup filesystem interface very well. As these aren't resource allocations, it's unclear what the hierarchical relationship means. Besides, it feels awkard to be keep adding duplicate interfaces where the modality changes completely based on the operation scope.
There are ample examples where other subsystems use cgroup membership information and while we haven't expanded that to syscalls yet, I don't see why that'd be all that difference. So, maybe it'd make sense to have the new mempolicy syscall take a cgroup ID as a target identifier too? ie. so that the scope of the operation (e.g. task, process, cgroup) and the content of the policy can stay orthogonal?
Thanks.
Signature · 1 line
tejun
Quoted 31 lines · [email protected] wrote:
Hello,
Quoted 1 line · Gregory Price
On Fri, Nov 10, 2023 at 05:05:50PM -1000, [email protected] wrote:
...
Quoted 13 lines
I've been considering this as well, but there's more context here being lost. It's not just about being able to toggle the policy of a single task, or related tasks, but actually in support of a more global data interleaving strategy that makes use of bandwidth more effectively as we begin to memory expansion and bandwidth expansion occur on the PCIE/CXL bus.
If the memory landscape of a system changes, for example due to a hotplug event, you actually want to change the behavior of *every* task that is using interleaving. The fundamental bandwidth distribution of the entire system changed, so the behavior of every task using that memory should change with it.
Quoted 5 lines
We've explored adding weights to: mempolicy, memory tiers, nodes, memcg, and now additionally cpusets. In the last email, I'd asked whether it might actually be worth adding a new mpol component of cgroups to aggregate these issues, rather than jam them into either component. I would love your thoughts on that.
As for CXL and the changing memory landscape, I think some caution is necessary as with any expected "future" technology changes. The recent example with non-volatile memory isn't too far from CXL either. Note that this is not to say that we shouldn't change anything until the hardware is wildly popular but more that we need to be cognizant of the speculative nature and the possibility of overbuilding for it.
Quoted 5 lines
I don't have a golden answer but here are general suggestions: Build something which is small and/or useful even outside the context of the expected hardware landscape changes. Enable the core feature which is absolutely required in a minimal manner. Avoid being maximalist in feature and convenience coverage.
If I had to state the golden rule of kernel enabling, this paragraph comes close to being it.
Quoted 5 lines
Here, even if CXL actually becomes popular, how many are going to use memory hotplug and need to dynamically rebalance memory in actively running workloads? What's the scenario? Are there going to be an army of data center technicians going around plugging and unplugging CXL devices depending on system memory usage?
While I have personal skepticism that all of the infrastructure in the CXL specification is going to become popular, one mechanism that seems poised to cross that threshold is "dynamic capacity". So it is not the case that techs are running around hot-adjusting physical memory. A host will have a cable hop to a shared memory pool in the rack where it can be dynamically provisioned across hosts.
However, even then the bounds of what is dynamic is going to be constrained to a fixed address space with likely predictable performance characteristics for that address range. That potentially allows for a system wide memory interleave policy to be viable. That might be the place to start and mirrors, at a coarser granularity, what hardware interleaving can do.
[..]
Quoted 19 lines · Dan Williams
Quoted 10 lines · [email protected] wrote:
Hello,
Quoted 1 line · Gregory Price
On Fri, Nov 10, 2023 at 05:05:50PM -1000, [email protected] wrote:
Here, even if CXL actually becomes popular, how many are going to use memory hotplug and need to dynamically rebalance memory in actively running workloads? What's the scenario? Are there going to be an army of data center technicians going around plugging and unplugging CXL devices depending on system memory usage?
While I have personal skepticism that all of the infrastructure in the CXL specification is going to become popular, one mechanism that seems poised to cross that threshold is "dynamic capacity". So it is not the case that techs are running around hot-adjusting physical memory. A host will have a cable hop to a shared memory pool in the rack where it can be dynamically provisioned across hosts.
Quoted 8 lines
However, even then the bounds of what is dynamic is going to be constrained to a fixed address space with likely predictable performance characteristics for that address range. That potentially allows for a system wide memory interleave policy to be viable. That might be the place to start and mirrors, at a coarser granularity, what hardware interleaving can do.
[..]
Funny enough, this is exactly why I skipped cgroups and went directly to implementing the weights as an attribute of numa nodes. It cuts out a middle-man and lets you apply weights globally.
BUT the policy is still ultimately opt-in, so you don't really get a global effect, just a global control. Just given that lesson, yeah it's better to reduce the scope to mempolicy first.
Getting to global interleave weights from there... more complicated.
The simplees way I can think of to test system-wide weighted interleave is to have the init task create a default mempolicy and have all tasks inherit it. That feels like a big, dumb hammer - but it might work.
Comparatively, implementing a mempolicy in the root cgroup and having tasks use that directly "feels" better, though lessons form this patch
- interating cgroup parent trees on allocations feels not great.
Barring that, if a cgroup.mempolicy and a default mempolicy for init aren't realistic, I don't see a good path to fruition for a global interleave approach that doesn't require nastier allocator changes.
In the meantime, unless there's other pro-cgroups voices, I'm going to pivot back to my initial approach of doing it in mempolicy, though I may explore extending mempolicy into procfs at the same time.
~Gregory
Michal Hocko
reviewerOn Fri 10-11-23 22:42:39, Gregory Price wrote:
[...]
Quoted 3 lines
If I can ask, do you think it would be out of line to propose a major refactor to mempolicy to enable external task's the ability to change a running task's mempolicy *as well as* a cgroup-wide mempolicy component?
No, I actually think this is a reasonable idea. pidfd_setmempolicy is a generally useful extension. The mempolicy code is heavily current task based and there might be some challenges but I believe this will a) improve the code base and b) allow more usecases.
That being said, I still believe that a cgroup based interface is a much better choice over a global one. Cpusets seem to be a good fit as the controller does control memory placement wrt NUMA interfaces.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 10 lines · Michal Hocko
On Fri 10-11-23 22:42:39, Gregory Price wrote:
[...]Quoted 3 lines
If I can ask, do you think it would be out of line to propose a major refactor to mempolicy to enable external task's the ability to change a running task's mempolicy *as well as* a cgroup-wide mempolicy component?
No, I actually think this is a reasonable idea.
pidfd_setmempolicyis a generally useful extension. The mempolicy code is heavily current task based and there might be some challenges but I believe this will a) improve the code base and b) allow more usecases.
Just read up on the pidfd_set_mempolicy lore, and yes I'm seeing all the same problems (I know there was discussion of vma policies, but i think that can be a topic for later). Have some thoughts on this, but will take some time to work through a few refactoring tickets first.
Quoted 4 lines
That being said, I still believe that a cgroup based interface is a much better choice over a global one. Cpusets seem to be a good fit as the controller does control memory placement wrt NUMA interfaces.
I think cpusets is a non-starter due to the global spinlock required when reading informaiton from it:
https://elixir.bootlin.com/linux/latest/source/kernel/cgroup/cpuset.c#L391
Unless the proposal is to place the weights as a global cgroups value, in which case I think it would be better placed in default_mempolicy :]
Michal Hocko
reviewerQuoted 1 line · Gregory Price
On Tue, Nov 14, 2023 at 10:43:13AM +0100, Michal Hocko wrote:
[...]
Quoted 8 lines
Quoted 3 lines
That being said, I still believe that a cgroup based interface is a much better choice over a global one. Cpusets seem to be a good fit as the controller does control memory placement wrt NUMA interfaces.
I think cpusets is a non-starter due to the global spinlock required when reading informaiton from it:
https://elixir.bootlin.com/linux/latest/source/kernel/cgroup/cpuset.c#L391
Right, our current cpuset implementation indeed requires callback lock from the page allocator. But that is an implementation detail. I do not remember bug reports about the lock being a bottle neck though. If anything cpusets lock optimizations would be win also for users who do not want to use weighted interleave interface.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 10 lines · Michal Hocko
Quoted 1 line · Gregory Price
On Tue, Nov 14, 2023 at 10:43:13AM +0100, Michal Hocko wrote:
[...]
Quoted 7 lines
Quoted 3 lines
That being said, I still believe that a cgroup based interface is a much better choice over a global one. Cpusets seem to be a good fit as the controller does control memory placement wrt NUMA interfaces.
I think cpusets is a non-starter due to the global spinlock required when reading informaiton from it:
Quoted 7 lines
Right, our current cpuset implementation indeed requires callback lock from the page allocator. But that is an implementation detail. I do not remember bug reports about the lock being a bottle neck though. If anything cpusets lock optimizations would be win also for users who do not want to use weighted interleave interface.
Definitely agree, but that's a rather large increase of scope :[
We could consider a push-model similar to how cpuset nodemasks are pushed down to mempolicies, rather than a pull-model of having mempolicy read directly from cpusets, at least until cpusets lock optimization is undertaken.
This pattern looks like a wart to me, which is why I avoided it, but the locking implications on the pull-model make me sad.
Would like to point out that Tejun pushed back on implementing weights in cgroups (regardless of subcomponent), so I think we need to come to a consensus on where this data should live in a "more global" context (cpusets, memcg, nodes, etc) before I go mucking around further.
So far we have:
* mempolicy: updating weights is a very complicated undertaking, and no (good) way to do this from outside the task. would be better to have a coarser grained control.
New syscall is likely needed to add/set weights in the per-task mempolicy, or bite the bullet on set_mempolicy2 and make the syscall extensible for the future.
* memtiers: tier=node when devices are already interleaved or when all devices are different, so why add yet another layer of complexity if other constructs already exist. Additionally, you lose task-placement relative weighting (or it becomes very complex to implement.
* cgroups: "this doesn't involve dynamic resource accounting / enforcement at all" and "these aren't resource allocations, it's unclear what the hierarchical relationship mean".
* node: too global, explore smaller scope first then expand.
For now I think there is consensus that mempolicy should have weights per-task regardless of how the more-global mechanism is defined, so i'll go ahead and put up another RFC for some options on that in the next week or so.
The limitations on the first pass will be that only the task is capable of re-weighting should cpusets.mems or the nodemask change.
~Gregory
Quoted 44 lines · Gregory Price
Quoted 10 lines · Michal Hocko
Quoted 1 line · Gregory Price
On Tue, Nov 14, 2023 at 10:43:13AM +0100, Michal Hocko wrote:
[...]
Quoted 7 lines
Quoted 3 lines
That being said, I still believe that a cgroup based interface is a much better choice over a global one. Cpusets seem to be a good fit as the controller does control memory placement wrt NUMA interfaces.
I think cpusets is a non-starter due to the global spinlock required when reading informaiton from it:
Quoted 7 lines
Right, our current cpuset implementation indeed requires callback lock from the page allocator. But that is an implementation detail. I do not remember bug reports about the lock being a bottle neck though. If anything cpusets lock optimizations would be win also for users who do not want to use weighted interleave interface.
Definitely agree, but that's a rather large increase of scope :[
We could consider a push-model similar to how cpuset nodemasks are pushed down to mempolicies, rather than a pull-model of having mempolicy read directly from cpusets, at least until cpusets lock optimization is undertaken.
This pattern looks like a wart to me, which is why I avoided it, but the locking implications on the pull-model make me sad.
Would like to point out that Tejun pushed back on implementing weights in cgroups (regardless of subcomponent), so I think we need to come to a consensus on where this data should live in a "more global" context (cpusets, memcg, nodes, etc) before I go mucking around further.
So far we have:
* mempolicy: updating weights is a very complicated undertaking, and no (good) way to do this from outside the task. would be better to have a coarser grained control.New syscall is likely needed to add/set weights in the per-task mempolicy, or bite the bullet on
set_mempolicy2and make the syscall extensible for the future.
Quoted 5 lines
* memtiers: tier=node when devices are already interleaved or when all devices are different, so why add yet another layer of complexity if other constructs already exist. Additionally, you lose task-placement relative weighting (or it becomes very complex to implement.
Because we usually have multiple nodes in one mem-tier, I still think mem-tier-based interface is simpler than node-based. But, it seems more complex to introduce mem-tier into mempolicy. Especially if we have per-task weights. So, I am fine to go with node-based interface.
Quoted 6 lines
* cgroups: "this doesn't involve dynamic resource accounting / enforcement at all" and "these aren't resource allocations, it's unclear what the hierarchical relationship mean".
* node: too global, explore smaller scope first then expand.
Why is it too global? I understand that it doesn't cover all possible use cases (although I don't know whether these use cases are practical or not). But it can provide a reasonable default per-node weight based on available node performance information (such as, HMAT, CDAT, etc.). And, quite some workloads can just use it. I think this is an useful feature.
Quoted 7 lines
For now I think there is consensus that mempolicy should have weights per-task regardless of how the more-global mechanism is defined, so i'll go ahead and put up another RFC for some options on that in the next week or so.
The limitations on the first pass will be that only the task is capable of re-weighting should cpusets.mems or the nodemask change.
--
Best Regards,
Huang, Ying
Quoted 12 lines · Ying
Gregory Price <[email protected]> writes:
Because we usually have multiple nodes in one mem-tier, I still think mem-tier-based interface is simpler than node-based. But, it seems more complex to introduce mem-tier into mempolicy. Especially if we have per-task weights. So, I am fine to go with node-based interface.
Quoted 5 lines
* cgroups: "this doesn't involve dynamic resource accounting / enforcement at all" and "these aren't resource allocations, it's unclear what the hierarchical relationship mean".
Quoted 9 lines
Quoted 1 line
* node: too global, explore smaller scope first then expand.
Why is it too global? I understand that it doesn't cover all possible use cases (although I don't know whether these use cases are practical or not). But it can provide a reasonable default per-node weight based on available node performance information (such as, HMAT, CDAT, etc.). And, quite some workloads can just use it. I think this is an useful feature.
Have been sharing notes with more folks. Michal thinks a global set of weights is unintuitive and not useful, and would prefer to see the per-task weights first.
Though this may have been in response to adding it as an attribute of nodes directly.
Another proposal here suggested adding a new sysfs setting
https://github.com/skhynix/linux/commit/61d2fcc7a880185df186fa2544edcd2f8785952a
$ tree /sys/kernel/mm/interleave_weight/
/sys/kernel/mm/interleave_weight/
├── enabled [1]
├── possible [2]
└── node
├── node0
│ └── interleave_weight [3]
└── node1
└── interleave_weight [3](this could be changed to /sys/kernel/mm/mempolicy/...)
I think the internal representation of this can be simplified greatly, over what the patch provides now, but maybe this solves the "it doesn't belong in these other components" issue.
Answer: Simply leave it as a static global kobject in mempolicy, which also deals with many of the issues regarding race conditions.
If a user provides weights, use those. If they do not, use globals.
On a cpuset rebind event (container migration, mems_allowed changes), manually set weights would have to remain, so in a bad case, the weights would be very out of line with the real distribution of memory.
Example: if your nodemask is (0,1,2) and a migration changes it to (3,4,5), then unfortunately your weights will likely revert to [1,1,1]
If set with global weights, they could automatically adjust. It would not be perfect, but it would be better than the potential worst case above. If that same migration occurs, the next allocation would simply use whatever the target node weights are in the global config.
So if globally you have weights [3,2,1,1,2,3], and you move from nodemask (0,1,2) to (3,4,5), your weights change from [3,2,1] to [1,2,3]. If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
That feels very intuitive, deals with many race condition issues, and the global setting can actually be implemented without the need for set_mempolicy2 at all - which is certainly a bonus.
Would love more thoughts here. Will have a new RFC with set_mempolicy2, mbind2, and MPOL_WEIGHTED_INTERLEAVE soon that demonstrate the above.
Regards
~Gregory
Quoted 43 lines · Gregory Price
Quoted 12 lines · Ying
Gregory Price <[email protected]> writes:
Because we usually have multiple nodes in one mem-tier, I still think mem-tier-based interface is simpler than node-based. But, it seems more complex to introduce mem-tier into mempolicy. Especially if we have per-task weights. So, I am fine to go with node-based interface.
Quoted 5 lines
* cgroups: "this doesn't involve dynamic resource accounting / enforcement at all" and "these aren't resource allocations, it's unclear what the hierarchical relationship mean".
Quoted 9 lines
Quoted 1 line
* node: too global, explore smaller scope first then expand.
Why is it too global? I understand that it doesn't cover all possible use cases (although I don't know whether these use cases are practical or not). But it can provide a reasonable default per-node weight based on available node performance information (such as, HMAT, CDAT, etc.). And, quite some workloads can just use it. I think this is an useful feature.
Have been sharing notes with more folks. Michal thinks a global set of weights is unintuitive and not useful, and would prefer to see the per-task weights first.
Though this may have been in response to adding it as an attribute of nodes directly.
Another proposal here suggested adding a new sysfs setting
https://github.com/skhynix/linux/commit/61d2fcc7a880185df186fa2544edcd2f8785952a$ tree /sys/kernel/mm/interleave_weight/ /sys/kernel/mm/interleave_weight/ ├── enabled [1] ├── possible [2] └── node ├── node0 │ └── interleave_weight [3] └── node1 └── interleave_weight [3]
Quoted 8 lines
(this could be changed to
/sys/kernel/mm/mempolicy/...)I think the internal representation of this can be simplified greatly, over what the patch provides now, but maybe this solves the "it doesn't belong in these other components" issue.
Answer: Simply leave it as a static global kobject in mempolicy, which also deals with many of the issues regarding race conditions.
Although personally I prefer to add interleave weight as an attribute of nodes. I understand that some people think it's not appropriate to place anything node-specific there. So, some place under /sys/kernel/mm sounds reasonable too.
Quoted 1 line
If a user provides weights, use those. If they do not, use globals.
Yes. That is the target use case.
Quoted 7 lines
On a cpuset rebind event (container migration,
mems_allowedchanges), manually set weights would have to remain, so in a bad case, the weights would be very out of line with the real distribution of memory.Example: if your nodemask is (0,1,2) and a migration changes it to (3,4,5), then unfortunately your weights will likely revert to [1,1,1]
Quoted 8 lines
If set with global weights, they could automatically adjust. It would not be perfect, but it would be better than the potential worst case above. If that same migration occurs, the next allocation would simply use whatever the target node weights are in the global config.
So if globally you have weights [3,2,1,1,2,3], and you move from nodemask (0,1,2) to (3,4,5), your weights change from [3,2,1] to [1,2,3].
That is nice. And I prefer to emphasize the simple use case. Users don't need to specify interleave weight always. Just use MPOL_WEIGHTED_INTERLEAVE policy, and system will provide reasonable default weight.
Quoted 2 lines
If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
The matrix stuff makes the situation complex. If people do need something like that, they can just use set_memorypolicy2() with user specified weights. I still believe that "make simple stuff simple, and complex stuff possible".
Quoted 6 lines
That feels very intuitive, deals with many race condition issues, and the global setting can actually be implemented without the need for
set_mempolicy2at all - which is certainly a bonus.Would love more thoughts here. Will have a new RFC with
set_mempolicy2, mbind2, andMPOL_WEIGHTED_INTERLEAVEsoon that demonstrate the above.
Thanks for doing all these!
--
Best Regards,
Huang, Ying
Quoted 10 lines · Ying
Quoted 2 lines · Gregory Price
If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
The matrix stuff makes the situation complex. If people do need something like that, they can just use
set_memorypolicy2()with user specified weights. I still believe that "make simple stuff simple, and complex stuff possible".
I don't think it's particularly complex, since we already have a distance matrix for numa nodes:
available: 2 nodes (0-1)
... snip ...
node distances:
node 0 1
0: 10 21 1: 21 10
This would follow the same thing, just adjustable for bandwidth.
I personally find the (src,dst) matrix very important for flexibility.
But if there is particular pushback against it, having a one dimensional array is better than not having it, so I will take what I can get.
Quoted 9 lines
Quoted 6 lines
That feels very intuitive, deals with many race condition issues, and the global setting can actually be implemented without the need for
set_mempolicy2at all - which is certainly a bonus.Would love more thoughts here. Will have a new RFC with
set_mempolicy2, mbind2, andMPOL_WEIGHTED_INTERLEAVEsoon that demonstrate the above.Thanks for doing all these!
Someone's got to :]
~Gregory
Quoted 15 lines · Gregory Price
Quoted 10 lines · Ying
Quoted 2 lines · Gregory Price
If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
The matrix stuff makes the situation complex. If people do need something like that, they can just use
set_memorypolicy2()with user specified weights. I still believe that "make simple stuff simple, and complex stuff possible".I don't think it's particularly complex, since we already have a distance matrix for numa nodes:
Quoted 8 lines
available: 2 nodes (0-1)
... snip ...
node distances:
node 0 10: 10 21 1: 21 10This would follow the same thing, just adjustable for bandwidth.
We add complexity for requirement. Not there's something similar already.
Quoted 1 line
I personally find the (src,dst) matrix very important for flexibility.
With set_memorypolicy2(), I think we have the needed flexibility for users needs the complexity.
Quoted 2 lines
But if there is particular pushback against it, having a one dimensional array is better than not having it, so I will take what I can get.
TBH, I don't think that we really need that. Especially given we will have set_memorypolicy2().
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
That feels very intuitive, deals with many race condition issues, and the global setting can actually be implemented without the need for
set_mempolicy2at all - which is certainly a bonus.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Would love more thoughts here. Will have a new RFC with
set_mempolicy2, mbind2, andMPOL_WEIGHTED_INTERLEAVEsoon that demonstrate the above.Thanks for doing all these!
Someone's got to :]
--
Best Regards,
Huang, Ying
Quoted 31 lines · Ying
Quoted 15 lines · Gregory Price
Quoted 10 lines · Ying
Quoted 2 lines · Gregory Price
If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
The matrix stuff makes the situation complex. If people do need something like that, they can just use
set_memorypolicy2()with user specified weights. I still believe that "make simple stuff simple, and complex stuff possible".I don't think it's particularly complex, since we already have a distance matrix for numa nodes:
Quoted 8 lines
available: 2 nodes (0-1)
... snip ...
node distances:
node 0 10: 10 21 1: 21 10This would follow the same thing, just adjustable for bandwidth.
We add complexity for requirement. Not there's something similar already.
Quoted 1 line
I personally find the (src,dst) matrix very important for flexibility.
Quoted 9 lines
With
set_memorypolicy2(), I think we have the needed flexibility for users needs the complexity.Quoted 2 lines
But if there is particular pushback against it, having a one dimensional array is better than not having it, so I will take what I can get.
TBH, I don't think that we really need that. Especially given we will have
set_memorypolicy2().
From a complexity standpoint, it is exactly as complex as the hardware configuration itself: each socket has a different view of the memory topology. If you have a non-homogeneous memory configuration (e.g. a different number of CXL expanders on one socket thant he other), a flat array of weights has no way of capturing this hardware configuration.
That makes the feature significantly less useful. In fact, it makes the feature equivalent to set_mempolicy2 - except that weights could be changed at runtime from outside a process.
A matrix resolves one very specific use case: task migration
set_mempolicy2 is not sufficient to solve this. There is presently no way for an external task to change the mempolicy of an existing task. That means a task must become "migration aware" to use weighting in the context of containers where migrations are likely.
Two things to consider: A task...
a) has no way of knowing a migration occured
b) may not have visibility of numa nodes outside its cpusets prior to a migration - making it unlikely/not possible for them to set weights correctly in the event a migration occurs.
If a server with 2 sockets is set up non-homogeneously (different amount of CXL memory expanders on each socket), then the effective bandwidth distribution between sockets will be different.
If a container is migrated between sockets in this situation, then tasks with manually set weights, or if global weights are a single array, will have poor memory distributions in relation to the new view of the system.
Requiring the global settings to be an array basically requires global weights to be sub-optimal for any use cases that is not explicitly a single workload that consumes all the cores on the system.
If the system provides a matrix, then the global settings can be optimal and re-weighting in response to migration happens cleanly and transparently.
~Gregory
Quoted 42 lines · Gregory Price
Quoted 31 lines · Ying
Quoted 15 lines · Gregory Price
Quoted 10 lines · Ying
Quoted 2 lines · Gregory Price
If the structure is built as a matrix of (cpu_node,mem_nodes), the you can also optimize based on the node the task is running on.
The matrix stuff makes the situation complex. If people do need something like that, they can just use
set_memorypolicy2()with user specified weights. I still believe that "make simple stuff simple, and complex stuff possible".I don't think it's particularly complex, since we already have a distance matrix for numa nodes:
Quoted 8 lines
available: 2 nodes (0-1)
... snip ...
node distances:
node 0 10: 10 21 1: 21 10This would follow the same thing, just adjustable for bandwidth.
We add complexity for requirement. Not there's something similar already.
Quoted 1 line
I personally find the (src,dst) matrix very important for flexibility.
Quoted 9 lines
With
set_memorypolicy2(), I think we have the needed flexibility for users needs the complexity.Quoted 2 lines
But if there is particular pushback against it, having a one dimensional array is better than not having it, so I will take what I can get.
TBH, I don't think that we really need that. Especially given we will have
set_memorypolicy2().
Quoted 5 lines
From a complexity standpoint, it is exactly as complex as the hardware configuration itself: each socket has a different view of the memory topology. If you have a non-homogeneous memory configuration (e.g. a different number of CXL expanders on one socket thant he other), a flat array of weights has no way of capturing this hardware configuration.
One important task of the software is to hide the complexity of hardware from the users. At least it should provide the option. It only add complexity based on real requirements.
Quoted 27 lines
That makes the feature significantly less useful. In fact, it makes the feature equivalent to
set_mempolicy2- except that weights could be changed at runtime from outside a process.A matrix resolves one very specific use case: task migration
set_mempolicy2is not sufficient to solve this. There is presently no way for an external task to change the mempolicy of an existing task. That means a task must become "migration aware" to use weighting in the context of containers where migrations are likely.Two things to consider: A task...
a) has no way of knowing a migration occured
b) may not have visibility of numa nodes outside its cpusets prior to a migration - making it unlikely/not possible for them to set weights correctly in the event a migration occurs.If a server with 2 sockets is set up non-homogeneously (different amount of CXL memory expanders on each socket), then the effective bandwidth distribution between sockets will be different.
If a container is migrated between sockets in this situation, then tasks with manually set weights, or if global weights are a single array, will have poor memory distributions in relation to the new view of the system.
Quoted 6 lines
Requiring the global settings to be an array basically requires global weights to be sub-optimal for any use cases that is not explicitly a single workload that consumes all the cores on the system.
If the system provides a matrix, then the global settings can be optimal and re-weighting in response to migration happens cleanly and transparently.
For these complex requirements, we will have process_set_mempolicy2(). I think that it's even more flexible than the global matrix.
--
Best Regards,
Huang, Ying
Quoted 8 lines · Ying
Quoted 6 lines · Gregory Price
From a complexity standpoint, it is exactly as complex as the hardware configuration itself: each socket has a different view of the memory topology. If you have a non-homogeneous memory configuration (e.g. a different number of CXL expanders on one socket thant he other), a flat array of weights has no way of capturing this hardware configuration.
Quoted 4 lines
One important task of the software is to hide the complexity of hardware from the users. At least it should provide the option. It only add complexity based on real requirements.
The global weights are intended to help adminstrators hide that complexity from actual end-users.
The administrator of a system should already be aware of the hardware configuration, however to hide this complexity a system service can be made which auto-configures these weights at system-bringup and on memory-device hostplug to simplify and hide the complexity even further.
A system service can use ACPI HMAT (ACPI Heterogeneous Memory Attribute Table) information to automatically set the global weight information at boot time and/or on hotplug. Such extensions have already been proposed in prior RFCs and on the cxl mailing list.
To break this down a little more explicitly into 6 example use-cases, lets consider the potential ways in which weighted interleave may be set via set_mempolicy or set_mempolicy2().
1. Actual end-user software calls it directly (or through libnuma)
a) they can call set_mempolicy() without task-weights and accept the administrator configured global weights
b) they can call set_mempolicy2() with task-weights and use task-local defined weighting
2. Actual end-user uses numactl -w[weights] --interleave ...
a) if weights are not defined, use global weights
b) if weights are defined, use task-local weights
3. Administrator / Orchestrator opts user-software into weighted interleave by wrapping their software into numactl -w --interleave
a) if weights are not defined, use global weights
b) if weights are not defined, use task-local weights
The most common use case is likely to be (3a) - an administrator opting a user-workload into weighted-interleave via numactl -w --interleave or an orchestrator such as kubernetes doing something similar on pod/container dispatching.
In all cases where the user does not define weights, they are trusting the administrator (or system-daemon) set weights to provide the optimal distribution, removing the complexity of understanding the hardware environment from the end-user.
In all cases where the user does define weights, they are accepting the complexity of understanding the hardware environment.
On the topic of the ACTUAL complexity of system hardware that is being hidden, we must consider a non-homogeneous bandwidth environment. The simplest form is an off the shelf Intel 2-socket server with CXL memory expander.
Lets Consider a 2 socket system with the following configuration::
DRAM on Socket0: 300GB/s local DRAM bandwidth (node 0) DRAM on Socket1: 300GB/s local DRAM bandwidth (node 1) CXL on socket0: 128GB/s bandwidth (node 2) CXL on socket1: 128GB/s bandwidth (node 3)
A single linear array of weights is not sufficient to capture the complexities of bandwidth distributions on this system, because of the presence of a UPI link between socket0 and socket1, which changes the bandwidth distribution depending on where a task runs.
For example, 3 links of UPI is 62.4GB/s full-duplex.
From the perspective of socket 0, the following is true:
Bandwidth to Socket0 DRAM: 300GB/s (node 0) Bandwidth to Socket0 CXL: 100GB/s (node 2)
Aggregate bandwidth to nodes (1,3): 62.4GB/s
From the perspective of socket 1, this changes to:
Bandwidth to Socket0 DRAM: 300GB/s (node 1) Bandwidth to Socket0 CXL: 100GB/s (node 3)
Aggregate bandwidth to nodes (0,2): 62.4GB/s
With a single linear array of weights that apply to the entire system, you cannot represent this configuration. And in fact, a single configuration of weights will always provide a sub-optimal distribution.
The goal of simplicity defeats the entire goal of weighted interleave in a heterogeneous environment.
Quoted 4 lines
For these complex requirements, we will have
process_set_mempolicy2(). I think that it's even more flexible than the global matrix.
process_set_mempolicy2() has a *very* long road to exist. The problem of mempolicy reference counting is non-trivial, and the plumbing requires changes to no less than 4 subsystems.
Beyond that, the complexity of actually using process_set_mempolicy2() is the same as any situation in which set_mempolicy2() with task-local weights set: The absolute highest.
The global weighting matrix actually hides this complexity entirely.
Quoted 3 lines
--
Best Regards,
Huang, Ying
Quoted 7 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
The
il_weightof a node is used by mempolicy to implement weighted interleave whennumactl --interleave=...is invoked. By defaultil_weightfor a node is always 1, which preserves the default round robin interleave behavior.
IIUC, this makes it almost impossible to set the default weight of a node from the node memory bandwidth information. This will make the life of users a little harder.
If so, how about use a new memory policy mode, for example MPOL_WEIGHTED_INTERLEAVE, etc.
Quoted 29 lines
Interleave weights denote the number of pages that should be allocated from the node when interleaving occurs and have a range of 1-255. The weight of a node can never be 0, and instead the preferred way to prevent allocation is to remove the node from the cpuset or mempolicy altogether.
For example, if a node's interleave weight is set to 5, 5 pages will be allocated from that node before the next node is scheduled for allocations.
# Set node weight for node 0 to 5
echo 0:5 >/sys/fs/cgroup/user.slice/memory.interleave_weights# Set node weight for node 1 to 3
echo 1:3 >/sys/fs/cgroup/user.slice/memory.interleave_weights# View the currently set weights
cat/sys/fs/cgroup/user.slice/memory.interleave_weights0:5,1:3Weights will only be displayed for possible nodes.
With this it becomes possible to set an interleaving strategy that fits the available bandwidth for the devices available on the system. An example system:
Node 0 - CPU+DRAM, 400GB/s BW (200 cross socket) Node 1 - CXL Memory. 64GB/s BW, on Node 0 root complex
Quoted 9 lines
In this setup, the effective weights for a node set of [0,1] may be may be [86, 14] (86% of memory on Node 0, 14% on node 1) or some smaller fraction thereof to encourge quicker rounds for better overall distribution.
This spreads memory out across devices which all have different latency and bandwidth attributes in a way that can maximize the available resources.
--
Best Regards,
Huang, Ying
Quoted 10 lines · Ying
Quoted 7 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
The
il_weightof a node is used by mempolicy to implement weighted interleave whennumactl --interleave=...is invoked. By defaultil_weightfor a node is always 1, which preserves the default round robin interleave behavior.
Quoted 7 lines
IIUC, this makes it almost impossible to set the default weight of a node from the node memory bandwidth information. This will make the life of users a little harder.
If so, how about use a new memory policy mode, for example
MPOL_WEIGHTED_INTERLEAVE, etc.
weights are also inherited from parent cgroups, so if you set them in parent slices you can automatically set update system settings.
by default the parent slice weights will always be 1 until set otherwise. Once they're set, children inherit naturally.
Maybe there's an argument here for including interleave_weights in the root cgroup.
~Gregory
Quoted 19 lines · Gregory Price
Quoted 10 lines · Ying
Quoted 7 lines · Gregory Price
This patchset implements weighted interleave and adds a new cgroup sysfs entry: cgroup/memory.interleave_weights (excluded from root).
The
il_weightof a node is used by mempolicy to implement weighted interleave whennumactl --interleave=...is invoked. By defaultil_weightfor a node is always 1, which preserves the default round robin interleave behavior.Quoted 7 lines
IIUC, this makes it almost impossible to set the default weight of a node from the node memory bandwidth information. This will make the life of users a little harder.
If so, how about use a new memory policy mode, for example
MPOL_WEIGHTED_INTERLEAVE, etc.
Quoted 8 lines
weights are also inherited from parent cgroups, so if you set them in parent slices you can automatically set update system settings.
by default the parent slice weights will always be 1 until set otherwise. Once they're set, children inherit naturally.
Maybe there's an argument here for including
interleave_weightsin the root cgroup.
Even if the interleave_weights is introduced in root cgroup, the initial default weight need to be 1 to be back-compatible with the original MPOL_INTERLEAVE.
If we don't reuse MPOL_INTERLEAVE, but use a new memory policy mode (say MPOL_WEIGHTED_INTERLEAVE). The default values of the interleave weight in root cgroup needn't to be 1. So, we can provide a more helpful default interleave weight based on the node memory bandwidth information (e.g., from HMAT, CDAT, etc). That will make users life much easier. Do you agree?
--
Best Regards,
Huang, Ying
Quoted 12 lines · Ying
Quoted 10 lines · Gregory Price
Quoted 2 lines · Ying
Gregory Price <[email protected]> writes:
weights are also inherited from parent cgroups, so if you set them in parent slices you can automatically set update system settings.
by default the parent slice weights will always be 1 until set otherwise. Once they're set, children inherit naturally.
Quoted 7 lines
Quoted 2 lines
Maybe there's an argument here for including
interleave_weightsin the root cgroup.Even if the
interleave_weightsis introduced in root cgroup, the initial default weight need to be 1 to be back-compatible with the originalMPOL_INTERLEAVE.
Sorry, I am maybe not explaining correctly. Right now, the weights are not *replicated* when a child cgroup is created. Instead, when weights are requested (during allocation) the requestor searches for the first cgroup in its family that has weights.
while (!memcg->weights && !memcg_is_root(memcg))
memcg = parent(memcg)
We only create new weights on each child if the child explicitly has their weights set. We manage everything else via RCU to keep it all consistent.
This would allow a set of weights in the root cgroup to be set and then immediately inherited by the entire system, though it does add the overhead of searching the cgroup family lineage on allocations (which could be non-trivial, we are still testing it).
Quoted 3 lines
If we don't reuse
MPOL_INTERLEAVE, but use a new memory policy mode (sayMPOL_WEIGHTED_INTERLEAVE). The default values of the interleave weight in root cgroup needn't to be 1.
I agree, and I already have patches that do just this. Though based on other feedback, it's looking like I'll be reverting back to implementing all of this in mempolicy, and maybe trying to pull mempolicy forward into the procfs world.
~Gregory