From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B19EC433B4 for ; Sat, 24 Apr 2021 11:54:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD1946128B for ; Sat, 24 Apr 2021 11:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237243AbhDXLzP (ORCPT ); Sat, 24 Apr 2021 07:55:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:46682 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231203AbhDXLzN (ORCPT ); Sat, 24 Apr 2021 07:55:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=29HYTylwYhZ3dYsWBx6VPp71dTboK0VaoGXB6Hg/UoQ=; b=uijsUv9twbDkh0f/HsZ s3sQlHADWWDS3ZGT4302e/GJiseFOrKGcqCclo1Eva/7ahcHfoRfv0GEuR3IhtmXv1sD8goSwNKXX EmJ+AOqquy+3jDiiZB+n7dNUxk7Hd0PS+CsAZQWj/hBNOUKa+dKc6m4G6MgIKCu1CW/vtLzb7kc= Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1laGri-001INj-Rw; Sat, 24 Apr 2021 14:54:26 +0300 From: Vasily Averin Subject: [PATCH v2 0/1] memcg: enable accounting for pids in nested pid namespaces To: Michal Hocko , cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Roman Gushchin , Christian Brauner , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Serge Hallyn References: <7b777e22-5b0d-7444-343d-92cbfae5f8b4@virtuozzo.com> Message-ID: <163b816f-0655-1b4d-9c59-7878981be44e@virtuozzo.com> Date: Sat, 24 Apr 2021 14:54:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <7b777e22-5b0d-7444-343d-92cbfae5f8b4@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pid was one the first kernel objects enabled for memcg accounting, see 5d097056c9a0 ("kmemcg: account certain kmem allocations to memcg") init_pid_ns.pid_cachep marked by SLAB_ACCOUNT and we can expect that any new pids in the system are memcg-accounted. Though recently I've noticed that it is wrong. nested pid namespaces creates own slab caches for pid objects, nested pids have increased size because contain id both for all parent and for own pid namespaces. The problem is that these slab caches are _NOT_ marked by SLAB_ACCOUNT,as a result any pids allocated in nested pid namespaces are not memcg-accounted. Pid struct in nested pid namespace consumes up to 500 bytes memory, 100000 such objects gives us up to ~50Mb unaccounted memory. This allow container to exceed assigned memcg limits. For me this issue lookslike bug and I would like to ask to push this fix both to upstream and to stable Vasily Averin (1): memcg: enable accounting for pids in nested pid namespaces kernel/pid_namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.8.3.1