From patchwork Tue Mar 8 01:20:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12772861 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 A6B9EC433FE for ; Tue, 8 Mar 2022 01:22:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 098A58D0003; Mon, 7 Mar 2022 20:22:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC52F8D0001; Mon, 7 Mar 2022 20:21:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D17148D0003; Mon, 7 Mar 2022 20:21:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id C2A3D8D0001 for ; Mon, 7 Mar 2022 20:21:59 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7B722456 for ; Tue, 8 Mar 2022 01:21:59 +0000 (UTC) X-FDA: 79219467558.08.B3BE6E5 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf08.hostedemail.com (Postfix) with ESMTP id 0E13F16000A for ; Tue, 8 Mar 2022 01:21:58 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id yy13so26968465ejb.2 for ; Mon, 07 Mar 2022 17:21:58 -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=Mr7bFXwRFUanMnGNnpUckpJUfAZz88L9eyoAngmHhhUmy7Hqswp/VuwagZ443cQndP oCYNfJQDtVorLVlM6sGSf1Aw7fwzcJjKa3hocgArdnUC2b8mUekANMGbZ7JYBxM1ER2N Bwv1pVU1nOKa3h9I+wd+bRWNJvymSim3EsfV01aqg571rb8b1vSnMwMVgQzwupbz4ds6 FlngrH9dFe5VxrBvaH5tLHpypB4tePgIJHkW6e3MDcukco9XUnen3VuH8mD2iDs+fa92 Uqac1l6dB+FODzmk4AEz546j7iblgAs5xOPKwCRZt77Z6pZQTSBQDhKNLnCAm66OnC50 M9QA== 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=4EheIgpMJKbZUGm0p1Gz0THBNzZ4aDJGcZW0Tqjl91sam12K2/WPRTT9+nx8DwdJzd zU0ahEltDqcCGbAE/7t3u/nnbIJXW+13usweDepMR1F2+HRwr6wKMc0MQ2N2cFjkcvrY eVljPo+y5By11EC8SQTUg2Mh9oFBwMrkxNx7SkTVp8YNUF2YjzH3TA605EnPnbIP/L6i Q7eyRWAXFgCUQED+I07RNOq1q+G9GZH9yAONq0agbaBIuCRLeUVzQFJpFT3G1laB3bm0 li+jSaYi42WyadQy0r+zppPEQAAFOdAPfvOA6rM/nIPnbM8jn7gpgkPMvUwtvD2v6N5I UjKw== X-Gm-Message-State: AOAM5329BfkEq2B+oZlid6EBCuart4WmtZviiE16NHVaTkt70+/XOt/m o7SQRJ0ouppDUB/7rb52Q5o= X-Google-Smtp-Source: ABdhPJx09GW0/xl9K5HY0fZYhxSqJvtB8pApBKzQSpKrpGl5Yvn4FmsY9YM+Gg+leQdC0K4o0dpNnw== X-Received: by 2002:a17:907:6d97:b0:6d7:49e:275e with SMTP id sb23-20020a1709076d9700b006d7049e275emr10969974ejc.410.1646702517716; Mon, 07 Mar 2022 17:21:57 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id x12-20020a50d9cc000000b0040f70fe78f3sm7041392edj.36.2022.03.07.17.21.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 17:21:57 -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 2/3] mm/memcg: __mem_cgroup_remove_exceeded could handle a !on-tree mz properly Date: Tue, 8 Mar 2022 01:20:46 +0000 Message-Id: <20220308012047.26638-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220308012047.26638-1-richard.weiyang@gmail.com> References: <20220308012047.26638-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0E13F16000A X-Stat-Signature: nc7a81hdfhnkhskyb1wrtogmrxwt3cih Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Mr7bFXwR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-HE-Tag: 1646702518-98792 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.