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=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 9BE7EC54FB2 for ; Tue, 20 Oct 2020 13:49:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEFE522250 for ; Tue, 20 Oct 2020 13:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEFE522250 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E1D166B0062; Tue, 20 Oct 2020 09:49:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4FB6B0071; Tue, 20 Oct 2020 09:49:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6DF66B0072; Tue, 20 Oct 2020 09:49:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 9694A6B0062 for ; Tue, 20 Oct 2020 09:49:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2ED0A3625 for ; Tue, 20 Oct 2020 13:49:50 +0000 (UTC) X-FDA: 77392436940.09.sand80_341216a27240 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 0CF9A180AD806 for ; Tue, 20 Oct 2020 13:49:50 +0000 (UTC) X-HE-Tag: sand80_341216a27240 X-Filterd-Recvd-Size: 3109 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 13:49:49 +0000 (UTC) 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.