On Wed 26-08-26 16:31:56, Eric Chanudet wrote: > On Wed, Aug 26, 2026 at 10:04:27AM +0200, Michal Hocko wrote: > > On Tue 25-08-26 16:58:51, Eric Chanudet wrote: > > > On Tue, Aug 25, 2026 at 09:19:21PM +0200, Michal Hocko wrote: > > > > On Tue 25-08-26 14:33:48, Eric Chanudet wrote: > > > > > On Tue, Aug 25, 2026 at 04:59:52PM +0200, Michal Hocko wrote: > > > > > [...] > > > > > The administrator opts in by mounting cgroupfs with > > > > > memory_cma_accounting. At which point the cma allocator will charge > > > > > CMA > > > > > allocations against memcg and manages a per area counter depending on > > > > > what area the allocation was made into. > > > > > > > > So each CMA area will have its own counter and limits? > > > > > > Yes, in order to enforce a limit per CMA area this series add a page > > > counter for each area. Areas are fixed and discovered early so the > > > counters are added to struct mem_cgroup and initialized when the cgroup > > > is created. > > > > > > An admin would then use the cgroupfs entries to assign an area limit to > > > a given cgroup, something like the following, using the reserved area > > > for example: > > > mount -o remount,memory_cma_accounting /sys/fs/cgroup > > > echo +memory > /sys/fs/cgroup/cgroup.subtree_control > > > mkdir /sys/fs/cgroup/mycg > > > echo 16M > /sys/fs/cgroup/mycg/memory.cma.reserved.max > > > echo 64M > /sys/fs/cgroup/mycg/memory.max > > > > OK, thanks for the clarification. This confirms my initial suspicion but > > it is better to have it clearly articulated. I can see several problems > > with this approach. First and formost I do not think dealing with all > > cmas this way is manageable. This can become a mess very quickly if we > > have one limit per cma and too coarse if there is a single one. I also > > have my doubts about space allocation control through a simple limit for > > something that is effectively a reserved physical space. > > > > I might be proven wrong but unless cma serves objects of a uniform > > size then this will simply not work in practice. Hitting ENOSPC without > > hitting limits and thus impractical for shared space management. > > Isn't that an inherent limit with CMA as it is? If the area gets > fragmented, some buffers may no longer be allocated since there is no > remaining hole big enough to accommodate them? I do hear that putting > arbitrary limits would make this worse, which might breach the threshold > at which it becomes a problem.
I wanted to say that a limit for something that is basically a reservation problem for shared pool is an ineffective solution. Exactly for reasons you are mentioning. You might set limits for parties sharing the same pool but that will not ensure they will be able to use their promised portion - that makes low,min limits effectively impossible. And hard/high limits are only to stop runaways. [...] > > Thanks. Yes this is more clear now. And it resembles hugetlb situation > > more than memcg. You simply need a memory pool specific access and usage > > control. Dispersing that to a global memcg limit seems rather coarse and > > I would say impractical. So it really calls for a per pool control with > > an understanding of how the specific pool really works. > > Thank you for the feedback. It looks like this won't work. It also > excludes the attempt through double charging dmem[1] as it would have > similar issues trying to use memcg. > > >From your last sentence, would this rather call for a different > controller entirely that would handle CMA semantics? I would recommend focusing on specific CMA users rather than trying to define a sane semantic for all potential CMA users because that might be a lot of different things. Then I would suggest focusing on the ultimate goal. Do you really want to provide any sort of guarantees (a reservation system) for a shared pool or merely cap maximum usage. Last but not least think about whether the whole sharing of a constrained memory area between uncooperative parties really makes sense in the first place. Especially when the pool serves objects of different sizes and fragmentation becomes a real problem. > [1] > https://lore.kernel.org/all/20260519-cgroup-dmem-memcg-double-charge-v2-0-db4d14070...@redhat.com/ > [2] > https://lore.kernel.org/all/[email protected]/ > > > -- > > Michal Hocko > > SUSE Labs > > > > -- > Eric Chanudet -- Michal Hocko SUSE Labs

