linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] enable memcg accounting for kernfs objects
@ 2022-07-31 15:37 Vasily Averin
  2022-08-09 17:31 ` Tejun Heo
  0 siblings, 1 reply; 22+ messages in thread
From: Vasily Averin @ 2022-07-31 15:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tejun Heo
  Cc: Alexander Viro, linux-kernel, kernel, Shakeel Butt,
	Roman Gushchin, Michal Koutný,
	Muchun Song, Michal Hocko

This patch set enables memcg accounting for kernfs-related objects.

Originally it was a part of patch set
"memcg: accounting for objects allocated by mkdir cgroup"
https://lore.kernel.org/all/0fe836b4-5c0f-0e32-d511-db816d359748@openvz.org/

The patches have received approval from several developers, 
however respected Michal Hocko pointed out that, if neccesary,
cgroups consumption can be restricted via cgroup.max.descendants
limit without additional accounting of allocated memory.
I still disagree with him, I think that memory limits works better,
but I could not give any new substantial arguments, so discussion
was stalled and patches was frozen in limbo until better times.

However 3 of these patches affect not only cgroups, and I hope
to get help from kernfs maintainers.

Kernfs nodes are quite small kernel objects, however there are few
scenarios where it consumes significant piece of all allocated memory.
I am aware of the following cases, but I am sure there are many other
ones.

1) creating a new netdevice allocates ~50Kb of memory, where ~10Kb
   was allocated for 80+ kernfs nodes.

2) cgroupv2 mkdir allocates ~60Kb of memory, ~10Kb of them are kernfs
   structures.

3) Shakeel Butt reports that Google has workloads which create 100s
   of subcontainers and they have observed high system overhead
   without memcg accounting of kernfs.

My experimets with LXC conrainer on Fedora node show that
usually new kernfs node creates few other objects:

Allocs  Alloc   Allocation
number  size
--------------------------------------------
1   +  128      (__kernfs_new_node+0x4d)        kernfs node
1   +   88      (__kernfs_iattrs+0x57)          kernfs iattrs
1   +   96      (simple_xattr_alloc+0x28)       simple_xattr(*)
1       32      (simple_xattr_set+0x59)
1       8       (__kernfs_new_node+0x30)

'+' -- to be accounted

(*) simple_xattr in this scenaro was allocated directly during
kernfs creation for selinux label. Even here it consumes noticeable
part of newly allocated object.
However please keep in mind that xattr can be allocated later,
via setxattr system calls, its size is controlled by userspace
and can reach 64Kb per call. kernfs objects lives in memory,
so it is improtant to account it.

Originally the patches was splitted to simplify their rewiev,
however if required I can merge them together.

Vasily Averin (3):
  memcg: enable accounting for kernfs nodes
  memcg: enable accounting for kernfs iattrs
  memcg: enable accounting for struct simple_xattr

 fs/kernfs/mount.c | 6 ++++--
 fs/xattr.c        | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-08-23 18:11 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31 15:37 [PATCH 0/3] enable memcg accounting for kernfs objects Vasily Averin
2022-08-09 17:31 ` Tejun Heo
2022-08-09 17:49   ` Michal Koutný
2022-08-09 17:56     ` Tejun Heo
2022-08-11  3:19       ` Vasily Averin
2022-08-11  4:58         ` [RFC PATCH] kernfs: enable per-inode limits for all xattr types Vasily Averin
2022-08-12 10:20           ` Christian Brauner
2022-08-13  4:16             ` Vasily Averin
2022-08-16  7:47         ` [PATCH 0/3] enable memcg accounting for kernfs objects Vasily Averin
2022-08-17  7:42           ` [RFC PATCH] memcg: adjust memcg for new cgroup allocations Vasily Averin
2022-08-17  9:17             ` Michal Koutný
2022-08-17 15:02               ` Vasily Averin
2022-08-17 16:41               ` Tejun Heo
2022-08-23 12:04                 ` Vasily Averin
2022-08-23 16:22                   ` Tejun Heo
2022-08-18  9:10           ` [RFC PATCH] memcg: adjust memcg used to charge for new simple_xattrs objects Vasily Averin
2022-08-18 12:27             ` Michal Koutný
2022-08-23  8:17               ` Vasily Averin
2022-08-18  9:12           ` [RFC PATCH] simple_xattr: switch from list to rb_tree Vasily Averin
2022-08-18 13:19             ` Christian Brauner
2022-08-23 10:42               ` Vasily Averin
2022-08-09 21:25   ` [PATCH 0/3] enable memcg accounting for kernfs objects Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).