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: 15499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4245043vqb; Tue, 17 Oct 2023 09:13:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWYEfL72ndWy+FJ5G9qjkJKLeE6HdMoTNinb3td/nTlvp69xXauUSkDWq3vquCldssjlEz X-Received: by 2002:a17:903:26c2:b0:1b8:9fc4:2733 with SMTP id jg2-20020a17090326c200b001b89fc42733mr2696826plb.3.1697559219789; Tue, 17 Oct 2023 09:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697559219; cv=none; d=google.com; s=arc-20160816; b=OkTnSB9R1BHngF+sbFgGY1MiExmAfR4IVTlfnODSRqfNB54Z/CdB+7E4QZrBLSMC6F 48yObzP+UxtYKr99H4c4HoNoy7NP1gkQvwTUIddXD/u/zqqAlpvuSjNpNCIaBTJmC3d7 AL1Tlc2jgWcy6IXuuVpRMbr4uHYul2tc/Lkev2psA7hd7c7ptWBR3XApXOkSx84k0eNB 2IOgF8foHPKDUFYTpVczBKDVKt3Hj10hVHzf8rUKsHTUj0w+OTajvnSrOoTVy9eFahCU /mKOFNiTMwmsELDNgyPTmN8TFjurNFqb3wRJsRzMKKDNfAfPtVZ9S4iDcjyN/U76s7nu THoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IhO1hrue+QjcqJoy1LvPhkcatqytFQsaU+mqzAl1IvY=; fh=odHZZLn5aUrUhssH6KSiJJlFsZ7wTjfMLFlHN8avkCo=; b=EmmWO9j41LdLQOOdSeCE0fY/GVOpJsTgkT8dPQW0R436kveezZkOPkbioJ2sMYt6bx H7m5gbWyDvVUniiucQfHKcTMdx21nMqywbZfUpJtvbG0UeGBs5mh8MVaTe+L+UZvIvK0 prbYgDKlk5WGBrz0qqXLm2bZ+wyuO8QTvyGPjL1b+QpAt6vvV0HzPZZag7CvgHSLW2le IJRbPlz/5VWnQ85OAFZ9UwiEGcxRixtM8FF1Do7vsGS4HmVLZSugQu0N3T0ZXT31PtIb m7Tf5rXyvvnIha4V6Dpdkv4yfFYHCdmgSbJuFfGMrTuJJI4bTsOlI1kVjghE3Y1aBfum 548Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u3-20020a17090282c300b001c41515c4c7si1308477plz.115.2023.10.17.09.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 09:13:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1B4E580293F7; Tue, 17 Oct 2023 09:13:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234352AbjJQQNS (ORCPT + 20 others); Tue, 17 Oct 2023 12:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbjJQQNR (ORCPT ); Tue, 17 Oct 2023 12:13:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F265E95 for ; Tue, 17 Oct 2023 09:13:14 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 17 Oct 2023 09:13:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780019856646786280 X-GMAIL-MSGID: 1780019856646786280 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