linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Averin <vvs@openvz.org>
To: Michal Hocko <mhocko@suse.com>
Cc: kernel@openvz.org, "Andrew Morton" <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	"Shakeel Butt" <shakeelb@google.com>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Muchun Song" <songmuchun@bytedance.com>,
	cgroups@vger.kernel.org
Subject: Re: [PATCH mm v5 0/9] memcg: accounting for objects allocated by mkdir, cgroup
Date: Thu, 23 Jun 2022 18:03:31 +0300	[thread overview]
Message-ID: <c516033f-a9e4-3485-26d9-a68afa694c1d@openvz.org> (raw)
In-Reply-To: <0fe836b4-5c0f-0e32-d511-db816d359748@openvz.org>

Dear Michal,
do you still have any concerns about this patch set?

Thank you,
	Vasily Averin

On 6/23/22 17:50, Vasily Averin wrote:
> In some cases, creating a cgroup allocates a noticeable amount of memory.
> This operation can be executed from inside memory-limited container,
> but currently this memory is not accounted to memcg and can be misused.
> This allow container to exceed the assigned memory limit and avoid
> memcg OOM. Moreover, in case of global memory shortage on the host,
> the OOM-killer may not find a real memory eater and start killing
> random processes on the host.
> 
> This is especially important for OpenVZ and LXC used on hosting,
> where containers are used by untrusted end users.
> 
> Below is tracing results of mkdir /sys/fs/cgroup/vvs.test on 
> 4cpu VM with Fedora and self-complied upstream kernel. The calculations
> are not precise, it depends on kernel config options, number of cpus,
> enabled controllers, ignores possible page allocations etc.
> However this is enough to clarify the general situation.
> All allocations are splitted into:
> - common part, always called for each cgroup type
> - per-cgroup allocations
> 
> In each group we consider 2 corner cases:
> - usual allocations, important for 1-2 CPU nodes/Vms
> - percpu allocations, important for 'big irons'
> 
> common part: 	~11Kb	+  318 bytes percpu
> memcg: 		~17Kb	+ 4692 bytes percpu
> cpu:		~2.5Kb	+ 1036 bytes percpu
> cpuset:		~3Kb	+   12 bytes percpu
> blkcg:		~3Kb	+   12 bytes percpu
> pid:		~1.5Kb	+   12 bytes percpu		
> perf:		 ~320b	+   60 bytes percpu
> -------------------------------------------
> total:		~38Kb	+ 6142 bytes percpu
> currently accounted:	  4668 bytes percpu
> 
> - it's important to account usual allocations called
> in common part, because almost all of cgroup-specific allocations
> are small. One exception here is memory cgroup, it allocates a few
> huge objects that should be accounted.
> - Percpu allocation called in common part, in memcg and cpu cgroups
> should be accounted, rest ones are small an can be ignored.
> - KERNFS objects are allocated both in common part and in most of
> cgroups 
> 
> Details can be found here:
> https://lore.kernel.org/all/d28233ee-bccb-7bc3-c2ec-461fd7f95e6a@openvz.org/
> 
> I checked other cgroups types was found that they all can be ignored.
> Additionally I found allocation of struct rt_rq called in cpu cgroup 
> if CONFIG_RT_GROUP_SCHED was enabled, it allocates huge (~1700 bytes)
> percpu structure and should be accounted too.
> 
> v5:
>  1) re-based to linux-mm (mm-everything-2022-06-22-20-36)
> 
> v4:
>  1) re-based to linux-next (next-20220610)
>    now psi_group is not a part of struct cgroup and is allocated on demand
>  2) added received approval from Muchun Song
>  3) improved cover letter description according to akpm@ request
> 
> v3:
>  1) re-based to current upstream (v5.18-11267-gb00ed48bb0a7)
>  2) fixed few typos
>  3) added received approvals
> 
> v2:
>  1) re-split to simplify possible bisect, re-ordered
>  2) added accounting for percpu psi_group_cpu and cgroup_rstat_cpu,
>      allocated in common part
>  3) added accounting for percpu allocation of struct rt_rq
>      (actual if CONFIG_RT_GROUP_SCHED is enabled)
>  4) improved patches descriptions 
> 
> Vasily Averin (9):
>   memcg: enable accounting for struct cgroup
>   memcg: enable accounting for kernfs nodes
>   memcg: enable accounting for kernfs iattrs
>   memcg: enable accounting for struct simple_xattr
>   memcg: enable accounting for percpu allocation of struct psi_group_cpu
>   memcg: enable accounting for percpu allocation of struct
>     cgroup_rstat_cpu
>   memcg: enable accounting for large allocations in mem_cgroup_css_alloc
>   memcg: enable accounting for allocations in alloc_fair_sched_group
>   memcg: enable accounting for perpu allocation of struct rt_rq
> 
>  fs/kernfs/mount.c      | 6 ++++--
>  fs/xattr.c             | 2 +-
>  kernel/cgroup/cgroup.c | 2 +-
>  kernel/cgroup/rstat.c  | 3 ++-
>  kernel/sched/fair.c    | 4 ++--
>  kernel/sched/psi.c     | 2 +-
>  kernel/sched/rt.c      | 2 +-
>  mm/memcontrol.c        | 4 ++--
>  8 files changed, 14 insertions(+), 11 deletions(-)
> 



  reply	other threads:[~2022-06-23 15:03 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Yn6aL3cO7VdrmHHp@carbon>
2022-05-21 16:37 ` [PATCH mm v2 0/9] memcg: accounting for objects allocated by mkdir cgroup Vasily Averin
2022-05-30 11:25   ` [PATCH mm v3 " Vasily Averin
2022-05-30 11:55     ` Michal Hocko
2022-05-30 13:09       ` Vasily Averin
2022-05-30 14:22         ` Michal Hocko
2022-05-30 19:58           ` Vasily Averin
2022-05-31  7:16             ` Michal Hocko
2022-06-01  3:43               ` Vasily Averin
2022-06-01  9:15                 ` Michal Koutný
2022-06-01  9:32                   ` Michal Hocko
2022-06-01 13:05                     ` Michal Hocko
2022-06-01 14:22                       ` Roman Gushchin
2022-06-01 15:24                         ` Michal Hocko
2022-06-01  9:26                 ` Michal Hocko
2022-06-13  5:34     ` [PATCH mm v4 " Vasily Averin
2022-06-23 14:50       ` [PATCH mm v5 0/9] memcg: accounting for objects allocated by mkdir, cgroup Vasily Averin
2022-06-23 15:03         ` Vasily Averin [this message]
2022-06-23 16:07           ` Michal Hocko
2022-06-23 16:55             ` Shakeel Butt
2022-06-24 10:40               ` Vasily Averin
2022-06-24 12:26                 ` Michal Koutný
2022-06-24 13:59               ` Michal Hocko
2022-06-25  9:43                 ` [PATCH RFC] memcg: avoid idr ids space depletion Vasily Averin
     [not found]                 ` <c53e1df0-5174-66de-23cc-18797f0b512d@openvz.org>
2022-06-26  1:56                   ` [PATCH RFC] memcg: notify about global mem_cgroup_id " Roman Gushchin
     [not found]                     ` <97bed1fd-f230-c2ea-1cb6-8230825a9a64@openvz.org>
2022-06-27  3:23                       ` [PATCH mm v2] " Muchun Song
     [not found]                         ` <f3e4059c-69ea-eccd-a22f-9f6c6780f33a@openvz.org>
2022-06-28  1:11                           ` Roman Gushchin
2022-06-28  9:08                             ` Michal Koutný
2022-06-27 16:37                 ` [PATCH mm v5 0/9] memcg: accounting for objects allocated by mkdir, cgroup Shakeel Butt
2022-07-01 11:03                   ` Michal Hocko
2022-07-10 18:53                     ` Vasily Averin
2022-07-11 16:24                       ` Michal Hocko
2022-06-23 14:50       ` [PATCH mm v5 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-06-23 14:50       ` [PATCH mm v5 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-06-23 14:51       ` [PATCH mm v5 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-06-13  5:34     ` [PATCH mm v4 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-06-13  5:34     ` [PATCH mm v4 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-06-13  5:34     ` [PATCH mm v4 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
     [not found]   ` <cover.1653899364.git.vvs@openvz.org>
2022-05-30 11:25     ` [PATCH mm v3 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-05-30 11:26     ` [PATCH mm v3 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-05-30 11:26     ` [PATCH mm v3 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-05-30 11:26     ` [PATCH mm v3 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-05-30 11:26     ` [PATCH mm v3 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-05-30 11:26     ` [PATCH mm v3 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-05-30 15:04       ` Muchun Song
     [not found]     ` <a1fcdab2-a208-0fad-3f4e-233317ab828f@openvz.org>
2022-05-30 15:06       ` [PATCH mm v3 9/9] memcg: enable accounting for perpu allocation of struct rt_rq Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-05-22  6:37   ` Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-05-22  6:37   ` Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-05-22  6:38   ` Muchun Song
2022-05-21 16:38 ` [PATCH mm v2 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-05-22  6:38   ` Muchun Song
2022-05-21 16:38 ` [PATCH mm v2 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-05-21 21:34   ` Shakeel Butt
2022-05-22  6:40   ` Muchun Song
2022-05-25  1:30   ` Roman Gushchin
     [not found] ` <9925d0ba-40d7-e3a8-1fef-054968b26ce6@openvz.org>
2022-05-22  6:47   ` [PATCH mm v2 7/9] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Muchun Song
     [not found] ` <46bbde64-7290-cabb-8fef-6f4a30263d8c@openvz.org>
2022-05-22  6:49   ` [PATCH mm v2 8/9] memcg: enable accounting for allocations in alloc_fair_sched_group Muchun Song
     [not found] ` <c0d01d6e-530c-9be3-1c9b-67a7f8ea09be@openvz.org>
2022-05-21 17:58   ` [PATCH mm v2 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-05-21 21:35   ` Shakeel Butt
2022-05-21 22:05   ` kernel test robot
2022-05-25  1:31   ` Roman Gushchin
     [not found] ` <d7094aa2-1cd0-835c-9fb7-d76003c47dad@openvz.org>
2022-05-21 21:37   ` [PATCH mm v2 9/9] memcg: enable accounting for percpu allocation of struct rt_rq Shakeel Butt
2022-05-25  1:31   ` Roman Gushchin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c516033f-a9e4-3485-26d9-a68afa694c1d@openvz.org \
    --to=vvs@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=kernel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mkoutny@suse.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=songmuchun@bytedance.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).