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=unavailable 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 05F81C433C1 for ; Wed, 24 Mar 2021 09:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4A8261A01 for ; Wed, 24 Mar 2021 09:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbhCXJUf (ORCPT ); Wed, 24 Mar 2021 05:20:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:38758 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231685AbhCXJU2 (ORCPT ); Wed, 24 Mar 2021 05:20:28 -0400 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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