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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED87C4332F for ; Mon, 14 Mar 2022 09:54:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C4818D0008; Mon, 14 Mar 2022 05:54:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 673E58D0001; Mon, 14 Mar 2022 05:54:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53BB38D0008; Mon, 14 Mar 2022 05:54:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 426E28D0001 for ; Mon, 14 Mar 2022 05:54:05 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 11A70233A7 for ; Mon, 14 Mar 2022 09:54:05 +0000 (UTC) X-FDA: 79242530850.15.1343E6D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf24.hostedemail.com (Postfix) with ESMTP id 867A718002E for ; Mon, 14 Mar 2022 09:54:04 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 72ED2210FE; Mon, 14 Mar 2022 09:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647251643; 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=6VPBVQrxRZ4Cx7+iuRgH+2wDidcAf0gmeaDeqXu8ow8=; b=uoiY0spO/Ap8AdtaUTbRUJl58srkazDganaxbtxD0SvT4OF+KtD/ux6hk3ueqxX3EGYSu8 3c7E3zpadTc2qGeE9wDEVL6l9ZxN/hlQAFwh+2UJy2pFUjgaa0NOxcMOR6iuKz6UyqfBHr k6RF+rr6F+tvDC5mnQrI0i5fti0aj78= Received: from suse.cz (unknown [10.163.30.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5BF37A3B81; Mon, 14 Mar 2022 09:54:03 +0000 (UTC) Date: Mon, 14 Mar 2022 10:54:03 +0100 From: Michal Hocko To: Wei Yang Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [Patch v2 2/3] mm/memcg: __mem_cgroup_remove_exceeded could handle a !on-tree mz properly Message-ID: References: <20220312071623.19050-1-richard.weiyang@gmail.com> <20220312071623.19050-2-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220312071623.19050-2-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 867A718002E X-Stat-Signature: ipac1bec11dru8wfgakqtbbzixxzsxfj Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uoiY0spO; spf=pass (imf24.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1647251644-987491 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 Sat 12-03-22 07:16:22, Wei Yang wrote: > There is no tree operation if mz is not on-tree. This doesn't explain problem you are trying to solve nor does it make much sense to me TBH. > Let's remove the extra check. What would happen if the mz was already in the excess tree and the excess has grown? > Signed-off-by: Wei Yang > --- > mm/memcontrol.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index d70bf5cf04eb..344a7e891bc5 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -545,9 +545,11 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, int nid) > unsigned long flags; > > spin_lock_irqsave(&mctz->lock, flags); > - /* if on-tree, remove it */ > - if (mz->on_tree) > - __mem_cgroup_remove_exceeded(mz, mctz); > + /* > + * remove it first > + * If not on-tree, no tree ops. > + */ > + __mem_cgroup_remove_exceeded(mz, mctz); > /* > * Insert again. mz->usage_in_excess will be updated. > * If excess is 0, no tree ops. > -- > 2.33.1 -- Michal Hocko SUSE Labs