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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 30508C433DB for ; Wed, 24 Mar 2021 09:20:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9B7E619E5 for ; Wed, 24 Mar 2021 09:20:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9B7E619E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 17FCA6B02A7; Wed, 24 Mar 2021 05:20:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12FD26B02A9; Wed, 24 Mar 2021 05:20:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F126C6B02AA; Wed, 24 Mar 2021 05:20:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id D470F6B02A7 for ; Wed, 24 Mar 2021 05:20:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 87A6E1DE8 for ; Wed, 24 Mar 2021 09:20:29 +0000 (UTC) X-FDA: 77954222178.22.5E241E8 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf14.hostedemail.com (Postfix) with ESMTP id E8676C0007C5 for ; Wed, 24 Mar 2021 09:20:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616577628; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7gLziUiladtyJd3p/ln2FmDe2g6zHX+KsW0OGVFj21E=; b=VbHnPFE42SYJRuEFkhkWAHr4t4p5qxQJFsfZtY++E0e10Oi90jUMuP+zzxNFPz8a9B4/r5 03tb8a/woot6C3mA/isgfeHqnxPl2AYvprLiKqyKLbsAKxnFJUkqMiVlLv0bKVDUtwVFUC UGcnOeyxadhb/QMMNWjhwTBfwijht1Q= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D1E0EAC16; Wed, 24 Mar 2021 09:20:27 +0000 (UTC) Date: Wed, 24 Mar 2021 10:20:25 +0100 From: Michal Hocko To: Muchun Song Cc: Roman Gushchin , Johannes Weiner , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List Subject: Re: [External] Re: [PATCH] mm: memcontrol: fix memsw uncharge for root_mem_cgroup Message-ID: References: <20210323145653.25684-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E8676C0007C5 X-Stat-Signature: 5aifzc1c1hf4zuyfozxbwzi48z1893f3 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616577626-959107 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: On Wed 24-03-21 16:50:41, Muchun Song wrote: > On Wed, Mar 24, 2021 at 4:33 PM Michal Hocko wrote: > > > > On Wed 24-03-21 12:11:35, Muchun Song wrote: > > > On Tue, Mar 23, 2021 at 11:04 PM Muchun Song wrote: > > > > > > > > The pages aren't accounted at the root level, so we cannot uncharge the > > > > page to the memsw counter for the root memcg. Fix this. > > > > > > > > Fixes: 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from offline cgroup") > > > > Signed-off-by: Muchun Song > > > > > > I am very sorry. I should repent. I suddenly realise the fix is totally > > > wrong. Because the @memcg cannot be root memcg when > > > @memcg != @swap_memcg. > > > > I am probably blind but I do not see why this would be the case. > > We have memcg != swap_memcg in this branch but we do not know the > > neither of the two is root_mem_cgroup, no? If we did knot that we > > wouldn't have to check for swap_memcg != root_mem_cgroup. Or do I miss > > something? > > I look at the mem_cgroup_id_get_online() closely. If memcg is root, this > function always returns root memcg. So memcg will equal swap_memcg. Ahh, I can see it now. I have completely missed that the swap_memcg is a parent of an offline memcg. I should have looked more closely. -- Michal Hocko SUSE Labs