Re: [RFC PATCH] memcg: adjust memcg used to charge for new simple_xattrs objects
From: Vasily Averin
Date: Tue Aug 23 2022 - 04:37:56 EST
On 8/18/22 15:27, Michal Koutný wrote:
> On Thu, Aug 18, 2022 at 12:10:45PM +0300, Vasily Averin <vvs@xxxxxxxxxx> wrote:
>> sys_set[f]xattr uses simple_xattr infrastructure to create a new
>> extended attribute for in-memory file systems like sysfs and tmpfs.
>> Number and size of allocated objects are controlled by user space,
>> they are always living in memory and its lifetime is indefinitely long.
>> Therefore this memory should be properly accounted.
>>
>> By default new memory is accounted to memcg of creator process.
>
> despite objects aren't bound to this process lifetime.
>
> (I think this was the main argument for this approach and should be in
> the commit message then.)
Thank you for the remark, I'll update patch description in the next version
>> As a result, neighboring xattrs of the same inode can be charged to
>> different memcgs. This looks unexpected and makes hard the
>> investigation of the memcg accounting issues.
>>
>> This patch adjust memcg used for such allocations. For kernfs
>> it gives memcg from kernfs node, for shmem -- from shmem_info.
>> This allows to cahrge all inode-sepcific objects to the same
>> memory cgroup.
>
> IIUC you intend to inherit association from shmem_inode_info (i.e.
> whoever created the inode). shmem_inode_cachep has SLAB_ACCOUNT, so it's valid.
Yes, you are right, I'll clarify this in next patch version.
Thank you,
Vasily Averin