Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp459988ioo; Sat, 21 May 2022 04:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKBzlv6g/3sw9tW/lZdm+6sGtJJI/zuc8D99ctwgTNPXlEKV/XVLe3fZ7UzjVOUThALsI1 X-Received: by 2002:a17:907:8a0e:b0:6f5:a48:e04e with SMTP id sc14-20020a1709078a0e00b006f50a48e04emr12552231ejc.228.1653132376045; Sat, 21 May 2022 04:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653132376; cv=none; d=google.com; s=arc-20160816; b=hXks0RRVf5ESQz11xmOE5egUaXbUYOcVaAdy5Jg/GhemN3pap+EfIOxvq1ZRseR2V9 DKZ5n29WYOz+xxgbBm5O1CNvhK/AvqxkU3IClmijVMhHapwLVV6y5T0Nft1djoAwPmi8 RO5gmGrMmUa4IBqxwpERzhvoUbpTnLiDTxiXCsSW8FO1JMXlZGe/xNjmOdFr/33hICMo fFI7UyJ9TkKO+CqtLhhn562aGBPQZ+bXH711NIRVTXU7ukIbmGKZXLk88DGxoW5I/Ue/ deumfHBMaIdaA3kzLY3/SiK+vIKlG5MxQx+OkNsQJ9uTd715SeZU2hRvNVrnL9Eb4CTe 4Fuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=G6gtvqYNjnVwht1zFDxId2+CvU+SMvS0Nm0E4p7o9cM=; b=yE9PqORaBKfp/2LTsU0fW9gAfjMwLX9J8NZh1Jb/QDZibAozMxjaPSCnIT6/nFNG27 pps5jE5RaMNMFw5mEkE+1SWsO/TxoWDV5MVtMjv77nZY214olHyfz09iDzq7g/ixcoBQ 1hftMximg1YJB24xq64pi5Dt4tI1ICwR56K3y31CFWxUhPgkPwxn4ullqVTJtMQ9RCNq /I4A6rb81xoz09KEH/tOvGxfa3Yob5QtqPu2v/ryms9L7gvoOmbORJMXtUtMW6QZ4bof aNeI1ndejgP/nC4BaFfJ4nCTqlYegflHCcPyc+yLJNZpY/sKHu9cDENulU6GCDbtf2Wm UTqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Gq0rw+Mr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj4-20020a1709069c8400b006feb0035b59si4365348ejc.178.2022.05.21.04.25.50; Sat, 21 May 2022 04:26:16 -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=@google.com header.s=20210112 header.b=Gq0rw+Mr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344206AbiETBHP (ORCPT + 99 others); Thu, 19 May 2022 21:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344201AbiETBHM (ORCPT ); Thu, 19 May 2022 21:07:12 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0AFB91567 for ; Thu, 19 May 2022 18:07:10 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2ff37db94e8so59046237b3.16 for ; Thu, 19 May 2022 18:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=G6gtvqYNjnVwht1zFDxId2+CvU+SMvS0Nm0E4p7o9cM=; b=Gq0rw+MrvLWVPrWEBXryZB1jQV/V1G9kqtZ5HVH9URkE6LQh50hBnHJMNqkGngRE1B OKQFxrvMTob/C1c6Prc225WuKjE8WCTLx3fHin7rlnzNSeIOtlGLTu74nl6iciYuNa6V wKGClUZev9JgvVbePXUNUNBu7Uz1/J49jE9sWsl47yg7HwP0TiOqv882QwVKD+FEXZY5 VRHfGsaPeQ8uLVWv02vR138ZcXZ+G+eh5CxwWdQnlEieVAYcg1VZgbsIj+VW85zoNOBM wo1vIABj/7CfTuXAAnloVwGNjfYF36gl6mrEArXq+HVLQCpFYG1ejzHnmXk3KpUV9HEj Th3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=G6gtvqYNjnVwht1zFDxId2+CvU+SMvS0Nm0E4p7o9cM=; b=B+OJdI2HUHnZWQkAWkWxSD7SNMVWvSLxVFvevv84i21+Uzdyma850EWLY0g6vY5Uk0 wD6HhHdpYyxixccEc5HXZnWdHESOew120pzU0FFK8IqdzeJ2Ip4Y9Yecvoa09qSxbRvl DxhWijCwbR9utvwoylFQf1dcK8t57GhGB4hlh+I5pyKlTu57aHU6NzA4A4nsVrWLvRy8 BUsBcaifb90G/ZQv1ISBGjFGjarDABoWz/1FHfBzZxEx/Cd7mOiFHn/5skjRtgZZK78n 8ih4VnWf/lXxaXk11jgsUyCVuumNoLLtCRwNdmI26nW0xfx56jGeRUA/SMd7SnP+A3/b QRgg== X-Gm-Message-State: AOAM533OCxzgZU2R8hHpYvD7obP+Hgs1dTHQn28fYemQu4nEeq/Ex3R4 bXVEZ8rNM2Ahox/DxxvjRHoFV3rVSDvNdA== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:28b]) (user=shakeelb job=sendgmr) by 2002:a25:2f16:0:b0:64c:b761:b440 with SMTP id v22-20020a252f16000000b0064cb761b440mr7560583ybv.359.1653008830081; Thu, 19 May 2022 18:07:10 -0700 (PDT) Date: Fri, 20 May 2022 01:07:07 +0000 In-Reply-To: <212f1b74-7d4e-29f2-9e92-2a1820beff61@openvz.org> Message-Id: <20220520010707.77z5blxpbsddwmyo@google.com> Mime-Version: 1.0 References: <212f1b74-7d4e-29f2-9e92-2a1820beff61@openvz.org> Subject: Re: [PATCH 1/4] memcg: enable accounting for large allocations in mem_cgroup_css_alloc From: Shakeel Butt To: Vasily Averin Cc: Roman Gushchin , "Michal =?utf-8?Q?Koutn=C3=BD?=" , kernel@openvz.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Michal Hocko , cgroups@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 Fri, May 13, 2022 at 06:51:41PM +0300, Vasily Averin wrote: > cgroup mkdir can be misused inside memcg limited container. It can allocate > a lot of host memory without memcg accounting, cause global memory shortage > and force OOM to kill random host process. > > Below [1] is result of mkdir /sys/fs/cgroup/test tracing on VM with 4 cpus > > 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) > 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) > [smaller objects skipped] > --- > Total 61728 > > '=' -- accounted allocations > > This patch enabled accounting for one of the main memory hogs in this > experiment: allocation which are called inside mem_cgroup_css_alloc() > > Signed-off-by: Vasily Averin > Link: [1] https://lore.kernel.org/all/1aa4cd22-fcb6-0e8d-a1c6-23661d618864@openvz.org/ > Acked-by: Shakeel Butt