From patchwork Tue Oct 1 05:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchana P Sridhar X-Patchwork-Id: 13817484 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 88657CEB2FE for ; Tue, 1 Oct 2024 05:37:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1778F6B00CC; Tue, 1 Oct 2024 01:37:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2F386B00D6; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D30C76B00CD; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A838D6B00CC for ; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2369C80E09 for ; Tue, 1 Oct 2024 05:37:14 +0000 (UTC) X-FDA: 82623925188.04.E9FD941 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf20.hostedemail.com (Postfix) with ESMTP id 08E621C0008 for ; Tue, 1 Oct 2024 05:37:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ab4QoyS9; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760905; 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=5EdKqjOL7o3kOjKhQvu2azcBBD6RrwG0Yp5W/R+zxPE=; b=6/MWetLdCFM6ERid1snUP1cnqSxvt4l2vZYRaNl3OVCICcJfb+XQ6vfT7KUBD/4MupAz/K cU5K1OczTkcvJeF6ZsA7nhB1SkZ/7XYylsUC9lYCP0j0JJqSfoah1Yo9bBmFoHZpjoiU4e NJkATj9ZxtijOMqWaizinIzkwhkKRls= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760905; a=rsa-sha256; cv=none; b=OfV3IlKQxHybEICwN+0ibXm7c5IBYqaY7M74lFcGjy5MzWtWbYLbtqko/FJtpoNep500x5 T0k5p6qKL9JvCmfDUxzalk0muputV/0fD8wRQxJmtQ69TLmYoMRCqbq1D4W2f6AIPoXICd iCS4oZFcC8N8mz9uq/2qvcAP35w7ZFo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ab4QoyS9; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761032; x=1759297032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RXFigHVvqX66h0CgnEPMdbPUVdZNL13x+vDE/BJrhj8=; b=Ab4QoyS9DT9Q5YqFN2G1PMCR6adPH4hjn+NLZyEakM8fH33rbjxNvLd2 6n3Bt8CgkR4BxnsljeWLeb/TjzybWDvFs/Y6NjjgsMUABqCbjv0jc5NtJ xvUHYlkURHdWNRnsySLnY4ri7Php+GR8p/7YYCH9CUEFJt1upqYLPTYbv l3bwQsUxy408gg+n2N6k/AbqEWENsiVTHSH/E5zUT+RnqfoW6ZJLEYCBE Q9WjyEFgU2apnnwcRlokMOgvXg15aGUDk8/6EwjcZL4710Ie3HQST7V8l ngqeuq6HzuyW8Bkh0ilP5Z6zJv+4cwwZSYehKxnLDUUvs6zEePKiLc6xM w==; X-CSE-ConnectionGUID: eVKhq27bQFqbx4L/avhHxA== X-CSE-MsgGUID: lgFcRjdIS5C4mga3A82AcA== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465094" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465094" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:25 -0700 X-CSE-ConnectionGUID: 8AwPM96ESfa4/3bCeF/HBQ== X-CSE-MsgGUID: +JTWy565Q2O8jcvuOpSgUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205801" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:24 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 3/7] mm: zswap: Rename zswap_pool_get() to zswap_pool_tryget(). Date: Mon, 30 Sep 2024 22:32:18 -0700 Message-Id: <20241001053222.6944-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: 1n3k3b86kgqpdw7ozok3uqdtcz3sbp5a X-Rspamd-Queue-Id: 08E621C0008 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761031-719065 X-HE-Meta: U2FsdGVkX19eviJGc3VyWuZEntXBhaXNDvORYo+mqL89wGw4614pcdCiybraXRsBZrdv4OD25chroaqCBpX8ylApYO6auL6++Cmjxasdi4Na9MfGxRggS6kyKYFL6ydoGdur3whDcmpxeUXTtU9ID98vDGN15KpQmGZGHxFFpX60dHfonxM10oR1L5aTawbX9NVqpluLams/nwES1mwl9eiT+XOkZBh3d4t0CU6FKE+F8Axzeoz6Eevs/eBFPvL9murKn/x8A2NuzlPIfERnQCQZHIqMWuJWWpalUf1/cD0SwSctxenUVLv2bOzo1Bkcof0ohqt7LZuTSI0EnXrQ15Bp6R800Wdb3OkI5Mwdcp+99ghEE+GQGPMqWLvdTFc/MeNSobk+NIei3sknXJMDzfM7cCM8pfXUu418ggujI0CmvyBTsaOvVI0+2WdDsixYhiA6/fOl1Rb1+oGSTVErlzmeE8YjS0HvY6l49gB31t6VqE6vLep9xWgGAmKeT7ZOw1GljtU+dPWcJND7tuz2+GQPO8TJGjBmy5q+qfsOwL9CPKADAkaNDk5jCVKcvI1ShfeAap8M35r8Rnh3E4M6cEmwNMDtovSnD6ywvZdJTZCubmf47Q9eSAkSoDvChyPeZqZTr4XHvRhAxSWxbRxt0ezVnMM0OEt0KFVA23LvmG6RUA03mjvYEksLgszzn8Md+4HDMlEvhBycv70NZVQyJMiPWYPJehgaHOaWRRQZg3QNDwRE9YSQkaFTldRZNbqLFgqIqkfMAiRGJg/4TbhpCp0YPEYZLOw7DcbUqe5jxKLfZXBDSVY/2Rjv17bP6ZfJaSaAPK1wd9dh+FGJzhkDe405wbg39sMp0QeKph+G3E9dtcNtr+DaBCX8a82uQetAXaRmvfKlH4gVMURQjD8DVJ8SNutJTqEbP3V/JOAOQgddlYZ60zHY2N227K4IqgDEgW3N5Kd93BI2RhDh9b4 DC425xHI olVV8UPlRHpKdakjZNffClgVRJaS3Uo76T4Dy7e5rZlS7bdxGnKJI4dinXJNDEVS7+DjEr1Spqdp1g64CYu8WYWb9HSNFzmtTdewyqGpKb5cOb0/4OwCTB0ub/wQ9ghVxn9fk+9xoMTG02Q1NxpCPRYgp4rf32drt4VgcWXN45UdHVZLue7cfY9/bLKStz+Dkc2j8hYJ2PyfOzKUN2L5XZg3Vh4xAnWuq9AL0zmnU91DsOdxtTYaW7h6YCo1cNJN23y296N6sC3X7qxMwPzJgQL/nddUHAxx28a5j/Uer7lnWtv7pCYTs3PTqNv2WdYA/7MmKP9nWB1kPxJkEBqVnfnzXYQ== 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: List-Subscribe: List-Unsubscribe: Modify the name of the existing zswap_pool_get() to zswap_pool_tryget() to be representative of the call it makes to percpu_ref_tryget(). A subsequent patch will introduce a new zswap_pool_get() that calls percpu_ref_get(). The intent behind this change is for higher level zswap API such as zswap_store() to call zswap_pool_tryget() to check upfront if the pool's refcount is "0" (which means it could be getting destroyed) and to handle this as an error condition. zswap_store() would proceed only if zswap_pool_tryget() returns success, and any additional pool refcounts that need to be obtained for compressing sub-pages in a large folio could simply call zswap_pool_get(). Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner Reviewed-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 fd7a8c14457a..0f281e50a034 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -403,7 +403,7 @@ static void __zswap_pool_empty(struct percpu_ref *ref) spin_unlock_bh(&zswap_pools_lock); } -static int __must_check zswap_pool_get(struct zswap_pool *pool) +static int __must_check zswap_pool_tryget(struct zswap_pool *pool) { if (!pool) return 0; @@ -441,7 +441,7 @@ static struct zswap_pool *zswap_pool_current_get(void) rcu_read_lock(); pool = __zswap_pool_current(); - if (!zswap_pool_get(pool)) + if (!zswap_pool_tryget(pool)) pool = NULL; rcu_read_unlock(); @@ -462,7 +462,7 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) if (strcmp(zpool_get_type(pool->zpool), type)) continue; /* if we can't get it, it's about to be destroyed */ - if (!zswap_pool_get(pool)) + if (!zswap_pool_tryget(pool)) continue; return pool; }