From patchwork Sat Sep 28 02:16:13 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: 13814595 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 A16F9CF6494 for ; Sat, 28 Sep 2024 02:16:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0FFA6B0160; Fri, 27 Sep 2024 22:16:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0276B0161; Fri, 27 Sep 2024 22:16:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 987896B0162; Fri, 27 Sep 2024 22:16:26 -0400 (EDT) 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 790196B0160 for ; Fri, 27 Sep 2024 22:16:26 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CD51841703 for ; Sat, 28 Sep 2024 02:16:25 +0000 (UTC) X-FDA: 82612532730.06.924143B Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf28.hostedemail.com (Postfix) with ESMTP id 2907CC0007 for ; Sat, 28 Sep 2024 02:16:22 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HwjscqaT; 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=1727489721; a=rsa-sha256; cv=none; b=KlQHncESCWPxz4pBaiDOuU/2hcHcS7DzvhdXhxvW0sYI3S6ZRkm91L9iEYmLea+0wSEXIk qX6Ex/BaUiIWxrDo/yWYlh2x+4nIkCiK1P97y9wJlwz1RTIHZSAY5XDuU8WTQJU4gSvvmm c1ceWOhNyQ1GBrG9C5N8w3Z5ioWNEBs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HwjscqaT; 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=1727489721; 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=8r/G7MZvN9qcl+J+6KV629nhwO4Bq0Wpq1eduKQLhRA=; b=XMHqmlz9q3ksN1sqrurzQcxuo6BKJoCAL+a6hxGEznSO0bfEL2lM8VHrwaSeSQnO6/a+N5 ZRQBHnfLv13P+CXU5/vEknlIfeRNUyVkujnLUi5SYmjnpOlwp2VFw59Kre2xW3+AKvey/I G9FPTkOEJV29fpTdllGudFHieRnPB40= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489783; x=1759025783; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IbCXass7UYncWYJbpbqgopMF9OvpwOCCnOnS4dLfg9g=; b=HwjscqaTMrfU+u1NQlaj25JpzZgJZiFdABiti8EmjvZWDz7hignPmMp+ RNGwRqRxB03sjjf54EC1Q/qk9Rfjd7hhRbjfPLdV7THQvAWsB24uG4vf9 ZfyYmlZRTe5ZYouzCSys2dOZU0BNR2ikGzuNRMeCS80u2EMMKc7iyXF+a GrVn3MkxnkBrM5oGjpCSiGxrRmBdircpa69pBeN5ev5R6c6bHwPQCF3oB HosrPT7D6yI3m4gaLECnRL1VibbJNAlWThVkeQQx+NAJpff3AtZwpfnnF Kj7/k5DH25WHsNLnpVN9HXcV9kxMy9sEDOblfDqjbMjhvvJmrbmjQ1OxZ Q==; X-CSE-ConnectionGUID: m+IIceFHRvOaW8d2W2S/Qw== X-CSE-MsgGUID: MYckJ+U6Qj2KczXVdh2/jA== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526865" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526865" 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:20 -0700 X-CSE-ConnectionGUID: 7MNZVH/3QTSILL+XMnuEgg== X-CSE-MsgGUID: oL3sghaCRXW2zPSVQBV2gQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507110" 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 1/8] mm: Define obj_cgroup_get() if CONFIG_MEMCG is not defined. Date: Fri, 27 Sep 2024 19:16:13 -0700 Message-Id: <20240928021620.8369-2-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: o356cnpuaofbdmze43migtkzitwj8ccn X-Rspamd-Queue-Id: 2907CC0007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727489782-414771 X-HE-Meta: U2FsdGVkX18NZCMc/6W5zJoX3ymRIEO5e3+LJJNJVNoFj8mQFGCuioROB0ezTdKEwnH22ycW219bZKeZFMCBfZR9TRGKXT3zzxR4AmE4XjRGHEknmbDfY3rdmL2VqJ7T0Ig6Vwg1cZ/xj83A7HGn10U400ko833SdgtzCEWexQsvj1HpQfShYrLSAZGCiGntSgTZ/uT3lkrtjLC5S9EdBAIm5LDGkml/iR44hgJHPcIfLpSvhNLfsjWi60L5fX7+FdSJ6xPkMjTbNb0iVP5+tFh/WpY0uLuZ0A2AGGtiIG92xUxjDU+zwHc1OcVewuNnjhdvmXc1FTi2Wo/u6wgjkiQTys5Ll73pqyin6m7Ovo94bVpdnHlwqBOoSV4ye6qJK90n91iD03w/u9aJnOHGfzQEyrKVv6u8Uxd+J8SibZbNOta4ZB5I4yw/2s2caHen35DyzHKXUUVmZXCIrT2G/vIeKzKgDjIlOcI/Cu6joDR2bj2U5wUdzroyGaeIOjq5k9btaw7njeXTNQqtFkbRHTeys1inlga/opfD4TksDlZC2w8hQ94gNmNY8/ii/SZp6KSS058vA8HzxAXgFyPGiwwwddzyKf0J3NPU85VXFrM8o28g+6Gx09RDLx6FSFtw3/3NOJuPYFaHL30p0Yul+mHp71Q4pxURApbicgekNCU9EjVIyhr1wrGS7W5BlVGljyqzlvH7P6fAqTX0EffkQhHR/I8h7qBKnqS+ETA2/9mAxf7NI3oCfrTmCtST/4LjVEhsDcRh2+VU0ukTUr1zW9nUOMDu1VYhxTgbZ3c9fKDQrcFIV8OEWdV2qSjYFxo4LZSEjGZkw0yxSAl4uo0WpJOyzaICERmQUatXGPJXOR7fACZNK9m5l9tizfyAVU2TmnrCiIUwIzX51ZVr2r0FkfdytdmQhlh2vm9om1Crpa1k3NLOYOtD2t0TSlIQmCqX7XPcQ3YhRvNPXuQCKNA z2QmaP94 xB3pCI1X9U4cMgBrSodJMv3rKJ0dHUqplDkQksTqUReIn8EM64G+Ds0JbZxO8Y1VskhSgZHFhIrMYd2ziutK5eSTS/IbwrMeGuroq63NLaovyLxgKrgdSFQKxUAfj63OjbOkSLUQCZANnSh0puHEFEXr6T6uO4HbXQxmmUlBnF0D6JK8Cg1bVJ6kycoGBVfm1IwqMswvtqvRQ8UUX4uA3KYzZ5PuNJGjnjgiJHwQdD1QNlFIFhHjdo1cngw== 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: This resolves an issue with obj_cgroup_get() not being defined if CONFIG_MEMCG is not defined. Before this patch, we would see build errors if obj_cgroup_get() is called from code that is agnostic of CONFIG_MEMCG. The zswap_store() changes for large folios in subsequent commits will require the use of obj_cgroup_get() in zswap code that falls into this category. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham Reviewed-by: Yosry Ahmed Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 34d2da05f2f1..15c2716f9aa3 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1282,6 +1282,10 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css) return NULL; } +static inline void obj_cgroup_get(struct obj_cgroup *objcg) +{ +} + static inline void obj_cgroup_put(struct obj_cgroup *objcg) { } From patchwork Sat Sep 28 02:16:14 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: 13814596 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 7DE04CF6493 for ; Sat, 28 Sep 2024 02:16:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E440F6B00D8; Fri, 27 Sep 2024 22:16:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCC8C6B013F; Fri, 27 Sep 2024 22:16:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C46F96B0141; Fri, 27 Sep 2024 22:16:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 912D86B00D8 for ; Fri, 27 Sep 2024 22:16:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 26DA3AD017 for ; Sat, 28 Sep 2024 02:16:28 +0000 (UTC) X-FDA: 82612532856.30.86910F2 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf28.hostedemail.com (Postfix) with ESMTP id 0D8FDC0004 for ; Sat, 28 Sep 2024 02:16:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cfcrfeKw; 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=1727489723; a=rsa-sha256; cv=none; b=IP7QcnXI9wX6ps2scltXDHgiVLUz4+j8ZMzFT0JNbipzBYdZGSNyAH+W8e5QTr1uD7YD9W M6ZDG2lm6NFgzGnIoh4xaC0/ZjBcDnwvotPamWyV6Nr+6L8Mm8ohSbJeaAbX3h9F2u3YvP M2bCDY2+hkkPvTdx2Vkd4iVL2JunfCA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cfcrfeKw; 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=1727489723; 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=Xs4zWTZP+u35tfE3962xRZC7zEocizzc7guvsJWQ7y4=; b=UVIa86oKIvM/NHp/dGmAtilblQvCQoQJn6+6bvyE7/KgnHt9DFfh/ZmvPMCb3F8o57GcWW vwGyhaosP3zIm6W1++QllYZQ15Ih7nZdLWGr0tE/f9aYO3frqQwJLkXKidvbMBz7iYX6vX oieJov7UOGUzcSARwsESWpS5xv2dudk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489786; x=1759025786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KQeyC+P/mFswkiAsqAghN2A7u1uS+p3jOQ5BMPTPZHI=; b=cfcrfeKwGalh+ig2b+i7OD6/q3zziH8E3OXZEnqv7bWXWpqNG4U6xp9N 7oa3cPXxdIslgtBe3OC5HB2ZlVvlRUySDbV/8l8PkXfW5S3XS5JWS/oNk VVmSdHN8aNux11Lxo3uu0Sc5YymwOVjB1HybFBbo62UEoIOy9FVKJlFcb oOaI1rzi5mNc2EGr8CaA2NnohuIiwQxmt2ql4VHJNwvAxf7e63tYZabVl yuQRVrvKk30CU/6i1k8pBMxhAMy/Yh9w5IA0BKRkXTSDRzXF5V4obp09M WcUgsbxT34bEWYJk2oVWZaE12Thxh95Dug3Qdcgt5UGV6xQgAS4ezVOLZ A==; X-CSE-ConnectionGUID: 0udpuv7ATVC2BEy9NPOSrA== X-CSE-MsgGUID: 4azd4BHaSB2xnUxP5uNGow== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526871" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526871" 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: n4rSEBVmS3m1aY2A58DlMA== X-CSE-MsgGUID: WdeSY2XgRu25oGb8CioSBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507114" 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 2/8] mm: zswap: Modify zswap_compress() to accept a page instead of a folio. Date: Fri, 27 Sep 2024 19:16:14 -0700 Message-Id: <20240928021620.8369-3-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: itpi8bohcg9oa7edim8gj6j59hfth1ry X-Rspamd-Queue-Id: 0D8FDC0004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727489785-181420 X-HE-Meta: U2FsdGVkX19lqngvmfFaMpqinaInODbchK3xyZoS5BxFL6TMZeN18BqI1CVBNWIZZLJuGkEBnbumZ9Oh20AT8Im3sbX7VFbU2JfXG0JjA1h1QO3MlVR3For4ATCFFUM5iDFyb7IepwYwjST4mK+idlBPxqUWDl5mLtLmukp+Gbmgu/hWgBJhSYw3S1sqcq1yNfQZk8BTwgu0mrpWH3BqzDxgYz3pih7X6xoAvWL1Y6avocOUfs+DCS1La27DC1X33/kOxciWe0Yvi+TM/xZCpZxNYF/HSSIoX1E6p6jR++9noRMLMiNqnouJNrPIUSTwDghH9PyNJgKhrzL8hvsAJSjLGKvHtyTlkV39xZOC1TsMKYVU3bMrbSfLkw0Z5JeWdQsxwpoNyOMuVzeV+npz51ob6EB6I5meFWsgFFJYjlDu0Qe/1u2JWD5MqopDLzf3H1VJZAynkdGgmgRGYAxd6WM9KuxhPfrfqhFk0rD2iYwfPL57jfIjOf2PzaQyRkk38RfK6r5r7Sfxx34o0jeZFpFmm4GD4p0quk1XDGtGrPGvRkNX3qjobGjDOhR3zbVxnC2Ztjuw/S1KwCYMhwn9HJQkG/EqOgS7E0G7FuMWkAI0+Y5KzfowDdhOP18URw1eRJF8+CDAs+dsfBMm8o5RFJHHZlIBMYnNmUCeU3+rcfDdl1IPGLaGCuMD4owO3ggVrUG2Xq0bfYojSY4rnqfkEqV+L/J46O4zLWq0UPfa9WV2EGcxvibmahjC3tintfSfcLEdSE3TWMqm5jvCvOg/NpQIE6U7Fk2iPPOUS5BEd6MmYKNGNt+HXKVIl/dn2yGFQwLFIgeM6Q5WCI2k7sk9+15YDcN3f4VMoxJXZt6ly8A0GGv9Ol7JVj07ja/BOxtBMDttiv4JyGpSuhyUyXroOlXPpFD4YP+c31i698WoEh+xkL7N0WyFQ05kYNMFFu5kWigmnhLsjCfxCGkX4MA N7T1rqvx EMyjEB5ZJFc0Es3J8IH+m7ZtY8c5mbFEBIc4FPzq71cmCO3fApLGE/dlf/jqzQUBaDLAlPQJ5JlduARVG85/7QFzFAIOWX5GeeXpi0ZEp2JC0LkJ69O9zxym5/qFPmExPsrZXZVrl/Kilg3KheuWJSCFD2CKUZgw4U13I3h9s+h318BBWACxYi+L6GHJoQ0/AanM0b3BgL85a3MsFyEFUO8+2vhW+updSpA+ePaJXVcfH7uznJdrYL8OzjrWbF3g7xKfTb3y9TWJjW81t2ckYYbv0xw== 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: For zswap_store() to be able to store a large folio by compressing it one page at a time, zswap_compress() needs to accept a page as input. This will allow us to iterate through each page in the folio in zswap_store(), compress it and store it in the zpool. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner --- mm/zswap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index efad4e941e44..fd7a8c14457a 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -875,7 +875,7 @@ static int zswap_cpu_comp_dead(unsigned int cpu, struct hlist_node *node) return 0; } -static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) +static bool zswap_compress(struct page *page, struct zswap_entry *entry) { struct crypto_acomp_ctx *acomp_ctx; struct scatterlist input, output; @@ -893,7 +893,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) dst = acomp_ctx->buffer; sg_init_table(&input, 1); - sg_set_folio(&input, folio, PAGE_SIZE, 0); + sg_set_page(&input, page, PAGE_SIZE, 0); /* * We need PAGE_SIZE * 2 here since there maybe over-compression case, @@ -1456,7 +1456,7 @@ bool zswap_store(struct folio *folio) mem_cgroup_put(memcg); } - if (!zswap_compress(folio, entry)) + if (!zswap_compress(&folio->page, entry)) goto put_pool; entry->swpentry = swp; 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; } From patchwork Sat Sep 28 02:16:16 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: 13814599 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 01F18CF6493 for ; Sat, 28 Sep 2024 02:16:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB1736B0165; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B351F6B0166; 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 9882A6B0167; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7558E6B0165 for ; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2878D816D9 for ; Sat, 28 Sep 2024 02:16:31 +0000 (UTC) X-FDA: 82612532982.14.839B60A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf04.hostedemail.com (Postfix) with ESMTP id 18C3140002 for ; Sat, 28 Sep 2024 02:16:28 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Em1i62wD; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727489689; a=rsa-sha256; cv=none; b=hRE2z3+/w2mHA80SL9QYyc953CjWbbZbHCY/T6I1vIC/SJPpsJzVIAvyX5DhnZ2iWOfuu9 hTfzO4qBuiXTwXhYqGdnDLvebgYglwgWSbsiS/84UVAWWLH9Wrg6OHhWi6/NdsYnvGAZIq gpEo3fxSz2WsHQ+CM6JCrIZ8/brxBmM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Em1i62wD; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727489689; 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=tSkTkvc4RK/mABhfoBCo5mPE67SOGg9cBUxR5H6C1eE=; b=GqPC2ojfU4ltswR7EB6SrqpFUGgcglomTtNrpFbqQ+G1Fg0jzDLpWq+6YCBc1CDSvjBXh+ X6zcg/Qtf6vTcI8DlQZxaEqd5WJRoFnS7ENh+KN34+zWNGlwHHs8HPTE0ip82kYQ3ZvsNI UdeUK+bnGObBqfWN8WIGptBAlDdRRGc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489789; x=1759025789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QHKnkJGGdaPi/P8pWr1YVsvSRJmDf6+suHy+r3IyAYQ=; b=Em1i62wDc1UmSwrxuKE8zqHbXvFipfr3H26GbhjHnYj7t1yDbWJn5clW unCEPM6iLwomcMF9qTLI+TqwV88nVfCU+CmPp018qXUlFNfJ4q0CIMhum 1pWcu4PM8dHSaA8tMULe0sUU0euSbplKqTJXFFKR1SmDVvynQsQ4EGUCy CZpa91619oX7FNHXz+ImkDZzTuUdRimwG9k4PkGFr0anfcQt7FviPR3gQ PNN+OXHz7/JUmeQhhGZvlS1eEGlyUv7OcuaBeHDpZJDXZlIaGSWlvG5SS Dh/JRUYmKABTLkywggT0616274bMudvAoL1W/7TS3leDFASV6yQlIPB3H g==; X-CSE-ConnectionGUID: V6SC6ZM6R4qTcNRHed9bsQ== X-CSE-MsgGUID: 4n49zgAOSsSYTpdcTxF+Kg== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526886" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526886" 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: NLInsGB0QhKm+ll4bJ7x3w== X-CSE-MsgGUID: VaCbO+f5T0Sm7iNs63SZkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507123" 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 4/8] mm: Provide a new count_objcg_events() API for batch event updates. Date: Fri, 27 Sep 2024 19:16:16 -0700 Message-Id: <20240928021620.8369-5-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 18C3140002 X-Stat-Signature: ns3wd16n1g9aknzcsmqtftmxgrza9n56 X-Rspam-User: X-HE-Tag: 1727489788-116013 X-HE-Meta: U2FsdGVkX1/o3Xq6bV/V0KWIsaH71Gtp/Wxu0R6OdnhJiq3Zwkov0UOa29Vo49DmTvCfEgDqWNt1JxC8KNQODt+PbHA5CDnDEIFie5okyf6y0u340Qz5Dq75Ynb8SMxaDAhh8R6pUtmKXJbKrqkKMAookgJFXSKsenpA1oAM4AyjZIMG3/URP72jkp+C9B28uCsilvwfQKDLsvuA7qj0Fii+FM25+f69LdzodcMakYzK39DyNNXVZvdp+SWjSgMX44PlGWR4eMQBgd+MOjDy2rb4jIFuZOSCRupw0A8p+u7WToTMlFK6fPobSqccKDtljTHbP/RVwg8Cpaics3zedI4z30GTrBT0SlpucI1S04PIXPZwRGnpvY9T4w9D5eoKm62Slwmvh01FM+kPRopRFstNA2HmdysvNGLlte9dugzgodG38nxGiARn5HGhNiQ6Jql/oVbHd6npnsgxEROXD2a/ESJ5FvlF9YQpGpkwqUz1nnbVNzeYwQV7XzBjZm7A/iZCo9Bv2Vb45Z9ZJvtA07zp+hmoYJnrDSxnl51ICc1U8lCWGye7U54oDLcrSEfU7sChcmYJ/wPC7nd65MjGowxD4rEVxCCQ/cxVoPOrkfgsJFbCC6wRL2KBX0m+dAfVZlCb8lzATgpMyXYb3i10CMtVC0aKN+G/pNqSBZf3qxao7S1qBzGUYlZ8Vx+5CEqvmVHd3WqFDDpjVc0zV1ALQsE1XtOoP7w0jd5G/6TjObpdtQ0vYi6wOkuC5wi9gxC/fb0vZX9Zm2TLd374gr0WJ5+6aSYlWQkD9XoyE6vRYuvKBXCgOYXYVeMEwyqHwCn20zlzzc4nXM3lwe6OcCQ/n5/yIOO07+wZVbMgchYFTwTMI32A+hTyEUsKfplWay+g20X02F1n+fdbYC3Qk9xIUoM4yevwscd2vX2AWXrKOcijqhM6t0Yz42D3goOKDB2NmSIYy95yXlSJRYnFwo/ W8OKn3Fj lIkj94rDyAQrk+CLHer6I30U+tZ2IlaJThZ+eLZ7qBIVJGg1dJHwuUqIvpwTZ2xQy5Bp2WN45a+vXxzFDI0f4pU1yt11yYMcDVXd/eZk/lDK3a6eCuq1GEk4kd9kRSaZlhvMFC0nPs/rb71lZCNiNQcBtxiN15lbXQLXUuFyEXEREYiLxzOtlUJZ8pIbn5c6h36U4MWp6efdWI8Jsv79fMxh+ItLPnl69wjvI 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: With the introduction of zswap_store() swapping out large folios, we need to efficiently update the objcg's memcg events once per successfully stored folio. For instance, the 'ZSWPOUT' event needs to be incremented by folio_nr_pages(). Signed-off-by: Kanchana P Sridhar --- include/linux/memcontrol.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 15c2716f9aa3..f47fd00c5eea 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1778,6 +1778,21 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, rcu_read_unlock(); } +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) +{ + struct mem_cgroup *memcg; + + if (!memcg_kmem_online()) + return; + + rcu_read_lock(); + memcg = obj_cgroup_memcg(objcg); + count_memcg_events(memcg, idx, count); + rcu_read_unlock(); +} + #else static inline bool mem_cgroup_kmem_disabled(void) { @@ -1834,6 +1849,11 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, { } +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) +{ +} #endif /* CONFIG_MEMCG */ #if defined(CONFIG_MEMCG) && defined(CONFIG_ZSWAP) From patchwork Sat Sep 28 02:16:17 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: 13814600 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 5ADB9CF6493 for ; Sat, 28 Sep 2024 02:16:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 370226B0166; Fri, 27 Sep 2024 22:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A96A6B0167; Fri, 27 Sep 2024 22:16:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4D36B0168; Fri, 27 Sep 2024 22:16:31 -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 C25E46B0167 for ; Fri, 27 Sep 2024 22:16:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6293C817F8 for ; Sat, 28 Sep 2024 02:16:31 +0000 (UTC) X-FDA: 82612532982.23.4239D6C Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf30.hostedemail.com (Postfix) with ESMTP id 364B780008 for ; Sat, 28 Sep 2024 02:16:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=YxgLkKUg; spf=pass (imf30.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=1727489626; 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=dt+cTcWb+BAD2IHzMoYkxqsN3zKB5Ajsbz/YRJhcXic=; b=TQIg+pSAQHZHbr7QSab+bFPqb2vw4KyYS4QNaWkzOw2v8881n/1sUvKze6qdUd0UHfgCQx C3VKwiijntkOytHsLD6ZUCvEV0dvS0PW0k+hklOxCwG3vIQREYQcBHTstyJpe6m5stmPka D5XvAXNFRsqUTRSQnaqyGRkqohG0xeY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=YxgLkKUg; spf=pass (imf30.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=1727489626; a=rsa-sha256; cv=none; b=FZw/omjLtGXSFJyfrM5GU9XEY40vbN0o8xwYCHv/rgVBTHAL+Oby9vvpwC8cP80Txz7GIX 9fs9dG0DRU1+tdmMOOV8dOxpSlBfossJRUw8AU+fZxSRqcDpZ4g999yq2S9y6x26T/7hv7 t9fjcxdU/ycc5aT24kafgysa86D1ZnY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489789; x=1759025789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7AZStRs4Lxum8UQacAgZWzRz8QxxXzYiQ2pEjwK5j3g=; b=YxgLkKUgNuaR4dNtSWwzHLAO5pmYc/GDh6znyQV4YmR2o7XEPRmvJFcZ PkyauOTGXSppZu0hmisQUUitZ9x9H/rKkuPzb4maJ+CSICJy99GQpkgNK LLCoyxaQAdOagEaoddEyd/Pr1V4QduNtGvAVehM7LhlgLNZvyxorffHXo mN8vww+yMQyiEAFt+b59TY2UZ6fNgORBzmoJJhhkw0yUp4DhAZPF/AyBC NlVlYse0/n3dDi2VcfDYMiOmOEvc1hcPzLdRpZ5p2KDWAGFI6GsSB7+N1 7sfL0acWj9vFQ8SywSpTVe9B7aYzlN4mXI7SmZ322A5xknragVScs+3LO w==; X-CSE-ConnectionGUID: VcVZkhMdSEC4XbSmIVUMCg== X-CSE-MsgGUID: hDzKICUQTLqMfR1TyHMWMw== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526895" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526895" 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: mDT8is80RWObT6fFc36rng== X-CSE-MsgGUID: ugrimwV2TuCBBwZcCwdPzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507127" 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 5/8] mm: zswap: Modify zswap_stored_pages to be atomic_long_t. Date: Fri, 27 Sep 2024 19:16:17 -0700 Message-Id: <20240928021620.8369-6-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 364B780008 X-Stat-Signature: qr1zyinhxynezr35yq8ajwmyt1thznqc X-Rspam-User: X-HE-Tag: 1727489789-89113 X-HE-Meta: U2FsdGVkX1/kyV2P7N8qbDjok72810GMrEeZJhWVjeUJD62eHeojLvLWGtzYD0h7YFiHa/8IJKlZxdZz4WPP2BrQqi8HNVHO48MLGaG5Na1BXmabZcrbx9UGUaKCsLWxzkzzU3csZFbXDD71g7liRKVxR5vdmZxcqhBvbunTPFNI4LNz0NahiaojtCV+n+hD0ic683FpaNnR4sniA/bDfpodSToeXpPljs1oXiStggkzTfyg4BmARZLick0VDDWmuJUA8Do2d5DFH35OGrRWU8gz4qt9pfXBGeDH5EEEXELWMm898HWYdgpXVTrT6srEbL85yzxqHfBj1pWY9aqTKtJYweLi8bplDkrZ2yiy+TnZHhMib+wP9jxTkAqhFAqyise2RNc0c0vvYpkstcjG8uDqJ9ylVxWRhnXLKMpmgbPSbAclzRjgODLikvdkEW6UChklHEUzn4wryEiusZ5M/4KDT/ghyjFVKnGFd6b3tnOpQ0lg0a8VQUi4IY79xa8yXp3syRTB3yIHxOZt4/zC8j9ZxGVFgOgu02Udmk+epxW/JBKk6wPivGMGtQ2rL439RrwiLRNeubQYCngtEb8DZNz1sOS4K9P57YCO1mzQ/TsX+S/36Cp4PMF76cvSwRSojn1TJTBpwOVfWWfnpr4vERemwN0FZSqRlxHvC6rsUNHl0BznGdS67GywfFizrUl1dBZHvh9nd660js5cfNBLGyPksM7VnxI+we2PgmPnNn9NJ2ztnwQdCXFvagd/Ipccv3lNHuVnM39HtOJgPVP3DXV6dzIkfn4rJU+9z6/Khc9eLOEy3b4enp5IgWDTNLL3VjdVaSf0ay1LQwMuHUo26Ks3sNt00mGbjaTrOFrDuRdCEoD6iICM8p4GtEzFTumQP2TzqExt6bmKTGq9g0vh0RkqsnWuutAv67vjVIckdOci25ydLYqytRnwmokLEzM350QPl3jYoY/SkZfebEu bdm31wHI 93u4HIgUsdbGoJ1Y4DrDvFT+Fw5A4gvg85w3trfjrT9EHhZhKy4rMPgpGGubyRA/6GOVdUjrjzJ3vQDqZZAmwoyYGTUTwP77Rs6hFNneo3qYcnLI5DIiL9p/Ax7Of6IDiMS9RJWoIUrX78Mxk8lGSo9Oxf6LeQnqBE95jHXKk7e8qIhdx3SRPhwYV/uwjMmrTDZBPW2T/y7/arB6pyW/QKBg0Nip9HcTrZfOM95BuB+/EWtk= 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: For zswap_store() to support large folios, we need to be able to do a batch update of zswap_stored_pages upon successful store of all pages in the folio. For this, we need to add folio_nr_pages(), which returns a long, to zswap_stored_pages. Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Acked-by: Johannes Weiner Reviewed-by: Nhat Pham --- fs/proc/meminfo.c | 2 +- include/linux/zswap.h | 2 +- mm/zswap.c | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 245171d9164b..8ba9b1472390 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -91,7 +91,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) #ifdef CONFIG_ZSWAP show_val_kb(m, "Zswap: ", zswap_total_pages()); seq_printf(m, "Zswapped: %8lu kB\n", - (unsigned long)atomic_read(&zswap_stored_pages) << + (unsigned long)atomic_long_read(&zswap_stored_pages) << (PAGE_SHIFT - 10)); #endif show_val_kb(m, "Dirty: ", diff --git a/include/linux/zswap.h b/include/linux/zswap.h index 9cd1beef0654..d961ead91bf1 100644 --- a/include/linux/zswap.h +++ b/include/linux/zswap.h @@ -7,7 +7,7 @@ struct lruvec; -extern atomic_t zswap_stored_pages; +extern atomic_long_t zswap_stored_pages; #ifdef CONFIG_ZSWAP diff --git a/mm/zswap.c b/mm/zswap.c index 0f281e50a034..43e4e216db41 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -43,7 +43,7 @@ * statistics **********************************/ /* The number of compressed pages currently stored in zswap */ -atomic_t zswap_stored_pages = ATOMIC_INIT(0); +atomic_long_t zswap_stored_pages = ATOMIC_INIT(0); /* * The statistics below are not protected from concurrent access for @@ -802,7 +802,7 @@ static void zswap_entry_free(struct zswap_entry *entry) obj_cgroup_put(entry->objcg); } zswap_entry_cache_free(entry); - atomic_dec(&zswap_stored_pages); + atomic_long_dec(&zswap_stored_pages); } /********************************* @@ -1232,7 +1232,7 @@ static unsigned long zswap_shrinker_count(struct shrinker *shrinker, nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED); } else { nr_backing = zswap_total_pages(); - nr_stored = atomic_read(&zswap_stored_pages); + nr_stored = atomic_long_read(&zswap_stored_pages); } if (!nr_stored) @@ -1501,7 +1501,7 @@ bool zswap_store(struct folio *folio) } /* update stats */ - atomic_inc(&zswap_stored_pages); + atomic_long_inc(&zswap_stored_pages); count_vm_event(ZSWPOUT); return true; @@ -1650,6 +1650,13 @@ static int debugfs_get_total_size(void *data, u64 *val) } DEFINE_DEBUGFS_ATTRIBUTE(total_size_fops, debugfs_get_total_size, NULL, "%llu\n"); +static int debugfs_get_stored_pages(void *data, u64 *val) +{ + *val = atomic_long_read(&zswap_stored_pages); + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(stored_pages_fops, debugfs_get_stored_pages, NULL, "%llu\n"); + static int zswap_debugfs_init(void) { if (!debugfs_initialized()) @@ -1673,8 +1680,8 @@ static int zswap_debugfs_init(void) zswap_debugfs_root, &zswap_written_back_pages); debugfs_create_file("pool_total_size", 0444, zswap_debugfs_root, NULL, &total_size_fops); - debugfs_create_atomic_t("stored_pages", 0444, - zswap_debugfs_root, &zswap_stored_pages); + debugfs_create_file("stored_pages", 0444, + zswap_debugfs_root, NULL, &stored_pages_fops); return 0; } From patchwork Sat Sep 28 02:16:18 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: 13814601 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 D7C5ECF6493 for ; Sat, 28 Sep 2024 02:16:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B5E76B0168; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7642D6B0169; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 544096B016A; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2F6BE6B0168 for ; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D80DD41703 for ; Sat, 28 Sep 2024 02:16:32 +0000 (UTC) X-FDA: 82612533024.23.AD082D4 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf28.hostedemail.com (Postfix) with ESMTP id B91A1C0004 for ; Sat, 28 Sep 2024 02:16:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=D03aT4iC; 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=1727489728; a=rsa-sha256; cv=none; b=Ggijlz4IIqgLFOt1XXRfH+WWgTI8YrEEI+zyi7PDv2XmEcrnUq60EDFTsBYoEaLqMMNeyY Kd2pHiFEnLsMQxU2XPQp2a6mIItAZijk9Potb4lrA00tc9oPuiT3AqEKtAeCDMPHWG6S55 Wzgmus71fyua47IbmSqinmoW7T5GzNY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=D03aT4iC; 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=1727489728; 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=2Ci/8+s23r9WnT8yoxOhHXnQj61WPlo+0s62A2xF7Go=; b=Aa3j0vPZ1Lt2/iyyNSVtawFObftzILuCQ+b3gkCx/2ax3blqPqQapSiRpra0JcCJnkarUa bxHgxyCFXTPdQTQeNk1Wcd9uEKpPJg2dTd7ebHsPsqGO3tXYfjkdb9eI2xAec9g+fkGNed qJDx5AIv1H7UkVaZaxr2/n7iJyfjfkk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489790; x=1759025790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kXk6Ax7R4cbxIDcNNxyrrGN3X0TYFfUEAYtvllXSW9Y=; b=D03aT4iCAhurrTBpRqOzMaoO1R7W+ucGAeeREUxTrXSl6IaiwaDWc/12 VF4/6YF3dcb23LCSIBvOCekOv8eCH9Z4DX40to/rqQ8bv9DU6aCZAGC/l hWVcRm3X1plTGI89zpi0eIJfybRM6Ut9awQo5ByHhzZ+kWMwInwsOm9cL z3Pk8udw9FnsHbIawjv8agqXdWrX2pN1/th8Lw+x7QgFiKunXpJlsT4VR TENVQB4GubaRiM/DpJxqATUMZNQYng0eyUpqqTcnu5QpE9V681WfSGxTt vL+1jiy57aqq/VdDw62IVWAcA8K3G568OFmBeBYEvMbXT6HFSVtio+Jng Q==; X-CSE-ConnectionGUID: Afnv0AbyRnikMvOTiti7pg== X-CSE-MsgGUID: ctK8nAMnSmqJ0Gn8qQ17NA== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526904" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526904" 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: 4AIpJFJWT46k/1SWK+nriw== X-CSE-MsgGUID: JE3lrKiySlCTp6DoWlx+Ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507130" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa008.jf.intel.com with ESMTP; 27 Sep 2024 19:16:22 -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 6/8] mm: zswap: Support large folios in zswap_store(). Date: Fri, 27 Sep 2024 19:16:18 -0700 Message-Id: <20240928021620.8369-7-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: pusu8yqumzritsznzmoj6k8ki8q3oboo X-Rspamd-Queue-Id: B91A1C0004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727489790-231504 X-HE-Meta: U2FsdGVkX1+Xcu5kvmoI41V2rQRq0LNYm/nd0dr4GnT3B/FGdFbZft8bJ2URDMgjlFo3PRcnTeG0ZsiK7uRcdv6zyesSqJ0v3PxXKXx82p0MDkJoz9g0spj6jyBX3orjingg8snvjOWWzaTQRqTQEMJTEO2Ve6Iw5Jo7xCoRlL7T9Vqjt/XOEb3L+Bx+OX2/3G3JT9Moh23MDoFxpFSWRVzdzU0KE/iwVAt6jqtf/tSyCkBiI7BU5F7oeFcG5SDSw6lZC+SjFpVlGQpA7S7/rS+gMzXOo2dSUUigT+KwaFUzKoQWYZThmJLbbeVoQLJTOrGSM6Qyf6zk3e1D+XO9KjwfzJfwDmfzARpdG86LVr2M6mNvByXg+Oo7z5stiPzJygnTCqsxyocLDtCbigDtxOKrpzNqr0mE3dD4VCLPbygb7Hpgde9nxZKKnz2q2U5atdiZ0IrwjKUGGJwhOhtjHay6r8+yeTWwPFvBswj35iNARS5fxbGYAzmxXLC0IhfZmHqKB6Md90Eq0B2kRDpqrriEuYGynN6jL74MWrsYKFnjusFGbfN0QgoWSalvXxFhcv5wnQz9FyntaRpodqmUOoahkWit/DHHrrtO5iD5Sdm9QhH55160oH9F97TeKRkwd9AbdHsp0hj8rqeLymHCDVw+oY9ehgLOKlRBCDaMNJwEQA4oCxFi0D/gqoIXgOt7HU+YIzYb+vfynyu9fTkVwwcJFsBBk76b43eHvWx9Zg4F84nFgN9wCEdLFf1m4NfH127Y3Sd/Lg0SoNKerfoEW+0qc2tppWDCsY0zjpNbXgeGs7IC34ponJPkw4gflBwpQ3S4/TAfP5d5KNXkw5JyQxYjvqXVTChxmyhHJUFdqgqzLloE6bwUOIKndNdPLS+BIewC5N8RK8CUtltDbAR9RmpNG543r4WXtPe2gs7utd8qcpgSqLyr1TBHu1y+jBs684GAoCrNstUBu/sPGmK TTbIhYn6 0dE+eskJVZzHlziGItsKzoSYIQyT2jBNrJZrJmhzY/zY4WhAD6q3rScngpDw/jK/a7BFjWW/LSsDzKZUKQw+Qn/Mkpo2ghhSlmb+RDA/Gtw2I5gJwCo/swybszvlKjVrKbuIb0Uvj116iliod2NkHGLN/LxYtiKl4V5XeqALPe22FoTmgFSP2xUsJwUstJJTfLxUHvZ5kSRJNbrwVgM8emsmmeALR2gkk4gnv0cU3g6nXxlY2J+5qHMZC/e2DYI2lTWFN/y4wq9MpQsqMQa7NBViR5YUPqTxI4skubptSzd6nYYbaipeHl7kuRA== 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: zswap_store() will store large folios by compressing them page by page. This patch provides a sequential implementation of storing a large folio in zswap_store() by iterating through each page in the folio to compress and store it in the zswap zpool. Towards this goal, zswap_compress() is modified to take a page instead of a folio as input. Each page's swap offset is stored as a separate zswap entry. We check the cgroup zswap limit and the zpool utilization against the zswap max/accept_threshold limits once, at the beginning of zswap_store. We also obtain a percpu_ref_tryget() reference to the current zswap_pool at the start of zswap_store to prevent it from being deleted while the folio is being stored. If these one-time checks pass, we compress the sub-pages of the folio, while maintaining a running count of compressed bytes for all the folio's sub-pages. If all pages are successfully compressed and stored, we do the cgroup zswap charging with the total compressed bytes, and batch update the zswap_stored_pages atomic/zswpout event stats with folio_nr_pages() once, before returning from zswap_store. The patch adds a new zswap_pool_get() function that is called in the sub-page level "zswap_store_page()" function. If an error is encountered during the store of any page in the folio, all pages in that folio currently stored in zswap will be invalidated. Thus, a folio is either entirely stored in zswap, or entirely not stored in zswap. This patch forms the basis for building compress batching of pages in a large folio in zswap_store by compressing up to say, 8 pages of the folio in parallel in hardware using the Intel In-Memory Analytics Accelerator (Intel IAA). This change reuses and adapts the functionality in Ryan Roberts' RFC patch [1]: "[RFC,v1] mm: zswap: Store large folios without splitting" [1] https://lore.kernel.org/linux-mm/20231019110543.3284654-1-ryan.roberts@arm.com/T/#u Also, addressed some of the RFC comments from the discussion in [1]. Co-developed-by: Ryan Roberts Signed-off-by: Signed-off-by: Kanchana P Sridhar --- mm/zswap.c | 227 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 165 insertions(+), 62 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 43e4e216db41..b8395ddf7b7c 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -411,6 +411,16 @@ static int __must_check zswap_pool_tryget(struct zswap_pool *pool) return percpu_ref_tryget(&pool->ref); } +/* + * Note: zswap_pool_get() should only be called after zswap_pool_tryget() + * returns success. zswap_pool_tryget() returns success only if the "pool" is + * non-NULL and the "&pool->ref" is non-0. + */ +static void zswap_pool_get(struct zswap_pool *pool) +{ + percpu_ref_get(&pool->ref); +} + static void zswap_pool_put(struct zswap_pool *pool) { percpu_ref_put(&pool->ref); @@ -1402,38 +1412,35 @@ static void shrink_worker(struct work_struct *w) /********************************* * main API **********************************/ -bool zswap_store(struct folio *folio) + +/* + * Stores the page at specified "index" in a folio. + * + * @folio: The folio to store in zswap. + * @index: Index into the page in the folio that this function will store. + * @objcg: The folio's objcg. + * @pool: The zswap_pool to store the compressed data for the page. + * The caller should have obtained a reference to a valid + * zswap_pool by calling zswap_pool_tryget(), to pass as this + * argument. + * @compressed_bytes: The compressed entry->length value is added + * to this, so that the caller can get the total + * compressed lengths of all sub-pages in a folio. + */ +static bool zswap_store_page(struct folio *folio, long index, + struct obj_cgroup *objcg, + struct zswap_pool *pool, + size_t *compressed_bytes) { + struct page *page = folio_page(folio, index); swp_entry_t swp = folio->swap; - pgoff_t offset = swp_offset(swp); struct xarray *tree = swap_zswap_tree(swp); + pgoff_t offset = swp_offset(swp) + index; struct zswap_entry *entry, *old; - struct obj_cgroup *objcg = NULL; - struct mem_cgroup *memcg = NULL; - - VM_WARN_ON_ONCE(!folio_test_locked(folio)); - VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); + int type = swp_type(swp); - /* Large folios aren't supported */ - if (folio_test_large(folio)) - return false; - - if (!zswap_enabled) - goto check_old; - - /* Check cgroup limits */ - objcg = get_obj_cgroup_from_folio(folio); - if (objcg && !obj_cgroup_may_zswap(objcg)) { - memcg = get_mem_cgroup_from_objcg(objcg); - if (shrink_memcg(memcg)) { - mem_cgroup_put(memcg); - goto reject; - } - mem_cgroup_put(memcg); - } - - if (zswap_check_limits()) - goto reject; + if (objcg) + obj_cgroup_get(objcg); /* allocate entry */ entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); @@ -1442,24 +1449,21 @@ bool zswap_store(struct folio *folio) goto reject; } - /* if entry is successfully added, it keeps the reference */ - entry->pool = zswap_pool_current_get(); - if (!entry->pool) - goto freepage; + /* + * We get here only after the call to zswap_pool_tryget() in the + * caller, zswap_store(), has returned success. Hence it is safe + * to call zswap_pool_get(). + * + * if entry is successfully added, it keeps the reference + */ + zswap_pool_get(pool); - if (objcg) { - memcg = get_mem_cgroup_from_objcg(objcg); - if (memcg_list_lru_alloc(memcg, &zswap_list_lru, GFP_KERNEL)) { - mem_cgroup_put(memcg); - goto put_pool; - } - mem_cgroup_put(memcg); - } + entry->pool = pool; - if (!zswap_compress(&folio->page, entry)) + if (!zswap_compress(page, entry)) goto put_pool; - entry->swpentry = swp; + entry->swpentry = swp_entry(type, offset); entry->objcg = objcg; entry->referenced = true; @@ -1480,11 +1484,6 @@ bool zswap_store(struct folio *folio) if (old) zswap_entry_free(old); - if (objcg) { - obj_cgroup_charge_zswap(objcg, entry->length); - count_objcg_event(objcg, ZSWPOUT); - } - /* * We finish initializing the entry while it's already in xarray. * This is safe because: @@ -1496,36 +1495,140 @@ bool zswap_store(struct folio *folio) * an incoherent entry. */ if (entry->length) { + *compressed_bytes += entry->length; INIT_LIST_HEAD(&entry->lru); zswap_lru_add(&zswap_list_lru, entry); } - /* update stats */ - atomic_long_inc(&zswap_stored_pages); - count_vm_event(ZSWPOUT); - return true; store_failed: zpool_free(entry->pool->zpool, entry->handle); put_pool: - zswap_pool_put(entry->pool); -freepage: + zswap_pool_put(pool); zswap_entry_cache_free(entry); reject: obj_cgroup_put(objcg); - if (zswap_pool_reached_full) - queue_work(shrink_wq, &zswap_shrink_work); -check_old: + return false; +} + +bool zswap_store(struct folio *folio) +{ + long nr_pages = folio_nr_pages(folio); + swp_entry_t swp = folio->swap; + struct xarray *tree = swap_zswap_tree(swp); + pgoff_t offset = swp_offset(swp); + struct obj_cgroup *objcg = NULL; + struct mem_cgroup *memcg = NULL; + struct zswap_pool *pool; + size_t compressed_bytes = 0; + bool ret = false; + long index; + + VM_WARN_ON_ONCE(!folio_test_locked(folio)); + VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); + + if (!zswap_enabled) + goto reject; + /* - * If the zswap store fails or zswap is disabled, we must invalidate the - * possibly stale entry which was previously stored at this offset. - * Otherwise, writeback could overwrite the new data in the swapfile. + * Check cgroup zswap limits: + * + * The cgroup zswap limit check is done once at the beginning of + * zswap_store(). The cgroup charging is done once, at the end + * of a successful folio store. What this means is, if the cgroup + * was within the zswap_max limit at the beginning of a large folio + * store, it could go over the limit by at most (HPAGE_PMD_NR - 1) + * pages. */ - entry = xa_erase(tree, offset); - if (entry) - zswap_entry_free(entry); - return false; + objcg = get_obj_cgroup_from_folio(folio); + if (objcg && !obj_cgroup_may_zswap(objcg)) { + memcg = get_mem_cgroup_from_objcg(objcg); + if (shrink_memcg(memcg)) { + mem_cgroup_put(memcg); + goto put_objcg; + } + mem_cgroup_put(memcg); + } + + /* + * Check zpool utilization against zswap limits: + * + * The zswap zpool utilization is also checked against the limits + * just once, at the start of zswap_store(). If the check passes, + * any breaches of the limits set by zswap_max_pages() or + * zswap_accept_thr_pages() that may happen while storing this + * folio, will only be detected during the next call to + * zswap_store() by any process. + */ + if (zswap_check_limits()) + goto put_objcg; + + pool = zswap_pool_current_get(); + if (!pool) + goto put_objcg; + + if (objcg) { + memcg = get_mem_cgroup_from_objcg(objcg); + if (memcg_list_lru_alloc(memcg, &zswap_list_lru, GFP_KERNEL)) { + mem_cgroup_put(memcg); + goto put_pool; + } + mem_cgroup_put(memcg); + } + + /* + * Store each page of the folio as a separate entry. If we fail to + * store a page, unwind by deleting all the pages for this folio + * currently in zswap. + */ + for (index = 0; index < nr_pages; ++index) { + if (!zswap_store_page(folio, index, objcg, pool, &compressed_bytes)) + goto put_pool; + } + + /* + * All pages in the folio have been successfully stored. + * Batch update the cgroup zswap charging, zswap_stored_page atomic, + * and ZSWPOUT event stats. + */ + if (objcg) { + obj_cgroup_charge_zswap(objcg, compressed_bytes); + count_objcg_events(objcg, ZSWPOUT, nr_pages); + } + + /* update stats */ + atomic_long_add(nr_pages, &zswap_stored_pages); + count_vm_events(ZSWPOUT, nr_pages); + + ret = true; + +put_pool: + zswap_pool_put(pool); +put_objcg: + obj_cgroup_put(objcg); +reject: + /* + * If the zswap store fails or zswap is disabled, we must invalidate + * the possibly stale entries which were previously stored at the + * offsets corresponding to each page of the folio. Otherwise, + * writeback could overwrite the new data in the swapfile. + */ + if (!ret) { + struct zswap_entry *entry; + long i; + + for (i = 0; i < nr_pages; ++i) { + entry = xa_erase(tree, offset + i); + if (entry) + zswap_entry_free(entry); + } + + if (zswap_pool_reached_full) + queue_work(shrink_wq, &zswap_shrink_work); + } + + return ret; } bool zswap_load(struct folio *folio) From patchwork Sat Sep 28 02:16:19 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: 13814602 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 C4CFECF6494 for ; Sat, 28 Sep 2024 02:16:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 291BB6B0169; Fri, 27 Sep 2024 22:16:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EAC76B016A; Fri, 27 Sep 2024 22:16:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1C316B016C; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BA8326B0169 for ; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 70D6916103E for ; Sat, 28 Sep 2024 02:16:33 +0000 (UTC) X-FDA: 82612533066.02.07047AD Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf04.hostedemail.com (Postfix) with ESMTP id 4854740002 for ; Sat, 28 Sep 2024 02:16:31 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=KbfWfQKM; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727489691; a=rsa-sha256; cv=none; b=jTk0UfVuORSOPZCfo46e62i5H2UYI5l5k23ossm8V7p3zxE2M3JMTUTXKQ9uujqug87a79 aLO/QxVPkHIqHLYma8/0yDr6AjQgzW4n6NIgSlHrLtcN9numvEjhgcgblvPhPhd/PYv1cv jO4bcg1hQ5BvkNkqKikmZnw7r/WxvQI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=KbfWfQKM; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.13 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727489691; 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=CgshABXh43+EnL8gofqo/XDlvuefRSD0JDpM1evDmPU=; b=ETGwWGNm3zF90hTf8FQwHpBxM1v1qS+SJIqRS+ODz7xiVYaEv8aeHj7G3Z96U166/UE2ZZ agpva4jYLz3IfsdToyH6n+6pszjoMXdPNRNSIgyel8IbwOGi6CEnGAgR9T2IUsmaFgosIB osPL0jYzatQ6AfqGNOCXefhLOpLZVnM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489791; x=1759025791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6AckfW5DPm7esIMMaP5o1qk+OTB0aCm1cTjPckojN8M=; b=KbfWfQKMkFylo8gV+Qg7kuJvh9+iMrxP0zilWbi711paxNsHIG4h0HVk NmbY26rb5gamhv/mvba4ju2Pk9XP0A2g49OMWSbb+XukZfbw8x9/AAmVx NCN8U52Tau6F6IoUnOf7N9KI5mUDQH0ij/IcAEB9Y5KEJE9GoV5GpsRON VAjuy/oCEJNiSPvCbzxkU8bmK5MOHuruwHCPYj6C2nZXWZCYLkDO1+AmK 6srMv1jN6pJGUreUy0rrdU2PG9q+aOZhSQW9qZODXSIXwHf5jTFUmqFhW L3CWn7DsGS1U+HA5r2W2Rh3UF4YwB0owWB7RJda/IywZk68XnqcX25CzW g==; X-CSE-ConnectionGUID: iUlMrqfuRJCyayOqqnftTw== X-CSE-MsgGUID: AJHh9Y9dS4uUf36Hy+2H8A== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526911" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526911" 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: 7310gMP3QtWHwY/v2lB2jA== X-CSE-MsgGUID: A0YqRezoS0+mYDf5q/jI8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507133" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa008.jf.intel.com with ESMTP; 27 Sep 2024 19:16:22 -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 7/8] mm: swap: Count successful large folio zswap stores in hugepage zswpout stats. Date: Fri, 27 Sep 2024 19:16:19 -0700 Message-Id: <20240928021620.8369-8-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4854740002 X-Stat-Signature: 6otcrywtdcz6ne4tb7g6xf3mer8rywp8 X-Rspam-User: X-HE-Tag: 1727489791-939589 X-HE-Meta: U2FsdGVkX1/XRurBD3iKD/9QS8kql36MTOmZc0XhYN/XCnS5I2rMycG4Qp8DY0EKblZ46eda78ISe+sGsRFgfjzPqpiL1EIQBktiAfzhbGTLmCOl9nS5xTOWmDZ4ZGRISMF/yt/LIzWFsJUVp3xYWTzDIayXfx27NppIE7DRsetrcdNVD+jo/S0vs1tdo3D4+g4k+9R1NxBoNKNALMm9uWM3GZpfyupA5am33Sn6nYslrK7k5/HNvK/XP77MPNRTwmPgH/7vQLdZ5d0UAnUd+OtleWXiDXxirjYF9VGOkl/7Wbipf2bF8gEPpB881EPupoCJ8CMLOkPn42TcaQPC3ogGCPio7mdkdDBd0Yo3pXYFOnL4u/ASr2CK1jvy/WvzQ/p1p7r9yAtvRWCCYmnIWEQP8YBhL9NX+RzpXkkcF1Llxsfvdlqew0iFJKiSSLn4rbk69h29gX5A0RJw5y3oVL+trtBCmf7aGGBUSXCJarbnbXF+zyMyg8PgdppEadafZifxEP+NNWog+eKs1auOSiit8Lyt93O5PlIaJA2vsZBJLAJ4KMaBLpiaH3pcTE9oNA2d3yw7vc1Nimeu8xnsDolSJWs9Er7gfsJ9vpff691Kzl3XcnVzHs/XkbqKIAQYPrewg3dOzig7P3Z5eDQd3miHtVA2K44juk1QXA1HPUeqszMWuhpqxfyNOeac2T/Usrl+3pIwo+0Hlv9C2cRAHyie03N45/Z8yp5MXoaSYIXehxY6TlURoT7Ofg8CwCpaAKzVbWBawXME+CeAaTB0N6nm0vB5I55dgUtCo0HtGZmWACID9TGR+XITe6Mjo3TfcHi3k2Llzo4j5YR7HxQZt6B3w5N0BaG78qnCGXe+brCQcPlcJ0Hajnqv54eJuCiVK61DnFRRQRu6piGWvFdJkk933Vu29+NC648evJjahCLy7ubPdE4pXLyELcJHaO7M3fjagZS8d6giwL94HKv /PKKnlJp cZZV4qUMlG/PAAsITUxxSWyBETrVAFPXqoAdw5P6J/CVHsk4Ip72SqhcCtdIqs5tCoHvMlPEpqe8GqLsXmOyV/LXpKu5vCIF3q3d5QAwa/DWnNd9/rJc2ZW3X+RRaPZF5vczU9V8f31ywcI+2p/iJ69Gsn8BgVNMnzvLg3SYG1/dEd/EaMB7s1w77bQ== 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: Added a new MTHP_STAT_ZSWPOUT entry to the sysfs transparent_hugepage stats so that successful large folio zswap stores can be accounted under the per-order sysfs "zswpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/zswpout Other non-zswap swap device swap-out events will be counted under the existing sysfs "swpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/swpout Signed-off-by: Kanchana P Sridhar --- include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/page_io.c | 1 + 3 files changed, 5 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 5eb4b0376c7d..3eca60f3d512 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -119,6 +119,7 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_ALLOC, MTHP_STAT_ANON_FAULT_FALLBACK, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, + MTHP_STAT_ZSWPOUT, MTHP_STAT_SWPOUT, MTHP_STAT_SWPOUT_FALLBACK, MTHP_STAT_SHMEM_ALLOC, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 13bf59b84075..f596f57a3a90 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -611,6 +611,7 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); +DEFINE_MTHP_STAT_ATTR(zswpout, MTHP_STAT_ZSWPOUT); DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT); DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK); #ifdef CONFIG_SHMEM @@ -629,6 +630,7 @@ static struct attribute *anon_stats_attrs[] = { &anon_fault_fallback_attr.attr, &anon_fault_fallback_charge_attr.attr, #ifndef CONFIG_SHMEM + &zswpout_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif @@ -659,6 +661,7 @@ static struct attribute_group file_stats_attr_grp = { static struct attribute *any_stats_attrs[] = { #ifdef CONFIG_SHMEM + &zswpout_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif diff --git a/mm/page_io.c b/mm/page_io.c index bc1183299a7d..4aa34862676f 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -269,6 +269,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) swap_zeromap_folio_clear(folio); } if (zswap_store(folio)) { + count_mthp_stat(folio_order(folio), MTHP_STAT_ZSWPOUT); folio_unlock(folio); return 0; } From patchwork Sat Sep 28 02:16:20 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: 13814603 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 90734CF6493 for ; Sat, 28 Sep 2024 02:16:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 536F46B016A; Fri, 27 Sep 2024 22:16:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 322536B016C; Fri, 27 Sep 2024 22:16:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14CFB6B016D; Fri, 27 Sep 2024 22:16:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DD45E6B016B for ; Fri, 27 Sep 2024 22:16:33 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9FFE81C75BA for ; Sat, 28 Sep 2024 02:16:33 +0000 (UTC) X-FDA: 82612533066.23.264C9EC Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by imf30.hostedemail.com (Postfix) with ESMTP id 7B2B480008 for ; Sat, 28 Sep 2024 02:16:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OJB75IY5; spf=pass (imf30.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=1727489628; 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=L8jR7tSPEHVdmc5CyEIJ5dlIVKtxIw4w4VIXD+XVKsA=; b=jTbKOERd471f4BIAnnlPTCLV8nNchUZagcUMz9TfNGDs29pE9KMSDiDHctXa/8Wa5DFBDJ ZxPEK3P8jWl9FlNmLFUsb+hn7kSUv2yO/Fjqbog81Mx2JoqfsoOKQQBlOZjdc7VzB1b3IU R6hXZobA4Y2mQSt5Rgp0zYRXvuXsLj4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OJB75IY5; spf=pass (imf30.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=1727489628; a=rsa-sha256; cv=none; b=b/j7qlbzKG6YJuoGg+stboQXpXMpLGpW57tGTC52XFo4kRPO9/E4q/98jxAIzqlJcrXdtg 0N8UEfadjhyn/1NOjxfmZCLKCCUz1RpQP3Wy75MAf7z++b6AF+YskgU/DwKqJeh8EbskRH PxhOBxDYCGWQgoO7c2LOBvu+T1AuMh8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727489791; x=1759025791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jeCu3iqu/2EXy9IfjtlKEtm4q6TnkB4czmIDU7q2LAY=; b=OJB75IY5NAzShbSfPcUu4QL/avDSgm2HxPutF1gr7cxTA8kAboaI6hCo GMaDNDM4sgg2P5/ZwvCCnOaXhesGaAms5K+eZan2IA10K/teODc6tw2Dk eAoUQC6U9+Rp2QlkxRhkH04DGFZM+6YsrKmPi6dqwSdH0jwqyzW2p5vbm ajBMr5HA2Mx6T8OkBHNkI3tVMI0Fdxoebf3e/1wvlLWpJf7px7uVsprsv kVPV/78lQ4ZKoJ3IxjM7lIbtRladmiTgVavO59H+++GYyWO8FZPpNLg7A yAmS/Vpif8qrtv3DEaS7n5E7H61XRhbj1jIuElKxWE6/ocbAXNUg8HZVw w==; X-CSE-ConnectionGUID: fahv+hQfSpGz7eIC10RoqA== X-CSE-MsgGUID: v2A1+4ToRjy0GKsMiZHaDQ== X-IronPort-AV: E=McAfee;i="6700,10204,11208"; a="29526920" X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="29526920" 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: cRQ5tnNWR5CUGZgxe6qXrg== X-CSE-MsgGUID: qgNMbP/jRMKqlKVlPbychw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,160,1725346800"; d="scan'208";a="73507136" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa008.jf.intel.com with ESMTP; 27 Sep 2024 19:16:22 -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 8/8] mm: Document the newly added sysfs large folios zswpout stats. Date: Fri, 27 Sep 2024 19:16:20 -0700 Message-Id: <20240928021620.8369-9-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7B2B480008 X-Stat-Signature: ijn177ptyd7rf715gjhjjgiqhqfqudyh X-Rspam-User: X-HE-Tag: 1727489791-6474 X-HE-Meta: U2FsdGVkX1/VbLNMCOH31mDQVRsN57MTj8gZtVerIUD39QPyJHvaV+bazMLffyiHZPkK+wmdRhiAjKjdHrJAi9f2N5E196eaLz0DbY8qXi0FRAklRdVWFsopS18Zqw05HjUczbyoW24/wmqMJKsGbPa+zqaKVG6xRUJBRlemmU6QSJrQMjT/rHJSm0z72nC9YpEbolF/r5dhT5l6myhScUxAYHKwsH7QMeN6WarOlahR/002e2JbnkaZY1I4afHxnwFTRbFYvCHtxks2+1OAhkHAboXn9+0Efcgowdl47nJCUJ9p5UyLpbUjeFWuce3aF3b1XR6Jo3qJrkwLdNfuc/pfuEOPw5rSwEnCPdiBg0CeZVgKrHBbjrywUSpbDObuh9xXQw/3nHW2J35FIeu+8C3Pkw/DiTKrHmk2W2K8hZYmzqHVgHIb0zGccgbUZUiuHCOlXIFVkL/fyp8Yx00bzP23BcMGsYNY0UhsU/4Ij2yOUusp27CazXqNYkaMfijTCFWxC92+pnC8ha6K9ABEAtHIysUbe8ygbaEqCOrQsDsQYtndXhzvV/mhiZM73PXMJflBeOzZ/b43fjhh+UCq97lK0Id4QeMtn7qP0vFE1b/esxV+bcVP4/3b5ySxg7lnZ3qvtCsETGxU+vSQ1e5nswOoIrGsnO11z9QT8eGoxGu8a0iHcD6gnJ6FCenuRNnpxyRx0jikAAMg8b3mQhKcUEuS7nAbsTqgfVqR+x536mKy5baBeu/thb558Tc0nuPS5iIJD15ZTGlTeQDl3VcYXrtNtSoFVd0z8xdTAxAqnkKrXnqeDwhTbVoMlcFAMGTGxhI/PyZRUkYUBRCVAFLlKlim5jEpH4xGty8N7+cm6QpZRQFpgQ9qFhDcV16fKOPIexK93l2ZOxvgEL5g0H0XFjIQJnQNOmGVCwWK5VNxKeiTgAFAtULDdHGJGhnRzApX0YvA6Z/JPgOfa5KXxQX agqMJi94 /vnQ+S4RbOgNdiWRco1z5/nWkgoyLnEw3PP3SE+0NzWJzAXfkFTQZc7bcePupwcQeymp5kFcLTbvrD7+0BJtegOclCXcFjcto2SlseH3XRDZ3Jh2oWdiDY1bmr2cRj7aqTrtppgAtFak/lryXV2wVGN/X5QmD/tl7cycqaeZJMjaaxiLh+wgVWdYoxA== 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: Added documentation for the newly added sysfs per-order hugepage "zswpout" stats. Clarified that only non-zswap swapouts will be accounted in the existing "swpout" stats. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham --- Documentation/admin-guide/mm/transhuge.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index cfdd16a52e39..2a171ed5206e 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -530,10 +530,14 @@ anon_fault_fallback_charge instead falls back to using huge pages with lower orders or small pages even though the allocation was successful. -swpout - is incremented every time a huge page is swapped out in one +zswpout + is incremented every time a huge page is swapped out to zswap in one piece without splitting. +swpout + is incremented every time a huge page is swapped out to a non-zswap + swap device in one piece without splitting. + swpout_fallback is incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space