Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4032562pxu; Tue, 20 Oct 2020 06:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLpEfpAiOhlvRoTy5Yi1o5sDcwV7UzUbmdbVZ6cY7+R5QlTil2ljh1a+OW+txLIh180meV X-Received: by 2002:a50:9a86:: with SMTP id p6mr2869303edb.96.1603202002463; Tue, 20 Oct 2020 06:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603202002; cv=none; d=google.com; s=arc-20160816; b=Ie3p96SIdlbv8ZnfGddL746yzZZkgBJkP0eLmtKASoMFV3toLcFBiCBDLjZqii1AmJ aBCWqV89N5yxkD2RgX13T7gzkAMcn4haerKmx9KpiP4hWciA+fxZV4D19frb39M3BdHw QYPUjpyrX4vxPjANXJvD2MtaKVHT4bO42NdO5vVJG2aSW3YAxl+HO+xydY32DKy/6gjn iPULbWj3pRCLcvU/RyKBkFmYY5i4UcO7ay9ApYtqy6VqxGr7AoYl23jgHmUt3p8Jubk9 fr+Lq3M9RdSc6V0Nf3jbqHvjJupJKo1PhwRZHWX1f4aj6B6cCwBG9XYaYkhZR6BHFCO7 mo/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to :reply-to:subject:cc:to:from:user-agent:references; bh=fPTA6V40+XNIrjdoDY1eAQkMo7+AOaVQAvpVWY2jHac=; b=futG3pAqaME+PFnA1hhWmKwRvzobQViYHOGjlDv06DsmlCbK5fvNEUwUQsJGMSgGVQ 3qqLuxo/V7CQhL87/U6MBBXtYAshhJ8yh1Iia/IucJ7vUlMqATjgJaaQjOVnw8qUAJbM 15EUwGY2rrXINnzP6VmaYC4k8CBGU4aXcL/GGCcKBAaLORxMqbIHU4Q1M00iOlbqVnB9 7ncWURMPC7qESU8ElPUUdQRXvgYv5mACgDf3Zr9Pd2F1VIwl6D3h32ZrWV02z2KN9dNS BUclfMVyiEKRBk9ytlakex+P7EQlQ5abY0z/GM8eK1Lx11FH83DEo7lMm+f766mBKHnF pmMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si1681634ejb.488.2020.10.20.06.52.58; Tue, 20 Oct 2020 06:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407707AbgJTNtv (ORCPT + 99 others); Tue, 20 Oct 2020 09:49:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:52560 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407704AbgJTNtu (ORCPT ); Tue, 20 Oct 2020 09:49:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 49988AD72; Tue, 20 Oct 2020 13:49:48 +0000 (UTC) References: <87lfg2ob83.fsf@suse.de> <20201019095812.25710-1-rpalethorpe@suse.com> <87mu0hwik7.fsf@suse.de> User-agent: mu4e 1.4.13; emacs 27.1 From: Richard Palethorpe To: Shakeel Butt Cc: Linux MM , LKML , "LTP List" , Roman Gushchin , Johannes Weiner , Andrew Morton , "Christoph Lameter" , Michal Hocko , Tejun Heo , Vlastimil Babka Subject: Re: [PATCH v3] mm: memcg/slab: Stop reparented obj_cgroups from charging root Reply-To: rpalethorpe@suse.de In-reply-to: <87mu0hwik7.fsf@suse.de> Date: Tue, 20 Oct 2020 14:49:47 +0100 Message-ID: <87eeltvwg4.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Richard Palethorpe writes: > Hello Shakeel, > > Shakeel Butt writes: >>> >>> V3: Handle common case where use_hierarchy=1 and update description. >>> >>> mm/memcontrol.c | 7 +++++-- >>> 1 file changed, 5 insertions(+), 2 deletions(-) >>> >>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >>> index 6877c765b8d0..34b8c4a66853 100644 >>> --- a/mm/memcontrol.c >>> +++ b/mm/memcontrol.c >>> @@ -291,7 +291,7 @@ static void obj_cgroup_release(struct percpu_ref *ref) >>> >>> spin_lock_irqsave(&css_set_lock, flags); >>> memcg = obj_cgroup_memcg(objcg); >>> - if (nr_pages) >>> + if (nr_pages && (!mem_cgroup_is_root(memcg) || memcg->use_hierarchy)) >> >> If we have non-root memcg with use_hierarchy as 0 and this objcg was >> reparented then this __memcg_kmem_uncharge() can potentially underflow >> the page counter and give the same warning. > > Yes, although the kernel considers such a config to be broken, and > prints a warning to the log, it does allow it. Actually this can not happen because if use_hierarchy=0 then the objcg will be reparented to root. > >> >> We never set root_mem_cgroup->objcg, so, no need to check for root > > I don't think that is relevant as we get the memcg from objcg->memcg > which is set during reparenting. I suppose however, we can determine if > the objcg was reparented by inspecting memcg->objcg. > >> here. I think checking just memcg->use_hierarchy should be sufficient. > > If we just check use_hierarchy then objects directly charged to the > memcg where use_hierarchy=0 will not be uncharged. However, maybe it is > better to check if it was reparented and if use_hierarchy=0. -- Thank you, Richard.