From patchwork Fri Oct 18 06:48:05 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: 13841266 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 382CDD3C550 for ; Fri, 18 Oct 2024 06:48:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99C986B00B6; Fri, 18 Oct 2024 02:48:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94C2A6B00B7; Fri, 18 Oct 2024 02:48:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79CB66B00B8; Fri, 18 Oct 2024 02:48:18 -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 5294A6B00B6 for ; Fri, 18 Oct 2024 02:48:18 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 01FAE1A05DD for ; Fri, 18 Oct 2024 06:47:56 +0000 (UTC) X-FDA: 82685793540.24.B9FECA2 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by imf22.hostedemail.com (Postfix) with ESMTP id E9D1FC0019 for ; Fri, 18 Oct 2024 06:48:02 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WYVrONdM; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf22.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729233977; a=rsa-sha256; cv=none; b=QCDv67KTFk65dDE0IkGtItiuN4eeuAW9GcQ1mlx7pv+lGAq3ISii62xdJkHf5kmLeUb46N 1uHz3+rZhOvs85PdhjzKxytRegZU5PcNzDkSQznGDd5cdQxVyzPs2TCBOcGnx2Fo3i7gxS geplW5MzgtWYmlU88sN8ORoayGMplEQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WYVrONdM; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf22.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 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=1729233977; 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=a+DO2IbSo3aqtpKkTXkM3Xy050C7tBzcVCQxYobierI=; b=WVwZ/5QzSjgxlj0euSn37XiTBg92wdifTwM7RDpBykW8Fq3gElZtlQom6j2rjSIVrHsaFD y0bMknqkyuxDgZPCRYaFiGYhNuYmssm354o2lwHgcNGel9oIXg49zXl7mMKOheIzseLMm3 6WDcbpJc8y/VRPPYhXp1d5vFIa0fhQA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729234096; x=1760770096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CzMrEaQ3oHH5UP19JYpptn44NLCDei/++V3CWVkaTRg=; b=WYVrONdMDbi1iGY+8EIEdWq2QHEAQ8F0PUajhgMSkilz97vHUKg/ZJ+3 XB6D3l01WTdTjc5/WbTOvp//hjSxpFIAbxmrMHxgrVMb1zmwCQ7iPdCAB FXoxW659V+fVjGfXgehVFxXCQZAxIdnvvC3mb4dCGnujMuXTjgkGHKUoj v2obg4IzgnpFIW4F3jXu75IHePphCn03D9C6q+T34hhytznTK5608QqF2 j6/IaGo2PcnTZ5FEN36rSFCZTX8oI8Pv+EAJzfBbz08SNlRcMiQaFmUMf nweY/ctQSrk8J7df+RTLSIAC8Oi3GE63NLZ/ZHyi2BSK31em/AdkKHGFQ Q==; X-CSE-ConnectionGUID: FH6sIy+uSpiSSEfPWWghOg== X-CSE-MsgGUID: PIugjJgbSU2naWm2mYd7Pw== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="28963388" X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="28963388" 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:10 -0700 X-CSE-ConnectionGUID: IJqafArETn+8qdBvF+ZmKQ== X-CSE-MsgGUID: heBzjw1nQkOgWyQXAlD5Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="82744533" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa003.fm.intel.com with ESMTP; 17 Oct 2024 23:48:10 -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 7/7] mm: For IAA batching, reduce SWAP_BATCH and modify swap slot cache thresholds. Date: Thu, 17 Oct 2024 23:48:05 -0700 Message-Id: <20241018064805.336490-8-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E9D1FC0019 X-Stat-Signature: dm7kqwh73dyg3d5wa1iyzxbcsioj4tk8 X-Rspam-User: X-HE-Tag: 1729234082-538479 X-HE-Meta: U2FsdGVkX1+wGMeIuRs7y5AmFpOparGxpRi6oBHgt08U6jkrn/ocSoUMpK/e0CxFAILnzIr53zPT3wwrfW54I0UBSqr5z0RoUzd3YRvvI+RPIm4pX4WDTBSnSr7pHT7+l6zGcpm+//sWk0bxD9ofN9cvfLIRtP00MeQkeifCTQBOtR9k28pJYLXyLwtxb9XmjFD8RYU6X7RanrITItFTnz7JglDDfUIjId0hF6oqUdFNFdB+Qe6jo+HW3c8ajHsZQulTjq7T+hgzoI/8dtjaRCvAmsbgcP8w80nZRe4uvT3xYkiiKNdjoVexIDbh17reLUbwoipdE/I6/AqSTX+Nqdi7Ve/WRbU0FeYG22s7hXl7t4Y0nqxPZ+37+5XU/E8rEexns5knyL2N7zxQ6yBQjoUOtaqLULtGgXZ1TT9ymjQ9hUnkMXykal/VihdI9ZS6ECU1r6AQcfm+QKVk/fUKUVvcVkEYfMU8Y4xfQyR4d01KG22JTwX0P82NjrDWWE+Y6NhpGoNHmCCyvr6k0tPXV8qaAezCNA07ATACF+vZncpSp55E5sb+QXiJ7ILk6Y64fuKzILmqsKGq1dQV8clTQPmOCuBZ/YF/R6TEqA6yOVsfqMSMczBg/KCgTbtvdysNNLWznBmAhHbY0t+8KCOy8RgZPcPPKEKvylTcuJFXWn2pVmflxVqzxphxOabIG3fUjxjUnKSCCXG0AN56rXjEiW6GUpOLaHXjIUFJQXeTts90JL7h2GTVyVmw/uHoZQzgHC0Hm42qvUy1qXkdsnGJw2PMfcz21wiKQmEnzbrZk48Rkwlx4x2BWlnMWNFXCuwH2zpyuiIM28JQ4zuN86Bazr8KUQaQgesaFQYtysA43PAU0xRzb9r/2kBVR4zwpf46Lp7poGGQgr5HX2Uvcle5qPO3M2hc5r70AvYkbZLEBXVsm5xHJOh3I9JaNKQqfdIp/1gMMrp19PAimtwNkr5 b3+nNzeq dcKVsT0avV2EyDoRBtpyBZnVS2fD/eUSO2hycljE2Gj/1kXCflvLuPVp5nhd4EuhLGzJR22MOX1Ad3Jqfvh8lOIr45cYs2r2UrBYgqE84PcPWE/smEiy87e0x8sIuX8jIEcWGhcHrpvPBcqlKgxMGbeCKNbfeUycH6hcIEqT3alhQ6OoZ7yRSPWwd9NqlpIjO/HShpW2mZkg62IYeFU6ntl6ETG78A34AjHy7y+NHEuwkdnxPeamD8u4P2rxMbz9V7ywv8emdgir2ToU= 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: When IAA is used for compress batching and decompress batching of folios, we significantly reduce the swapout-swapin path latencies, such that swap page-faults' latencies are reduced. This means swap entries will need to be freed more often, and swap slots will have to be released more often. The existing SWAP_BATCH and SWAP_SLOTS_CACHE_SIZE value of 64 can cause lock contention of the swap_info_struct lock in swapcache_free_entries and cpu hardlockups can result in highly contended server scenarios. To prevent this, the SWAP_BATCH and SWAP_SLOTS_CACHE_SIZE has been reduced to 16 if IAA is used for compress/decompress batching. The swap_slots_cache activate/deactive thresholds have been modified accordingly, so that we don't compromise performance for stability. Signed-off-by: Kanchana P Sridhar --- include/linux/swap.h | 7 +++++++ include/linux/swap_slots.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/swap.h b/include/linux/swap.h index ca533b478c21..3987faa0a2ff 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,13 @@ struct pagevec; #define SWAP_FLAGS_VALID (SWAP_FLAG_PRIO_MASK | SWAP_FLAG_PREFER | \ SWAP_FLAG_DISCARD | SWAP_FLAG_DISCARD_ONCE | \ SWAP_FLAG_DISCARD_PAGES) + +#if defined(CONFIG_ZSWAP_STORE_BATCHING_ENABLED) || \ + defined(CONFIG_ZSWAP_LOAD_BATCHING_ENABLED) +#define SWAP_BATCH 16 +#else #define SWAP_BATCH 64 +#endif static inline int current_is_kswapd(void) { diff --git a/include/linux/swap_slots.h b/include/linux/swap_slots.h index 15adfb8c813a..1b6e4e2798bd 100644 --- a/include/linux/swap_slots.h +++ b/include/linux/swap_slots.h @@ -7,8 +7,15 @@ #include #define SWAP_SLOTS_CACHE_SIZE SWAP_BATCH + +#if defined(CONFIG_ZSWAP_STORE_BATCHING_ENABLED) || \ + defined(CONFIG_ZSWAP_LOAD_BATCHING_ENABLED) +#define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (40*SWAP_SLOTS_CACHE_SIZE) +#define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (16*SWAP_SLOTS_CACHE_SIZE) +#else #define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE) #define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (2*SWAP_SLOTS_CACHE_SIZE) +#endif struct swap_slots_cache { bool lock_initialized;