From patchwork Tue Dec 5 19:54:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 13480683 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 CBF29C10F05 for ; Tue, 5 Dec 2023 19:54:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB356B0092; Tue, 5 Dec 2023 14:54:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29B886B0093; Tue, 5 Dec 2023 14:54:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13CA86B0095; Tue, 5 Dec 2023 14:54:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 01A706B0092 for ; Tue, 5 Dec 2023 14:54:23 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BFA621C05B9 for ; Tue, 5 Dec 2023 19:54:23 +0000 (UTC) X-FDA: 81533816406.14.64B009C Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf29.hostedemail.com (Postfix) with ESMTP id E07BC120019 for ; Tue, 5 Dec 2023 19:54:21 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Sh6WFm6N; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701806061; a=rsa-sha256; cv=none; b=Pz4K4rJv0fm41BEv4oiHD/95z+zpY/12TR5fflhX0zx6dRWjV4PqzDBPaD1NWEx598AE0e 4CpKtwqTezcKWy7b4lk9jO/+RxxGJZr1c7sjborOIqEJWunqjGnDsQdrRhHY5vuKVK9XCT +Z27600JQolqJQyZ5YrCLoNNTCEIa2w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Sh6WFm6N; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701806061; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jBZzT0/QbcprxNQTsHpzd6ven1aj0800Yb9/CoMbKBA=; b=qGND/Y4A9/msZJebYhT3iYu9f5qht/JKHUJ5MYS0Og0jN5JtsNxnMh1l0JrH6aF4PbGPtJ eSyMB8z4H+9BJjO0R7c533umTbh/2IkLM/n96YLGnCbOMGJVxi0jtCR3KHRiGV6AWmdTSJ eUT15zla2nl4WP3Mwef/VYCwC9kYV20= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d03fb57b69so29704225ad.1 for ; Tue, 05 Dec 2023 11:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701806061; x=1702410861; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jBZzT0/QbcprxNQTsHpzd6ven1aj0800Yb9/CoMbKBA=; b=Sh6WFm6NQieZu9vetX0a7eLVvW1S4lMUkGiLJBjDf1X+4OuAMFKVK8PQtty2Re6Yqj NsYc/Gc3kHG7Xfy+WSHw2+H1utZmd7OMCS7rM7XKegxZToKjGZm494cVpaOKoQJfCtT5 hPDusIHxlCV92AnmeXadmvEIOXWrKrWwmqiEWXCowjGWGS4ji55I1TO9zL+KytopPI6y lN9y2FeaEr3+2gblkdJRq63BPyyCKb1wKU4ISkGKypL4JfhkDl5Gv8wp2E3pyGs/Kd3E Y6R8z6NpoQK9XqFkqjG4fg+8CXv+csF4Z1i7vqS9fhrwpGync81Q/VCe8KPn7nMcvShP yjPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701806061; x=1702410861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jBZzT0/QbcprxNQTsHpzd6ven1aj0800Yb9/CoMbKBA=; b=bDlfleplJDOKwmOVR3QkzP20YGgStlp8yVuwBF+sbRUz8jMLsG1H2/O9+5Kphfdx1L DfhLtqjBa33c+wPHhL7CcFTEKrOFbqR/w93+hK+GwkzvSDfDcaRWVufbJ2uRiFmQvhf5 XlqGWJv326dBsruxd02Mgsoz5rAJiO/qoV0Wy+zBB4KDQiQ6fKqI8pRMAWIgzdn5VO7f IlTyunA1Trmml4IJgz0Na8AEeFlNzGBCQxtTu76hFLGDhT7XaBmcocMG6WQNdZMPfusM PmTl9lmS7TEhuryQR+D8Nkx10GLn4NhBGAmcyYj8Ac6jJz6aLgO3SIZztRvh+dxgc9kE yHbg== X-Gm-Message-State: AOJu0YycWo6WaYfZuW4GAIx8l5K6Q8FgJcwolysIqiTQgFilySh1Bpvh q9u03z3uo4Y05hZZDuRjgRY= X-Google-Smtp-Source: AGHT+IHiN3u4lyG7cLPBE6NoEoYHDNHgelzGc9AxrA8KJTfHwHiCxIp8MO1xA3yLPhPxAMw1q8En6w== X-Received: by 2002:a17:902:8696:b0:1d0:6ffd:6e8e with SMTP id g22-20020a170902869600b001d06ffd6e8emr3152372plo.134.1701806060641; Tue, 05 Dec 2023 11:54:20 -0800 (PST) Received: from localhost (fwdproxy-prn-024.fbsv.net. [2a03:2880:ff:18::face:b00c]) by smtp.gmail.com with ESMTPSA id c15-20020a170902d48f00b001d0cd9e4248sm876201plg.196.2023.12.05.11.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:54:19 -0800 (PST) From: Nhat Pham To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, cerasuolodomenico@gmail.com, yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, chrisl@kernel.org, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Subject: [PATCH v8 3/6] zswap: make shrinking memcg-aware (fix) Date: Tue, 5 Dec 2023 11:54:19 -0800 Message-Id: <20231205195419.2563217-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130194023.4102148-4-nphamcs@gmail.com> References: <20231130194023.4102148-4-nphamcs@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E07BC120019 X-Stat-Signature: tqrodoexr4hykctqnukk8e43poeb3xq6 X-HE-Tag: 1701806061-675252 X-HE-Meta: U2FsdGVkX196GCBNCQ5Z9DeghU0wzBlIBgHBp2PkW4xeJFvsfSrY+Clj1JURkx7j6/jZCOYE3RFIg0bGRH5jtTkzRgktk3HgMVLIuc9zeazhGqUMYmIepxDOaizlXEA0alZEsPzOYSqQcLrK5k6tAoFnjEAx9WG0dGxzEM0lSh0bSLutqdGutwz0ohpfVScqvpIDj0pNULoQqYSn5iZ7urjq/A06batxrI4srV5LxTG2qsu+1+SDetkyMbknVgsdt75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zW1PZo+ArQoM3pN6tvOQiEJBT/BaiyWYGNiS5tTcD3HX8rJAPuIGzVaDzgusVChSBuwI93HcKBeGP3kzlQbwFL7Qc1aFkyu5E7FUCE1hyksByJvEBN6CTEjZqYCTiURUv/mSPZx/DVw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000317, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use the correct function for the onlineness check for the memcg selection, and use mem_cgroup_iter_break() to break the iteration. Suggested-by: Yosry Ahmed Signed-off-by: Nhat Pham --- mm/zswap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index f323e45cbdc7..7a84c1454988 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -834,9 +834,9 @@ static void shrink_worker(struct work_struct *w) goto resched; } - if (!mem_cgroup_online(memcg)) { + if (!mem_cgroup_tryget_online(memcg)) { /* drop the reference from mem_cgroup_iter() */ - mem_cgroup_put(memcg); + mem_cgroup_iter_break(NULL, memcg); pool->next_shrink = NULL; spin_unlock(&zswap_pools_lock); @@ -985,7 +985,7 @@ static void zswap_pool_destroy(struct zswap_pool *pool) list_lru_destroy(&pool->list_lru); spin_lock(&zswap_pools_lock); - mem_cgroup_put(pool->next_shrink); + mem_cgroup_iter_break(NULL, pool->next_shrink); pool->next_shrink = NULL; spin_unlock(&zswap_pools_lock);