From patchwork Sat Sep 28 02:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13814598 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 187CFCF6494 for ; Sat, 28 Sep 2024 02:16:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E4D76B0164; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36E976B0165; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A096B0166; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E7E1C6B0164 for ; Fri, 27 Sep 2024 22:16:30 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 977531C556D for ; Sat, 28 Sep 2024 02:16:30 +0000 (UTC) X-FDA: 82612532940.17.D76A3B7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf28.hostedemail.com (Postfix) with ESMTP id 80C5FC0004 for ; Sat, 28 Sep 2024 02:16:28 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="X/FiYvdA"; spf=pass (imf28.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727489725; a=rsa-sha256; cv=none; b=kF6odiD8vZ/EU5UNm2+gEyvuQDCt1YqlnIjhyQvSGUrt9Dz4s8K8SW9YYQ9+YhThGOUzkA 3gA75jyWhuVj//hqcmZfX1d3zyo9WWLKQPNi9RD7OUyDcwMQt5tygxC+9SCfHXhOfeXpZJ ON76dkLvbZe8aSv10Tj9toN/bCo4jO0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="X/FiYvdA"; spf=pass (imf28.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 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=1727489725; 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=aPn2jJW31uRJ54sAlR1ciuZDqg89v6usD6Z3SIJSJcc=; b=AmmvAEl+QF69WeyTAGeFTEGb6ZXBOB1eQi36opY5QWYXpfA20GGCpzcM/Df/iuHvgQVirv C777ez0LZ1bPPjgB8jOKOHnoRwF7Ty+38mfnltqHvxSTKKkPjqoGLxXfYuIEjiOCT0OUp1 qz3DugXsWildbSWokTBO3ZOVTbFAr/c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489788; x=1759025788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/WDA8F+aPpzJk3yIqLIwiWFiov3kl+WxDzwsHsiRG30=; b=X/FiYvdANKTr9No0aRKU3GVMdV1dq9p8GyUSpvWT/6CG/bnYaeIzR9+U L4DIA4KoCVVwsW3fcA11xuleew461wdMpbF4hiNcl0eRligfgUVvXvs+y svm5snbJudIqRJ8nFJQztSTToW+Rip30VM1aPU/Oa3q3zmWlaqTN+kBBc Ec0M39sB3pa/RbAyamZsRwSksn6JcatM1Q1NSjvD2fKPiuDrLkju534E9 Q7HfNyeKAGiQTsUqkuCT18bzy4t2jN8Q+WV6ZPYWmqoyiWS+heKLYgyu9 0OwWKjJ/SCTMinyP+FZa0BG5U3L2DA/wEYUfjvR7W43doROokgDZl/e6N A==; X-CSE-ConnectionGUID: uGcodCEATsqCKVnzDUuURA== X-CSE-MsgGUID: BUVrkLoNQQSFWQVjChbExA== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526876" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526876" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 19:16:21 -0700 X-CSE-ConnectionGUID: H4RpcxvRRyKCBU3hp5OkjA== X-CSE-MsgGUID: hIO6QzIVRNS6vQR5jZoNyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507119" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa008.jf.intel.com with ESMTP; 27 Sep 2024 19:16:21 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v8 3/8] mm: zswap: Rename zswap_pool_get() to zswap_pool_tryget(). Date: Fri, 27 Sep 2024 19:16:15 -0700 Message-Id: <20240928021620.8369-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240928021620.8369-1-kanchana.p.sridhar@intel.com> References: <20240928021620.8369-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: 54gejinhx46t8yxpbhfn64a7o8h3yyih X-Rspamd-Queue-Id: 80C5FC0004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727489788-425771 X-HE-Meta: U2FsdGVkX19UbjV8TJvrvmeI98t0mdQk2ngxqD0bMKvGUPL7xvCQn0ezDJAFOk5+Z8nPiPFMLGen03PyaDXDmxT0QJXPovAVs0dP5zZVmJ6C67VX6rj/Hv1fI/nR7na5KxZRYzOXiNWrvFfmkjZ69mSOlF+vYmW2ejlMLYZNI9KKdR6mIT3QFDFJlAp1s1PhR/CNW4lUw5DC2DIv/sIFGltHF+bfOALcMc0p7oVW1ec8PFnaEtOrRS27uKZUf44MFOmSI5vYqqaamW8x6qfBX8Bb/30bPmH/PMTEhWiCqYhxc2LzGr7oY5ppZNbUVs5rE/5FVk/5l2sjQNYkm4Xw4heRPQrqFHNRRgTznK15yERu2vKJ97kp6vY8oRUKNJmMCTc7f5gsoNtudpgxmnAHwtIZt6mxqYcJ9clyzBqAuI0awq/qe73zmkYJdEB/v3h+w+31Fd3UG3Ew3nAagFsS8ZGTjZsVSLTw+R4PgRvYXs0nBeJAmdzSNKCUfLU6nrzUltOmkjHcDYyaX6MsdPxmMB3PP2ZZK3vYM82cmDNo27YnvIIKFyZVUbkkGm8hdL+zVA3xNxdsVCKEeRz8lfNLmrVUbKRLVOJACtDCIzdTM5eoJ72Yds0ZmXZ6KoseTqh54fzP24aqTmLypV8+PpMzB3szFS420LpKVPTLqXjTmSPAZ66F+DspbyQb//SHlIGGKhlTB+tXjEjcA+R2rINH2ehmkkK4pSGEIMRUtQNwsUOUrQ7TQnxz98UhjnPpBzLnnI43TQv5uF98qoonKiyjNH31wqvtBlLs0BLbHLiPHeh8uAmU+mNBcIcHdQG653DdYp3AAwtgWLnLkws1hwwnCvLluubcOEzp3VW0n9yNL7eJVbCcNtaIYRqZ9H99HCq+LeG7y0NccbLHlsHs5xpWI3tJCcxB+b+WIxiRAmvCe4un6nJjAAxMVfNcZfZ9NZjrL72wBtyXp+VuFypRg6K afgWTBDe K/GxilT96d7xXtJWkDEF6zLkf7gH+LneB+h+RF+RwvG+pCbd5dZPQaxcVyva+e/EzBfJOItQJqyk1GH1I0Zcrzh5QwKFRfGVjBepsrYNBUzFy5nDIjlx3ha6gUao7BT3gQE4Mf0h6ANlxxd0+zfmCl0skcyW4qin0hXr0W6oi9P2H2DCA2kVZVVjjpWR3I5LN2UZCnz1TDrw5h3zzpbsi+hy7TwVu80gY0+4NrrIG91SD98U= 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; }