Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1362072iob; Wed, 4 May 2022 22:31:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTZEKsbMqsK6LvRutf1yohJIIvrMaAj7scN9xO/QPfpzMwRZ7j1RIeR+qo8uLAtL9qV9hh X-Received: by 2002:a05:6a00:a8b:b0:4e1:52db:9e5c with SMTP id b11-20020a056a000a8b00b004e152db9e5cmr24246958pfl.38.1651728703524; Wed, 04 May 2022 22:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651728703; cv=none; d=google.com; s=arc-20160816; b=l+C0dyxb//6JrbJWxGfzNRlX5I8QXWT5GFizn5EoVuvsM9IzsBMVbHRMMStItBsYoK gK2b8WZ9ggslZW3wVa1X2BRNF0g7asUMixJWSHobclvzerb5aWBdOVba7mD2i5spIfvU BZZiMRr5DVRLg0dYmgOQRbwcowLeB11Uk6xz7oomroMImTbk7+NGT2jHgG6uv80UjSfO GWUjYrI8AxVX8fGwNWk40up3gzq2A3vwyLRReQppVZH0KHWUs4EfzVUgcqwHec/eJwdE jsBHlZ6yIuZ7msrVtLe36LmPrC3jZXw6nNhX8MuyLCG/kbwyMHdq2U0Yvz6PgfM2Nr9/ TTlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=X8N/2j1iMVEWPhLHwXlf1lbWHCy97qgMOd6RtCKAAHI=; b=yHuubNVKy1ujOTME5buecQwVQllLvRHNH3XOnZ3wfQPFc9wUdMW8h3VPTorqOV5yYg +E5Ib87CjeLaK8dh/usu+pHVuCco3Js6fZN1e7i3f+4wTuea2x2jRDVT3Bp9dxaJtlvi SmHp5SpSpVr9pRl+muh1aqP90PkJW7KPe2VT0/h2T+i+7g30XBKE5EqZTtUjtA83sMTE HZqADalxq0vFTiBj13PRBMl+enOktzS+J2IFF7LiYHOVTO0VJJHyA0kM6rMQ2FqwXJhX hY0oN+quskTCwuXGs8EBisknjpcJL0eb79FAK3wNd0G15W3oWiIalRVnB4/sqkHOTisU oG8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YUvahhi8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a63741b000000b003c606c33460si478272pgc.666.2022.05.04.22.31.26; Wed, 04 May 2022 22:31:43 -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=@suse.com header.s=susede1 header.b=YUvahhi8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351128AbiEDOOE (ORCPT + 99 others); Wed, 4 May 2022 10:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351207AbiEDONn (ORCPT ); Wed, 4 May 2022 10:13:43 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CABE43AD4; Wed, 4 May 2022 07:10:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BA529210DB; Wed, 4 May 2022 14:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651673402; h=from:from:reply-to: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=X8N/2j1iMVEWPhLHwXlf1lbWHCy97qgMOd6RtCKAAHI=; b=YUvahhi8lIQnKT+/35TWCpA0GcF25PHrlG0nI6I37i/XqOeTn+w+dV7CC77XJJbhzSF9d6 hg6QJYGL24C0qMCZELbiXO5XFTcgbVtkpXWBBhhbCSTgPBQPb3AtS78QY6poz0CYHIWK+m IWbijGNan7qNqCzpWSk4Oe9ejmyXlUI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 70740131BD; Wed, 4 May 2022 14:10:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hitmGjqJcmLpDQAAMHmgww (envelope-from ); Wed, 04 May 2022 14:10:02 +0000 Date: Wed, 4 May 2022 16:10:01 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Vasily Averin Cc: Roman Gushchin , Vlastimil Babka , Shakeel Butt , kernel@openvz.org, Florian Westphal , linux-kernel@vger.kernel.org, Michal Hocko , cgroups@vger.kernel.org, Greg Kroah-Hartman , Tejun Heo Subject: Re: kernfs memcg accounting Message-ID: <20220504141001.GA10890@blackbody.suse.cz> References: <7e867cb0-89d6-402c-33d2-9b9ba0ba1523@openvz.org> <20220427140153.GC9823@blackbody.suse.cz> <7509fa9f-9d15-2f29-cb2f-ac0e8d99a948@openvz.org> <52a9f35b-458b-44c4-7fc8-d05c8db0c73f@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52a9f35b-458b-44c4-7fc8-d05c8db0c73f@openvz.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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, May 04, 2022 at 12:00:18PM +0300, Vasily Averin wrote: > My patches protect the host mostly from misuse, when someone creates > a huge number of nedevices inside a container. Understood. > Frankly speaking I do not see a big difference between memcg of current process, > memcg of newly created child and memcg of its parent. I agree that's not substantial difference. It's relevant for outer entities "injecting" something into a subtree. As I wrote previously, charging to the creator in the generic case is sensible. > As far as I understand, Roman chose the parent memcg because it was a special > case of creating a new memory group. He temporally changed active memcg > in mem_cgroup_css_alloc() and properly accounted all required memcg-specific > allocations. > However, he ignored accounting for a rather large struct mem_cgroup > therefore I think we can do not worry about 128 bytes of kernfs node. Are you referring to the current code (>= v5.18-rc2)? All big structs related to mem_cgroup should be accounted. What is ignored? > Primary I mean here struct mem_cgroup allocation in mem_cgroup_alloc(). Just note that memory controller may not be always enabled so cgroup_mkdir != mem_cgroup_alloc(). > However, I think we need to take into account any other distributions called > inside cgroup_mkdir: struct cgroup and kernefs node in common part and > any other cgroup-cpecific allocations in other .css_alloc functions. > They all can be called from inside container, allocates non-accountable > memory and by this way theoretically can be misused. Also note that (if you're purely on unified hierachy) you can protect against that with cgroup.max.descendants and cgroup.max.depth. Thanks, Michal