Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5579176ioo; Wed, 1 Jun 2022 08:16:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ0DT5ScUSNgpfko0SZxs01XT0Yozl4MtsBgaiJ3Av/draosuuPo//T7OofuKA69FjAnFu X-Received: by 2002:a17:902:7048:b0:15f:34c1:bae0 with SMTP id h8-20020a170902704800b0015f34c1bae0mr168670plt.71.1654096569028; Wed, 01 Jun 2022 08:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654096569; cv=none; d=google.com; s=arc-20160816; b=Nvkcce17r2mY+Z7EaEqQTjEJmjrq9FND8SzlJWkrxhndugc2byUmJtA+1h0Je+46OA gKVbOtxPBEZthDeisRydgzm/R+lHsk05Tz2IvYI/An9Ht1AdURzld8A5277l5XL2K+Gp mYOL+tXTLzX8dENyUfgaOtguYaUtjelI9ISTNMIz2n61T81QMRa/PbtoTI/67EEQY23a bA/QAbxNrvSSPNtxsY+sxjO+Q95w5LKwxdMJA+K0rsbX1Rg+zdprreffdc4ocEciDBDh dGQDZ6RCrOtgo/FtlUwJ64GjcWIH5CSGtM4ZGZvTBQ6i6H8OE72BHuuMn328H8NyBhpV U/HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=7dTK8lZD+GRn5W6XhroTWtrQIr3FWONSOpLntw7o9P8=; b=DBt1tfysNZdTE4WfNwWmEJV7Iji2i9UmwWeGjW7llLWWtlP17pYJ5ILYx+nO/Lsmjx hR5a/AyWlQ2riz5IcfiTYNqCvcDszhjZjcKzSleJf1X+Jtv5ePc1x7ZSaWiDOTpX4B93 bNO17x0CCloys4B0wVBbAZz2Wd54GPau4w35Koq0e4fazMQmKBjTQ6SYC9C0xvoccUcV lu0iSx9mDLUka58nPV7L4lG4Hg6NQdyB0Uffo76VL+RXJYhmeM9Wreshbt9jPalZg2bZ DYvVp6pX1kMOd0Xmyj5MjIJJ9sjlU6pb14rItovol1eYh4+geCBUnEtYg+dKLBxFMS5k 709g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NUkC82D4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg16-20020a17090b1e1000b001e34f5e0399si2816431pjb.66.2022.06.01.08.15.51; Wed, 01 Jun 2022 08:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NUkC82D4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354827AbiFAO1x (ORCPT + 99 others); Wed, 1 Jun 2022 10:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354928AbiFAO11 (ORCPT ); Wed, 1 Jun 2022 10:27:27 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6508A5026; Wed, 1 Jun 2022 07:22:15 -0700 (PDT) Date: Wed, 1 Jun 2022 07:22:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1654093333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7dTK8lZD+GRn5W6XhroTWtrQIr3FWONSOpLntw7o9P8=; b=NUkC82D4ypjqicXuOoWVCuRX+YRDU1QRJrivMJisaz2muYJDPR914lptcXqx2oVqxcfwc3 c1xEX6QGnV9xKfvdvIs10qjbmQ7rRL8g6itonmvlcVeG1PWh7/qnyL4C3/JkNBDTa8y+rb YUBb0WPjtf+QZOOqvtdwNWwTCxdsFdA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Michal Hocko Cc: Michal =?iso-8859-1?Q?Koutn=FD?= , Vasily Averin , Andrew Morton , kernel@openvz.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Vlastimil Babka , Muchun Song , cgroups@vger.kernel.org Subject: Re: [PATCH mm v3 0/9] memcg: accounting for objects allocated by mkdir cgroup Message-ID: References: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> <3a1d8554-755f-7976-1e00-a0e7fb62c86e@openvz.org> <118bcb39-1281-0d1d-b163-3f6bcc99c3e2@openvz.org> <20220601091543.GA21320@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 01, 2022 at 03:05:34PM +0200, Michal Hocko wrote: > On Wed 01-06-22 11:32:26, Michal Hocko wrote: > > On Wed 01-06-22 11:15:43, Michal Koutny wrote: > > > On Wed, Jun 01, 2022 at 06:43:27AM +0300, Vasily Averin wrote: > > > > CT-901 /# cat /sys/fs/cgroup/memory/cgroup.subgroups_limit > > > > 512 > > > > CT-901 /# echo 3333 > /sys/fs/cgroup/memory/cgroup.subgroups_limit > > > > -bash: echo: write error: Operation not permitted > > > > CT-901 /# echo 333 > /sys/fs/cgroup/memory/cgroup.subgroups_limit > > > > -bash: echo: write error: Operation not permitted > > > > > > > > I doubt this way can be accepted in upstream, however for OpenVz > > > > something like this it is mandatory because it much better > > > > than nothing. > > > > > > Is this customization of yours something like cgroup.max.descendants on > > > the unified (v2) hierarchy? (Just curious.) > > > > > > (It can be made inaccessible from within the subtree either with cgroup > > > ns or good old FS permissions.) > > > > So we already do have a limit to prevent somebody from running away with > > the number of cgroups. Nice! Yes, we do! > > I was not aware of that and I guess this > > looks like the right thing to do. So do we need more control and > > accounting that this? > > I have checked the actual implementation and noticed that cgroups are > uncharged when offlined (rmdir-ed) which means that an adversary could > still trick the limit and runaway while still consuming resources. > > Roman, I guess the reason for this implementation was to avoid limit to > trigger on setups with memcgs which can take quite some time to die? > Would it make sense to make the implementation more strict to really act > as gate against potential cgroups count runways? The reasoning was that in many cases a user can't do much about dying cgroups, so it's not clear how they should/would handle getting -EAGAIN on creating a new cgroup (retrying will not help, obviously). Live cgroups can be easily deleted, dying cgroups - not always. I'm not sure about switching the semantics. I'd wait till Muchun's lru page reparenting will be landed (could be within 1-2 releases, I guess) and then we can check whether the whole problem is mostly gone. Honestly, I think we might need to fix few another things, but it might be not that hard (in comparison to what we already did).