From patchwork Sat Mar 12 07:16:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12778753 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 B8ED5C433FE for ; Sat, 12 Mar 2022 07:16:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9475E8D0005; Sat, 12 Mar 2022 02:16:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F66B8D0001; Sat, 12 Mar 2022 02:16:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BE318D0005; Sat, 12 Mar 2022 02:16:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 6B4568D0001 for ; Sat, 12 Mar 2022 02:16:46 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 231758249980 for ; Sat, 12 Mar 2022 07:16:46 +0000 (UTC) X-FDA: 79234876812.29.4EF0C70 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf20.hostedemail.com (Postfix) with ESMTP id AD87F1C002C for ; Sat, 12 Mar 2022 07:16:45 +0000 (UTC) Received: by mail-ej1-f54.google.com with SMTP id r13so23461916ejd.5 for ; Fri, 11 Mar 2022 23:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TJpD8WbIgS+xru6bpF+N+uC+vSCiqZY6PRQI5LvMXoI=; b=OnRswjgsCsJLFDXAhDVynEt+QYId9QLq2eHDAEGp5uy8DDCncYRh8UPekuSANb8xek Uuhz8NXACFvzoNgKCB4ogBbvV5t8gNdEgaIlRNqa5fFzRh1LKQ8qeldQvEsU1MG8zw1L tcTWMUMWZTo+VcEiFj29ZSoZuesvJ5oMfToBXCxntl0z5UxIGq2X2thLpSVzSISfl3D9 aJB3QH2GA3EocBRfi5OMW/l3JuSvo/98FA9zrQorYBY7egSblrVCqiyrdO0wt89FE8/C 4tHdbz4ubwNz8YN1HWJ+u8cZOkBvCxAUJqdor7obk60+IxdbIZBVE+bRuXQnRI4j/EX0 45vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TJpD8WbIgS+xru6bpF+N+uC+vSCiqZY6PRQI5LvMXoI=; b=Lb5uErfTcSmZ0ikONRH2NFJ9CaCarN3fxwYW+4/ja63UZf6dKR/QACuiCeTvht3LLv 61kGvOJxk0/d2dokkYH7Cb6GgDf+F5OFOY8sF5EuC+uThxt0NF5Fiong8JNtu8z3r9aj Rl1PIol3yWQ1u63S6UVk7RVE0jpWpwBaYMexB0F/O3J/TLS4xkZ3HxaVYbEwY+0FNnPJ xIDCns+LWUPS3FPG18mEmBP3UmhS3qnmKnRDlwdQZIJ/f4P/iqmFRc6l59nvdgRl2H28 lpEgCb7g/563LM6RLVPmoH6wnaEkMFDbqV9pxSvrjG/J9Ard+E1C5I3XMHqrMHWi+B3v wfVw== X-Gm-Message-State: AOAM530s60V5LQal+hOa/E2naJG9ECVzNGEsFeKo7NrwiSS5eCBAuoWy FtrK5dCIzqSdSHJvxg9AbH4= X-Google-Smtp-Source: ABdhPJwOiV2aWkyrs3vCcOFujLCY3MWpms8vOw/gMA0k9/NHKb6WJplYCMpsRJZOnOmN9PpwNKGF/Q== X-Received: by 2002:a17:907:7f1d:b0:6da:74b1:fd65 with SMTP id qf29-20020a1709077f1d00b006da74b1fd65mr11848542ejc.72.1647069404297; Fri, 11 Mar 2022 23:16:44 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id h18-20020a1709062dd200b006db26396622sm3875907eji.212.2022.03.11.23.16.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Mar 2022 23:16:43 -0800 (PST) From: Wei Yang To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Wei Yang Subject: [Patch v2 2/3] mm/memcg: __mem_cgroup_remove_exceeded could handle a !on-tree mz properly Date: Sat, 12 Mar 2022 07:16:22 +0000 Message-Id: <20220312071623.19050-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220312071623.19050-1-richard.weiyang@gmail.com> References: <20220312071623.19050-1-richard.weiyang@gmail.com> X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OnRswjgs; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AD87F1C002C X-Stat-Signature: bjn8mce7zn7ha4kngh1eqi7m8m4apjo9 X-HE-Tag: 1647069405-871464 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: There is no tree operation if mz is not on-tree. Let's remove the extra check. 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.