Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3266051rdg; Tue, 17 Oct 2023 09:13:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhenRbpof6NuOlBbIfk6UKb7Mtew83om2aUH6llwxnRbbOT1xVaHXMh1bQJFo0vZozkehw X-Received: by 2002:a05:6a20:3d02:b0:12e:caac:f263 with SMTP id y2-20020a056a203d0200b0012ecaacf263mr3756185pzi.20.1697559206765; Tue, 17 Oct 2023 09:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697559206; cv=none; d=google.com; s=arc-20160816; b=o4UIzgeACiH9dynwKzyoQJcLS2naRhpoPGHe4+XsQ2smU3S4XM97/byelXXsmQIj7B Gg1AjRWtBn0zN91A1J8tG9QMJU3f/L1xsiV28qrQL2hnIkjSnjG/Osy5yDE+n+So5Fwl PDqZe/WPSR7xGiIfu7QXlxjQomrU0BiViJ7kUP19MnBjVWFL/5/LeItB2qo8V8VgOctc WWOboKz/m30xWVmiMrFG3Fx2XKG6aMbjbC8hg+CbLT5uwVOkbGULvtfD0bdNbB41BFG+ DMoZdO6U75FNrTqqY6BQnvHRyLh073nSrUFxcGd0TqUsif1FKGZxylJh9ZOpeTs2qqqF 4MZg== 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.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d124-20020a633682000000b005b4c93baa41si87015pga.391.2023.10.17.09.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 09:13:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id EDF4280ACCE6; Tue, 17 Oct 2023 09:13:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233493AbjJQQNS (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 09:13:24 -0700 (PDT) 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