[LTP] [PATCH] memcontrol03: Account for process size in cgroup allocation

Martin Doucha mdoucha@suse.cz
Fri May 9 12:11:26 CEST 2025


On 09. 05. 25 12:01, Cyril Hrubis wrote:
> Hi!
>>>>> Here we depend on the fact that process memory has been properly
>>>>> accounted for when it starts running its code. Are you sure that we can
>>>>> rely on this or does this just happen to work?
>>>>
>>>> Actually, my commit message is slightly misleading because the existing
>>>> process memory does not get migrated to the new cgroup. But the cgroup
>>>> itself may already have non-zero memory usage even when empty, likely
>>>> for internal kernel structures. Any new allocations of kernel structures
>>>> should also be finished when the process migration completes. So unless
>>>> the migration behavior changes in the near future, we can rely on this.
>>>
>>> I suppose that the cgroup is charged for the memory it needs to track
>>> the resources, that makes sense. I wonder if we can read that once at
>>> the start of the test when we create the cgroups and use that value
>>> later on.
>>
>> Unfortunately, we can't. I've tested this and memory.current can change
>> a lot during the first process migration.
> 
> That does sound strange. @Michal any idea what happens here?

My guess is that the kernel structure allocation is just lazy. The 
cgroup memory counter usually starts at zero. Then it allocates 
structures on the first process migration and keeps them until the 
cgroup gets destroyed.

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list