Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp5005123ioa; Wed, 27 Apr 2022 16:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2AmR65Bs87PVWOvXDn0sNoC2odDyf4TNkIqcC6zYT1BhIURj4mDBIONXskKQs6/9r84kr X-Received: by 2002:a50:ed16:0:b0:425:f420:e51a with SMTP id j22-20020a50ed16000000b00425f420e51amr15545405eds.23.1651102579980; Wed, 27 Apr 2022 16:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651102579; cv=none; d=google.com; s=arc-20160816; b=rB24kAE1E7t+6tYWClnLQ+wib4URMHaMHwMuWYKFe6AqugBll/cR+RrfuwgkaQgcEc Yw3JT2MNB/qwq4/eVrPtCfWoP6AX1NxcVc17hSSwj3VaGqkGQA1qJ5tVBOG471kmfMu6 MgAk/09IsEr8nhs1I/hYRz0gpOlvONQXSnd1I3bcjz3RDWgeBCfNaUQB8yw1UuE7trSB cUdUOK+mrTYDg/vjtUx4L9ODForfGf3YSuRkKzdnLG95V+HATL+jMghMjmlx8RVrtCpV wbDRHnVIPeUO5xIIepVzhxUDBPx3lwr+0CSp3Me4ombQtI1hOOfTovCMUaAZKNaCf8xW /Fkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zxjODgdLfXb5bMGzaUtB+izM+jyIRFXXBicqRczakdE=; b=VQ2bTWbNNkLjpCIQIC1GIB0+V15VKYjl3RaPYft1i1KYMbheHeDYpvI8Iyqn8T4Ykp hUDaqIl7IDAjn1renEsl1QLtQzaSnpFClc6PZb0sFjiPQXO58UAo7rGTUm3hTlNsT7Sk jKJYnhDJC1rx9ggOqihfI2JTBTbDxCROZd6k40mfXrEfdFWHyDkA7Jrm4xOUHjtZZ4xU 7ZVE8NzKqgTvWXO0k0rmhrzsbgqjXmF/Uz5IPnlWIkYmsBBia14Ey+0KbKVS+Fw6WOgA 8fk2495xnjd7+aP71e/sJ8W+sHZd1h9Hr4h6VRwOI83axJmjiZhq+Nj6jGEoO0R4leEm UvWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=kOgHkvcX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y26-20020a056402135a00b00425da163127si2777488edw.83.2022.04.27.16.35.48; Wed, 27 Apr 2022 16:36:19 -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=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=kOgHkvcX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238130AbiD0WjY (ORCPT + 99 others); Wed, 27 Apr 2022 18:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233410AbiD0WjL (ORCPT ); Wed, 27 Apr 2022 18:39:11 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD183A7 for ; Wed, 27 Apr 2022 15:35:57 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id l19so4472371ljb.7 for ; Wed, 27 Apr 2022 15:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=zxjODgdLfXb5bMGzaUtB+izM+jyIRFXXBicqRczakdE=; b=kOgHkvcXiKDHcf0FPKISXEY5HqGfG/C3VTxC3r+qCyDNb58YQ2Ffm1EN+ZlnNbcklN 3xuHlw7dI5IAdFE/+iGt8WZvjfO7q6k8VKBoPN743YhsElb89sF9gZKHOWTWzA2c3Rwd 54YF4aIVaLRZWzwG0KTZKcgCLNVNHLGg3rCWfTKevXQPCDYDJ2IZuZKHtRmaqsYwSR5p XpJhcPiWYNEZefwnTjp4pe/ygtOPWtd5Talc9/MypxxDHY+1wSUIaXiRzkx85TXRbhgt S+SnpKe5BVSbjw/sLPVHQ/cE9dacC5fnJ8dVd88zXJ4RowaAf8I5IZSkR41CoM++9DjB nvZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=zxjODgdLfXb5bMGzaUtB+izM+jyIRFXXBicqRczakdE=; b=vJ12BnkDroH+4Y8v+pyKJAm9sUKsxU3DpeiVR7EYASyBwVr4tbstjF9UhRfC2ldHoA ysSTkmsaLAqh3pLgpo+5FnnHLKaCsQ4SODmq9QwKNgc8Rw37G+aBUqK2T/FIfyDhzP1E Zv/VSTarkbH/i3uxkYdZjJAfaPfqLx/VJ5xYislDSJWdKmQWW3l3t7qVv3epvasJE31g JbmxmhoSygA3dIgRnfdRtGAHgohqPCP/tLK+903OCmxCu1w0xV0YTlIaZdTV2RXmHEnJ wO+HK4Lf81aEQ8Kb23NcwE2qMhtvWs/8NlPUHCZM+RAxm5eTPyEXBWXjZ+8XhRdwv2jB u80Q== X-Gm-Message-State: AOAM530Leywx7f/cU+sk1sOPoegBR9HKcQKt0r9s5dj8JcVMhSV9QKGH 9Jl9RCHNdAZjLRDZUpsAj0roSQ== X-Received: by 2002:a05:651c:1542:b0:249:5d86:3164 with SMTP id y2-20020a05651c154200b002495d863164mr20114887ljp.500.1651098956152; Wed, 27 Apr 2022 15:35:56 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.177]) by smtp.gmail.com with ESMTPSA id f1-20020a056512322100b00472285d5a74sm362884lfe.147.2022.04.27.15.35.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 15:35:55 -0700 (PDT) Message-ID: <53613f02-75f2-0546-d84c-a5ed989327b6@openvz.org> Date: Thu, 28 Apr 2022 01:35:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] memcg: accounting for objects allocated for new netdevice Content-Language: en-US To: Shakeel Butt , =?UTF-8?Q?Michal_Koutn=c3=bd?= Cc: Roman Gushchin , Vlastimil Babka , kernel@openvz.org, Florian Westphal , LKML , Michal Hocko , Cgroups , netdev , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Tejun Heo , Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-fsdevel References: <7e867cb0-89d6-402c-33d2-9b9ba0ba1523@openvz.org> <20220427140153.GC9823@blackbody.suse.cz> From: Vasily Averin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 4/27/22 19:52, Shakeel Butt wrote: > On Wed, Apr 27, 2022 at 7:01 AM Michal Koutný wrote: >> >> Hello Vasily. >> >> On Wed, Apr 27, 2022 at 01:37:50PM +0300, Vasily Averin wrote: >>> diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c >>> index cfa79715fc1a..2881aeeaa880 100644 >>> --- a/fs/kernfs/mount.c >>> +++ b/fs/kernfs/mount.c >>> @@ -391,7 +391,7 @@ void __init kernfs_init(void) >>> { >>> kernfs_node_cache = kmem_cache_create("kernfs_node_cache", >>> sizeof(struct kernfs_node), >>> - 0, SLAB_PANIC, NULL); >>> + 0, SLAB_PANIC | SLAB_ACCOUNT, NULL); >> >> kernfs accounting you say? >> kernfs backs up also cgroups, so the parent-child accounting comes to my >> mind. >> See the temporary switch to parent memcg in mem_cgroup_css_alloc(). >> >> (I mean this makes some sense but I'd suggest unlumping the kernfs into >> a separate path for possible discussion and its not-only-netdevice >> effects.) > > I agree with Michal that kernfs accounting should be its own patch. > Internally at Google, we actually have enabled the memcg accounting of > kernfs nodes. We have workloads which create 100s of subcontainers and > without memcg accounting of kernfs we see high system overhead. I had this idea (i.e. move kernfs accounting into separate patch) too, but finally decided to include it into current patch. Kernfs accounting is critical for described scenario. Without it typical netdevice creating will charge only ~50% of allocated memory, and the rest of patch does not allow to protect the host properly. Now I'm going to follow your recommendation and split the patch. Thank you, Vasily Averin