From patchwork Tue Mar 8 01:20:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12772862 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 731EDC433F5 for ; Tue, 8 Mar 2022 01:22:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B0D88D0005; Mon, 7 Mar 2022 20:22:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E7468D0001; Mon, 7 Mar 2022 20:22:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 688A78D0005; Mon, 7 Mar 2022 20:22:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 59F658D0001 for ; Mon, 7 Mar 2022 20:22:00 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 21617182E52FC for ; Tue, 8 Mar 2022 01:22:00 +0000 (UTC) X-FDA: 79219467600.26.2ACF221 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf26.hostedemail.com (Postfix) with ESMTP id 9CA79140002 for ; Tue, 8 Mar 2022 01:21:59 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id a8so35791723ejc.8 for ; Mon, 07 Mar 2022 17:21:59 -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=sX5s7jKgXd2WsU9F7nau9nEnt0LTAgg+hfHcITuEuBM=; b=ENqz0NVeHdKTzIpACb7Q9gDD11SNNdauqiy2jAzmxV49Bs5xz4/6u9nc363FgnwjOc db2aQrmbgMm+JEYdPncFEX5VQQvsjRhKVbvD+muJcfiBRB3R6diHamEZVbnJUElfYMuG K3ST7QJkIRRXUetvZ6Aad9u1qs+uNVbbL396ReLYD6W7jFWTCK/au2vp1ulGBSqTS3K8 dmGAadaViT8WcX/booDtkS9outqBMSNflWKOygUbbjiOdYnZOMAuIvhB8GjmBaXUXsnZ 1uV5J5PCNTxR8Qz3h6bQzbo+ZQ0H3mI8J0TkdHHpzQwO3jTkl8rKoNKzMKtUN1DvKjcK BMJw== 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=sX5s7jKgXd2WsU9F7nau9nEnt0LTAgg+hfHcITuEuBM=; b=vCDHU2eZzOaxJV+fSS6VBhazSHhjxjj/CQGR0PvEFgcgeJk5J2CssXtmg72jhUN+8I lBH0RDFoeMVEQS6MgOWdVGR4nqVIQ0pME3hYP7q5G8y4J1KruzWczDQL5AAqs/bTMW1t 2Tr8rG+h3tgXNdrGphnnHIflTNEHLfuvFI4/rh3/Fy+64ggtBPkyhhhDHRSQ85OauSpE REfKlPQ514kdzGoh/+xzeknxCbDjVHz3+Ap4MWmfGXZyOnKrQtzJpStg651pJRmQVg6E YQsOWTwmvJjFTALErhtTHK5rtRv5nM3RuKnRxrkfPLqVGuLSMjS0By3em3GrdGw8h/fI nBpA== X-Gm-Message-State: AOAM530yA0tuGvu+6P2WGfzPJaOQE43VZC0BIGVExTwcIWCWl+9UUbOA B7lIhRT/Pqckjl+mzViQcbc= X-Google-Smtp-Source: ABdhPJwWvWbB6M4I64azTUqYp6eC7GowACebPQj8LpOgHNGq+QTdwjlKOjawgZ8a2CZH75xh5YFdGw== X-Received: by 2002:a17:907:7f2a:b0:6d6:df12:7f57 with SMTP id qf42-20020a1709077f2a00b006d6df127f57mr11161124ejc.122.1646702518516; Mon, 07 Mar 2022 17:21:58 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id q2-20020a170906144200b006ceb8723de9sm5193049ejc.120.2022.03.07.17.21.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 17:21:58 -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 3/3] mm/memcg: add next_mz back if not reclaimed yet Date: Tue, 8 Mar 2022 01:20:47 +0000 Message-Id: <20220308012047.26638-3-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-Rspamd-Queue-Id: 9CA79140002 X-Stat-Signature: iho84ojxb5ps937717jgfjmn6cd7drww X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ENqz0NVe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-Rspamd-Server: rspam03 X-HE-Tag: 1646702519-387946 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: next_mz is removed from rb_tree, let's add it back if no reclaim has been tried. Signed-off-by: Wei Yang --- mm/memcontrol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 344a7e891bc5..e803ff02aae2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3493,8 +3493,13 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, loop > MEM_CGROUP_MAX_SOFT_LIMIT_RECLAIM_LOOPS)) break; } while (!nr_reclaimed); - if (next_mz) + if (next_mz) { + spin_lock_irq(&mctz->lock); + excess = soft_limit_excess(next_mz->memcg); + __mem_cgroup_insert_exceeded(next_mz, mctz, excess); + spin_unlock_irq(&mctz->lock); css_put(&next_mz->memcg->css); + } return nr_reclaimed; }