From patchwork Fri Oct 18 06:48:01 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: 13841262 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 6CF02D3C552 for ; Fri, 18 Oct 2024 06:48:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BA9E6B00B0; Fri, 18 Oct 2024 02:48:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 445706B00B3; Fri, 18 Oct 2024 02:48:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 134916B00B1; Fri, 18 Oct 2024 02:48:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DD9486B00B0 for ; Fri, 18 Oct 2024 02:48:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E0BBD120571 for ; Fri, 18 Oct 2024 06:48:02 +0000 (UTC) X-FDA: 82685792994.20.3D606DE Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by imf24.hostedemail.com (Postfix) with ESMTP id 4DC0F180009 for ; Fri, 18 Oct 2024 06:48:09 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=A9P0PveW; spf=pass (imf24.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 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=1729233945; 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=jdi1Tv04WXVxopnAtIvN+CKkIJ4gn1En4c8wA0c7RIg=; b=FfjszwBfrC645SS70VnApYcWQ3sXAcTkovgkg4u+Qu1rnVJvF0YEVeAzHZEqBm6Od6m1t9 aoRLYMEJiMmZX9Ssyw9jEOzBDelYBRiCf21eOjWOQSV5ZdjRykBdnWTCDuh+CeER8gPqQA rzzB3CVK1MdSAUsEqmtyKG/qomBpyf0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729233945; a=rsa-sha256; cv=none; b=GePmlslmdHy8hHXtM6qgehEv9nwsXm6JJfOnc3ZX22oo5QqZ8cLgrVXl51n4h2QwNKYtVW 4kDQ4mgrcEvNqmgC8RUyxVCEoR7dEhek4YJ4eS2kcdBJZxuGGmLOUHotcj7doW51B/XCyj gQfInX7987TgVomvVh01NoO+3N7SV7A= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=A9P0PveW; spf=pass (imf24.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 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=1729234091; x=1760770091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0287k7mWEmWYuvXNZAukIKoRrD9gl2Lhv4dAhuzEN6E=; b=A9P0PveWAhnXrQaO70Kw2LRlhuiQYfKsB43yJLLcPMQ6tQxxpgElR9mP PLdIlZ6vS1ziw2gXNtoiPw1rI0pWZelzVa7qQq4r0hKTxFwzXwMNQbkZN 3wKAs+FcYXiCP64hay6fuL9yxqWcTFEnLBcAMe9JD3lHo1U7ivpDz38eh vBszH6tegxlRsYAQftgQL+lBAtcClDxIxuvZ6CPnk8r5k6nXH5eyaWAff I5xZrZ1az7ucMNXyqgIdkBjAMviJLm4bHi5m3RgkXFT0QQVOkfbiwU4GM ADNfxuy7nhpvaobOYGFt05m1VXGzSrxDZRWqHShM/we9eOAXq7FZzTJVy A==; X-CSE-ConnectionGUID: UPUSoFXBQ4qIRPLEFl90GA== X-CSE-MsgGUID: QFwYFMVhS+2OfqrIIwo6dg== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="28963340" X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="28963340" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 23:48:08 -0700 X-CSE-ConnectionGUID: /UVWgjWZT22cO5WouhsKFg== X-CSE-MsgGUID: +vVqT/OlTbeg2bOeVG+nKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="82744509" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa003.fm.intel.com with ESMTP; 17 Oct 2024 23:48:07 -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, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, hughd@google.com, willy@infradead.org, bfoster@redhat.com, dchinner@redhat.com, chrisl@kernel.org, david@redhat.com Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [RFC PATCH v1 3/7] pagevec: struct folio_batch changes for decompress batching interface. Date: Thu, 17 Oct 2024 23:48:01 -0700 Message-Id: <20241018064805.336490-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241018064805.336490-1-kanchana.p.sridhar@intel.com> References: <20241018064805.336490-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: hk3agwjo69qxrwc4zowtnn7dentimife X-Rspamd-Queue-Id: 4DC0F180009 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729234089-750458 X-HE-Meta: U2FsdGVkX1+nHKUYL9Nixscr/wRl3jHtSVcGrGlbCnqnnbJ01D4jqd8xaaDvCgQpMinYIT+OLjUc0rf83B3+LT1ij175QjNBkR2ksLWhLuB0TE9IroY7XDfnNlk57QHODPFjfjaU87KP6kd/KYqjgbyVldPpHnXcs0QI8hQEG5FCipnTJbO3WCbzoxGzwc+SqSEeh9C5P/qm+z3yfyJGSI1uRIQ+QlmSVXDruiSPehE2Z1QsCld8kr/ii4nekkbYQRnYv0G2SmVccYYUOki2egDUxEmeC3KBfcQNETBOo6w8/ZlkfhkzyexeOYAd0vmW6EYz+pvlx6dl24TQq4IfxApqL88RbYckwlMGKKz0ivK9TE9/hH3ozPv+NXY+d5buieWjQbzKjU1g1ZEnwSoY+lN4U7IcxUQUH5ToDhgvVRf/fVP3UJPjppT0xYUvjqmi5DU+ksteKALphi2jOrcVLtonhYNsS9qjnbmVWuoA/hiYr1SEvUBP3lC2P1rc87FvnbbzLZTS7UkOK5x3SKdmK5bOHDwp19ByDxArLSA6zHN5b8WitKK1QlLmi63Bi5+h64mueIykDuz99KF0vXEoZ4mJl+G0QUGao4RY8q8OO8BtKKZCflUBUDWI7j9PKbKXk6ZWwqwlL1nbhlkg5sRaYcHzzCy/tQVX1FUa6VvASgy87U6B7VAzJq5ppJ25Fon4jY33T1UqmUUO/33puOBv8uCzVvdkvE9qisbM6aSB4CaAI9Rp0n0as7OtnPAvcN8KYHqL9BaVv+Diici27iFp5iZMvYQq+6rCyK246Ivs+fOSEaLDfyv3Fa5TBk3ylQcXJ1trgUVJXbuG4zCwmGBQ6mEus6VJnOtRMicOlpeQzPNC5+IjgH2z3Q7xDEXHe5KukBf8002LQjX1TpUv1k/myS6cAPVAQwURno2A2aFcfW8GeXOfdSHXF8drFaCCpmV5iKSczKmkdCKPBJyBiU5 oLpREA4U FZBuGUvAAb6ub7mijYu5oux07kj0W/EjfCqr2soYKyRFN4hr0R8UhsALe5KsQxtbTSfYYTxLNWWcLIstwJ1ZkreyrXJejxceIDMNOLAC3tyG5CG3fn7GS9ABOYTlYqSBFElfRzHb7JA7UyWxTRvi+S3FkNqmMm7e1o9Zdel/0qcPRkqnx1oy45sgvsEVlWO5Rihag/wo5HfdFB0uyus0Ps16d5gpwSqK6NoX68Qri+JaUYkM= 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: Made these changes to "struct folio_batch" for use in the swapin_readahead() based zswap load batching interface for parallel decompressions with IAA: 1) Moved SWAP_RA_ORDER_CEILING definition to pagevec.h. 2) Increased PAGEVEC_SIZE to (1UL << SWAP_RA_ORDER_CEILING), because vm.page-cluster=5 requires capacity for 32 folios. 3) Made folio_batch_add() more fail-safe. Signed-off-by: Kanchana P Sridhar --- include/linux/pagevec.h | 13 ++++++++++--- mm/swap_state.c | 2 -- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 5d3a0cccc6bf..c9bab240fb6e 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -11,8 +11,14 @@ #include -/* 31 pointers + header align the folio_batch structure to a power of two */ -#define PAGEVEC_SIZE 31 +/* + * For page-cluster of 5, I noticed that space for 31 pointers was + * insufficient. Increasing this to meet the requirements for folio_batch + * usage in the swap read decompress batching interface that is based on + * swapin_readahead(). + */ +#define SWAP_RA_ORDER_CEILING 5 +#define PAGEVEC_SIZE (1UL << SWAP_RA_ORDER_CEILING) struct folio; @@ -74,7 +80,8 @@ static inline unsigned int folio_batch_space(struct folio_batch *fbatch) static inline unsigned folio_batch_add(struct folio_batch *fbatch, struct folio *folio) { - fbatch->folios[fbatch->nr++] = folio; + if (folio_batch_space(fbatch) > 0) + fbatch->folios[fbatch->nr++] = folio; return folio_batch_space(fbatch); } diff --git a/mm/swap_state.c b/mm/swap_state.c index 3cebbff40804..0673593d363c 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -44,8 +44,6 @@ struct address_space *swapper_spaces[MAX_SWAPFILES] __read_mostly; static unsigned int nr_swapper_spaces[MAX_SWAPFILES] __read_mostly; static bool enable_vma_readahead __read_mostly = true; -#define SWAP_RA_ORDER_CEILING 5 - #define SWAP_RA_WIN_SHIFT (PAGE_SHIFT / 2) #define SWAP_RA_HITS_MASK ((1UL << SWAP_RA_WIN_SHIFT) - 1) #define SWAP_RA_HITS_MAX SWAP_RA_HITS_MASK