From patchwork Tue Oct 17 16:13:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13425596 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 817AECDB483 for ; Tue, 17 Oct 2023 16:13:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2249C80040; Tue, 17 Oct 2023 12:13:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ACEB8003F; Tue, 17 Oct 2023 12:13:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0769280040; Tue, 17 Oct 2023 12:13:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DF2428003F for ; Tue, 17 Oct 2023 12:13:17 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9FE4EB6133 for ; Tue, 17 Oct 2023 16:13:17 +0000 (UTC) X-FDA: 81355448034.06.76DB352 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id A0C9E1C0021 for ; Tue, 17 Oct 2023 16:13:15 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697559196; 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:references; bh=IhO1hrue+QjcqJoy1LvPhkcatqytFQsaU+mqzAl1IvY=; b=ncCKp+DIqPQGeQER/rHjiTpufv1WwLVvcGwSiJDBN1bCZR8a5jx5DvV7HlTcTEZ2Dl2lyH urPeSER5aAm2Bv1iVZ5G/1E9ZxUI8f6uyB4JYGGGvK8CXVFO+qTYtDJ4hFz+LeEsDOAoEr Karu6B+uNvdXL5SsRyfXlz/CZAiXgfM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697559196; a=rsa-sha256; cv=none; b=U57GD+d27g+dA+htkfjYZ6iVD4BdPTnw9wTz0eqapIIFPH6forYeG5wXDf9TbAtMccrfvc fs/wBKPsivvJVHdHgbegkMeEhMgS0+uXn3iqCujINEY1eee2nlgcape9cWBEOTsCPnHb/Q 3/IQF5DzEvXLXypuedwW6E5xZJ2i8+M= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D6AF2F4; Tue, 17 Oct 2023 09:13:55 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0463C3F762; Tue, 17 Oct 2023 09:13:12 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , David Hildenbrand , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/2] Swap-out small-sized THP without splitting Date: Tue, 17 Oct 2023 17:13:00 +0100 Message-Id: <20231017161302.2518826-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: A0C9E1C0021 X-Rspam-User: X-Stat-Signature: qsu75wjw9iehqmkhpuytof3if7p3pecq X-Rspamd-Server: rspam01 X-HE-Tag: 1697559195-820312 X-HE-Meta: U2FsdGVkX18LufGrI7hTbKvY8cXDb3SkPcOnx8pu1bLWvEmPbzqXx+b2hOe1NHll5/rmPLM8ZBHlu9Y+iDWkLS4WvWYNef1K1hNFCm2+OGtwTOFlATqeyD/tSWro7g7m8+0oPQTfH5Oaow+eiD5on712PF/XRXmGfMvWUUGUpuk3J7jvxxgc6MDD7mLI7T76Sp5mtsgviTFOnxe6pndv6CMca8TmZznPrt8zXnxKEGRj+wTUM7W3OFc+15poiNLgtpf6T0u/ekJu30PObiFS7MrHZLeRjiyBdSZFuE0A5k9dOzuY+czTGg7SSd5FKB4sFlBoplHcXzHgxFIyVf7/pAD4YUpyyK0GB4SqheCfv01KIjuRnVC9w0kT2KP1OcObzgg3zmNgWLe1/JFnJeKGPJEsCRTq/8/jvBVG56GDEQqxBUrR1PtNMmy5CKsZ9RbJ805JiRJvg47FPfkjJWv3pQGzkqJgZJZV6Gy21mImhsTmRvc0K9gh6jbudesYys6S2ALaJtYiWyYkLB8ALgzKlCfDDLfNLI8XNB30Quzv7Vxo0P93ofYd8MAMfZn347EsOCeXIRQEvWWJtwgKoFHFwCQAPsINlTUGlzrcxLgKFpGK3ownRuYTFHyAzQoaqoyUjJa/QKi6vppyuDb4lLVZrvhyZ/yqFijNZaVjuIoIsDAi0PuQiUonGxRR+xJ1uToJ6yvGA+PwfcPaqPkabaxjrh4cpwn0WZWvpQlj5NY18xYVwOctSZmswBsVDpnMFxgcrvjyFHN4wychzS24aO7iJlkH6KXcEDJxulpsnqNncoTgitdkMvRo+BX9nppPnuBNfPB1DDIV9KtJgKN72qu8yCby8NW+jqOt2u+N/4lUEmR85gTA/ytkkwa53sxMY5xNzwcz//LWsM4ehlxOYAdKTKPtK1+4a4mvUjSQPvMrxQKsXk+KJgjIz1CRfuxaiFBBFrzTEFkUsyYIquBWOnf qveKQ2zs 7eCAPUS5biq2OY3nCSr4m1W6XI5CwK718TlFq/VWLm9ackVmdTWLV24cEuYvMLLlQrdF4UnC7YqqY0LfWJ6H5uWv0Z4s00cemmGKsz0EWzT80nlx5eHZpr6ulmSDfp645lbA0BVIYttTJCdtvCNdohUn+NgJvN/wEHSR5OSBsOKOm7T7D62cdbAIvVwmpL45paeeIdW/fgQsay7fR7jgAsmTk1w== 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: Hi All, This is v2 of a series to add support for swapping out small-sized THP without needing to first split the large folio via __split_huge_page(). It closely follows the approach already used by PMD-sized THP. "Small-sized THP" is an upcoming feature that enables performance improvements by allocating large folios for anonymous memory, where the large folio size is smaller than the traditional PMD-size. See [2]. In some circumstances I've observed a performance regression (see patch 2 for details), and this series is an attempt to fix the regression in advance of merging small-sized THP support. I've done what I thought was the smallest change possible, and as a result, this approach is only employed when the swap is backed by a non-rotating block device (just as PMD-sized THP is supported today). Discussion against the RFC concluded that this is probably sufficient. The series applies against mm-unstable (3fb06e6d0a6f) Changes since v1 [1] ==================== - patch 1: - Use cluster_set_count() instead of cluster_set_count_flag() in swap_alloc_cluster() since we no longer have any flag to set. I was unable to kill cluster_set_count_flag() as proposed against v1 as other call sites depend explicitly setting flags to 0. - patch 2: - Moved large_next[] array into percpu_cluster to make it per-cpu (recommended by Huang, Ying). - large_next[] array is dynamically allocated because PMD_ORDER is not compile-time constant for powerpc (fixes build error). Thanks, Ryan [1] https://lore.kernel.org/linux-mm/20231010142111.3997780-1-ryan.roberts@arm.com/ [2] https://lore.kernel.org/linux-mm/15a52c3d-9584-449b-8228-1335e0753b04@arm.com/ Ryan Roberts (2): mm: swap: Remove CLUSTER_FLAG_HUGE from swap_cluster_info:flags mm: swap: Swap-out small-sized THP without splitting include/linux/swap.h | 16 +++--- mm/huge_memory.c | 3 -- mm/swapfile.c | 119 ++++++++++++++++++++++++------------------- mm/vmscan.c | 10 ++-- 4 files changed, 78 insertions(+), 70 deletions(-) --- 2.25.1