Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp972997iob; Fri, 13 May 2022 18:12:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIcPc+ZsVii+gCu0Lezxqll6fClLCCkGtknSmyly43YhVIIVS6edslDTg6Fk8X8TOQZys+ X-Received: by 2002:a5d:4744:0:b0:20a:ea5a:dc39 with SMTP id o4-20020a5d4744000000b0020aea5adc39mr5911415wrs.236.1652490725482; Fri, 13 May 2022 18:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652490725; cv=none; d=google.com; s=arc-20160816; b=BPQeziKbQO+I4qdK1DkqytKRb4PEGrYENPkGxpfuiikFpNoF2ToSltmb+7vFdL8QHc T/qXIW4CBGOOwmmdpRubLFYo/i09XDudwXeJVS9bciEF+MJzzOJZ8bRI8g9GJ4yvAorR V+f1kmCwhl0gnsB0u6uKt64vH6HW9f5dV2PmQpy0N1Z0c68HfD92vwHk0nljsBhNDAXI 5dHXBPWOZIdr4vNn6/iAIRNRArwhnERzRqeeXkVH1mcwN/2U04JfXAfUTYOZQJm3YlvK 5qdQs4fOPTsdM9rXtScZxiM0Rl2nUAnsGmMx3X6sGp2S5B8+GlMn7bLwJwTK1clb/Fu6 rphw== 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=BT7PhFjb0yfnX8Jyg1myJFbP9avxJpO8kwYrkhn3Qao=; b=uEXVMK1enw7nTivD92z2Q8viTeEamaQISHAhDjrYgjzvggpMC7+rz4HbYfbWQ54wmg hG7VfZfhZ932/ZLhaSsBNLKBys1ThrlL+A01sdwwcqOWKaTGmhyksTvvv2RSbxk5XW1L 5meEs9m57fcxHokHbTkPK6GaBJKhUnJs2R6U5S/o0FF9yLDWccS03kA/nOaAzOYF+xk6 L5KWx6umgFkGXUiJLiPPGFv7H8dHsj4OD7jIb8ThpYmNAmngb8iFrk9s2Ssxr5B6rlx+ B3AUfphhFnpA5PReNWjBDa3IOoP4BQdXyh31CV09D5VJLWqOb84rqi/8DJTvPYFKDtI1 2gEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Rqw7tlXY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n6-20020adffe06000000b0020acf016d1bsi3574051wrr.200.2022.05.13.18.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:12:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Rqw7tlXY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49C6339BC03; Fri, 13 May 2022 16:43:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239807AbiEKQuq (ORCPT + 99 others); Wed, 11 May 2022 12:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345060AbiEKQtt (ORCPT ); Wed, 11 May 2022 12:49:49 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6215295DDF; Wed, 11 May 2022 09:49:48 -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 19E6E21D3A; Wed, 11 May 2022 16:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1652287787; 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=BT7PhFjb0yfnX8Jyg1myJFbP9avxJpO8kwYrkhn3Qao=; b=Rqw7tlXYAK6aOCv5cU2S5SjeLkNYuQNaHQjxOxoinQtMjkhzD4QD7va4YazZecdAXkcqd0 hI8qsZ9LllH1OeY0mt/7zDJAI90AYjelKRQkzXYfT5rpLBqATrF3Uwbsysu1bjmOWYfnWM dAojk1ZewHtUCFuM7IjkVl+KdZmRADY= 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 CD78513A76; Wed, 11 May 2022 16:49:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aDCVMCrpe2JmVgAAMHmgww (envelope-from ); Wed, 11 May 2022 16:49:46 +0000 Date: Wed, 11 May 2022 18:49:45 +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: <20220511164945.GA31592@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> <0eec6575-548e-23e0-0d99-4e079a33d338@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0eec6575-548e-23e0-0d99-4e079a33d338@openvz.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 11, 2022 at 09:01:40AM +0300, Vasily Averin wrote: > number bytes $1*$2 sum note call_site > of alloc > allocs > ------------------------------------------------------------ > 1 14448 14448 14448 = percpu_alloc_percpu: > 1 8192 8192 22640 ++ (mem_cgroup_css_alloc+0x54) This requires just adding GFP_KERNEL_ACCOUNT (no new active memcg switch). > 49 128 6272 28912 ++ (__kernfs_new_node+0x4e) > 49 96 4704 33616 ? (simple_xattr_alloc+0x2c) > 49 88 4312 37928 ++ (__kernfs_iattrs+0x56) > 1 4096 4096 42024 ++ (cgroup_mkdir+0xc7) > 1 3840 3840 45864 = percpu_alloc_percpu: > 4 512 2048 47912 + (alloc_fair_sched_group+0x166) > 4 512 2048 49960 + (alloc_fair_sched_group+0x139) > 1 2048 2048 52008 ++ (mem_cgroup_css_alloc+0x109) > " > [1] https://lore.kernel.org/all/1aa4cd22-fcb6-0e8d-a1c6-23661d618864@openvz.org/ > = already accounted > ++ to be accounted first > + to be accounted a bit later > > There is no problems with objects allocated in mem_cgroup_alloc(), > they will be accounted to parent's memcg. > However I do not understand how to handle other large objects? > > We could move set_active_memcg(parent) call from mem_cgroup_css_alloc() > to cgroup_apply_control_enable() and handle allocation in all .css_alloc() > > However I need to handle allocations called from cgroup_mkdir() too and > badly understand how to do it properly. If we consent to charge to the creator, the change would be just passing GFP_ACCOUNT at fewer (right) places, wouldn't it? Also, my undertanding of memcgs is that they're not hermetically tight, so I think charging just kernfs_nodes (for dirs and files) provides sufficient bound. Except for, the xattrs, my older notes say: "make kernfs simple_xattr kernel accounted, up to KERNFS_USER_XATTR_SIZE_LIMIT*KERNFS_MAX_USER_XATTRS = 128k * 128 = 16M / inode". HTH, Michal