Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1481712imn; Sun, 31 Jul 2022 08:39:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vs25oVGWgRJvcwpBn2V4s4U7eoOF/sSzIDGL8HktVzKh/6vsRA2a/PvB9svBSm2FVlHWSX X-Received: by 2002:a63:688a:0:b0:412:6728:4bf3 with SMTP id d132-20020a63688a000000b0041267284bf3mr10276092pgc.339.1659281947366; Sun, 31 Jul 2022 08:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659281947; cv=none; d=google.com; s=arc-20160816; b=JqD8hFN5kDeZPFkO+Jzy6yfD7a12JtSmSy3NyIsWlWoXDalT8KEkmcf1K6mfGINhn8 CzLxgCJwctYyCoQeo08BLDMQtdxAbBFeNmnG/eIkNZ7zuLopz7yGF5QhR1uum4aBYSI5 GGYuM5bEpj+OQhRPYCq1CFlikznlCFCFKYlrGJLZWeBXzAbL/6mITTylLHXhIF5JAe8p s7nhzRmEujUeDedbYcKGeVZOQ8yvQ5Ev3/vsl09azE+9W/npNQN0k5mGCZz+QCbaMF44 b3A9r6GBuZW9CgHFqyqcnR4CGSyYPv2dHS8RJ0q9tw4109V9HzE3Ov4DEaXGfsv47m0B Rqsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:dkim-signature; bh=dLMU8cfmeXOwQMYX1yaqh+nDmpJAlXyyoWjpPIJaK14=; b=ykR9Q3i+klmF2lEe99Iwr8tuhYwlK9ENWHkwtSDpJuOIzl9ZZKG3GqjsmiuO4J+ImC kQMFAAZq8x+FaqkMQTEJekofNycWpVYfaajqh7/x0m3BsML7JegXL7w/iepgK7IrwaVX ggwQd3gx79jJueUlL9tpUJRQmRBqjW6BCW6/uu8s9rNazjfWODEDxT0QZ9DN5fKr8V6T ZM9YDv5f4AMlhxB2Ivk26lmA8luqMTxSiz2l8E5g8WIycTAbJZlWAntlOxzOIdz9C4Md FpxEWoMKG4cxMoiVUQ45rMDzdkZf3Ze5uhKZ+09a3Y4rKBLPaX4nayNLQYonafwte4+B kPzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=OQ2T1gW7; 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 j3-20020a170903028300b0016a65a43611si10931651plr.149.2022.07.31.08.38.52; Sun, 31 Jul 2022 08:39:07 -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=OQ2T1gW7; 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 S236937AbiGaPhf (ORCPT + 99 others); Sun, 31 Jul 2022 11:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233471AbiGaPhb (ORCPT ); Sun, 31 Jul 2022 11:37:31 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1273E09F for ; Sun, 31 Jul 2022 08:37:30 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id t1so13733634lft.8 for ; Sun, 31 Jul 2022 08:37:30 -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:from:subject:to:cc :content-language:content-transfer-encoding; bh=dLMU8cfmeXOwQMYX1yaqh+nDmpJAlXyyoWjpPIJaK14=; b=OQ2T1gW7fN1KfFahpZTiAWfAs4+oCZLhNsarKrbHuKmufzCF6hW51D7gw+YizPxEDa rH9pMctJBxhxvVXjuvaDpb6VQMzWRE3Cc2sR5lQIv1X+M740XjS0g4CQg7R4JYM8c+3l ukk1EQmxl6kS/PdNYyHmDjvbPLTV5RpHAR+e2TeA+6zxqYx0EZQFFXaOVr2A+TRYGolG SuQMr7CnmreNgHzxWeHPHxq06WAYI70gjRVsbbr7DJXTDN/6x+Tj/drXK8ZfoZ0Q4+4G CNERPMHwdoSjnSUhCwWRD64Lo02nVasYItdI9UHvpa7h/Oxi1MbsoE/Zr0bzdOBz9+pS 5HAA== 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:from :subject:to:cc:content-language:content-transfer-encoding; bh=dLMU8cfmeXOwQMYX1yaqh+nDmpJAlXyyoWjpPIJaK14=; b=eWgmSYgsHgj9W8fe1spSVW4qU43EiU2AOEbS/Durn8htwNfQc1J6xoyMUSqeSXpnLp UwR6HgNpAJ2b8er1Tq8nBd6dW6keqLGDF9ogIOXRQP8VhTxCavA9upLPkcWhloACZ+oz 9Ka6X3nAnqcxsOji7VHmnUUQ/XA82ITio7pqMFGtvsTg2wPbSUUI5k1MOTJIkEClntuG mg+RdrKkkDquGeQv3DbcVaLIV/EW3SN+TgZ4HoX/AF7aoB6g5hMjqlBYTfwAhgggxyrF UAFABgU/U9Yt5SrUk8MwYoqwCHKakuaO4FvFdg42ablEe4VI3xfhOko0csu4VdHkvcoW jFeA== X-Gm-Message-State: AJIora+K73PHbg/3NEVcPjEEXMueEaMIKEzbRFAYoa+PxzgyHlJc33+s Cz7Df43Xsmg1jMYrNRpRH9U5Ag== X-Received: by 2002:a19:dc4d:0:b0:489:63cb:20c7 with SMTP id f13-20020a19dc4d000000b0048963cb20c7mr4018567lfj.101.1659281848701; Sun, 31 Jul 2022 08:37:28 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.143]) by smtp.gmail.com with ESMTPSA id r10-20020a2e8e2a000000b0025e42f8e771sm714084ljk.34.2022.07.31.08.37.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 Jul 2022 08:37:28 -0700 (PDT) Message-ID: Date: Sun, 31 Jul 2022 18:37:27 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Vasily Averin Subject: [PATCH 2/3] memcg: enable accounting for kernfs iattrs To: Greg Kroah-Hartman , Tejun Heo Cc: Alexander Viro , linux-kernel@vger.kernel.org, kernel@openvz.org, Shakeel Butt , Roman Gushchin , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Muchun Song , Michal Hocko Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 kernfs nodes are quite small kernel objects, however there are few scenarios where it consumes significant piece of all allocated memory: 1) creating a new netdevice allocates ~50Kb of memory, where ~10Kb was allocated for 80+ kernfs nodes. 2) cgroupv2 mkdir allocates ~60Kb of memory, ~10Kb of them are kernfs structures. 3) Shakeel Butt reports that Google has workloads which create 100s of subcontainers and they have observed high system overhead without memcg accounting of kernfs. Usually new kernfs node creates few other objects: Allocs Alloc Allocation number size -------------------------------------------- 1 + 128 (__kernfs_new_node+0x4d) kernfs node 1 + 88 (__kernfs_iattrs+0x57) kernfs iattrs 1 + 96 (simple_xattr_alloc+0x28) simple_xattr 1 32 (simple_xattr_set+0x59) 1 8 (__kernfs_new_node+0x30) '+' -- to be accounted This patch enables accounting for kernfs_iattrs_cache slab cache Signed-off-by: Vasily Averin Reviewed-by: Roman Gushchin Reviewed-by: Michal Koutný Acked-by: Shakeel Butt Reviewed-by: Muchun Song --- fs/kernfs/mount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 3ac4191b1c40..40e896c7c86b 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -397,5 +397,6 @@ void __init kernfs_init(void) /* Creates slab cache for kernfs inode attributes */ kernfs_iattrs_cache = kmem_cache_create("kernfs_iattrs_cache", sizeof(struct kernfs_iattrs), - 0, SLAB_PANIC, NULL); + 0, SLAB_PANIC | SLAB_ACCOUNT, + NULL); } -- 2.25.1