From patchwork Tue Mar 21 00:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13182068 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 B40CFC6FD1D for ; Tue, 21 Mar 2023 00:48:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA05B6B0075; Mon, 20 Mar 2023 20:48:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D50B76B0078; Mon, 20 Mar 2023 20:48:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C17E86B007B; Mon, 20 Mar 2023 20:48:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B19226B0075 for ; Mon, 20 Mar 2023 20:48:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7CDA4140EE3 for ; Tue, 21 Mar 2023 00:48:52 +0000 (UTC) X-FDA: 80591070504.26.A74FFA3 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf10.hostedemail.com (Postfix) with ESMTP id 794C4C0019 for ; Tue, 21 Mar 2023 00:48:50 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=v2FnbI7R; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=DzX6tcpS; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679359730; h=from:from:sender:reply-to: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:dkim-signature; bh=oGkjK2TbqrODiZ27bwpufFy80dPhzmLH1tKePfQCcsg=; b=sgpqCQAoRyN1ASmGhBg288BZ/fuX/CJVlNR2QGJkbeOx/TySMM2Cp68jbnbw3SW7UAm6Wt B4dZq0taXsCpbM6ARig6HuSu86Wa0n84YFh7Vwt2v//0IN32tJ+wEdCfWZOhvTN1U7+8E+ SY+daj7kxUR9YrJENSZ8leLmeoMVUjA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=v2FnbI7R; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=DzX6tcpS; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679359730; a=rsa-sha256; cv=none; b=Ce5M44iL1ghOEguTeZ4sKBXLOGjRIJB8j11gJ4oaewEOipMOEXqTtgIxZutLEPtZy8Ya2a bnShiw+tE65kJaCixeHSKXP5zkQRRZQVMNTo9Y5r0S4J+8+ZDpZTKmy3MKnFpF+ip3K90H wyQq1Ea2W3oWvKwm6C2Bj2cUJOLTmkI= Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id DAE775C019B; Mon, 20 Mar 2023 20:48:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 20 Mar 2023 20:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:reply-to:sender :subject:subject:to:to; s=fm2; t=1679359729; x=1679446129; bh=oG kjK2TbqrODiZ27bwpufFy80dPhzmLH1tKePfQCcsg=; b=v2FnbI7Rk9K6GPSwoV xTFz47m9B3DRkVgQxdK6L5tpwV54Pkk7nXPDW8hO9SqjDMl1ZpssfT6uEk2Yrbnj 95keebwa6R3FM4Pf/+d9dgLdWAhDmVitG2jRZLxpi4Fj9X2ICuP9iusyKQv0yjdV vy6xo2bGVmW2P9VxdwPsscbPDhoLYU4CrDQS9TRgNrj1bs+YmyjAYIfVFNyHwbdN PTjHUe5eyOqJdy5/nDUl2mESU2Nj5bSt8b7fGgACtHwaf+DfXEeltmX7FpBE23oS GF6nRFzvAOu0tobGk2qS0ijszzwi7x63ONxjyyVMfRQUr1ZGxwmrJfkEaoum/gBk EJgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1679359729; x=1679446129; bh=o GkjK2TbqrODiZ27bwpufFy80dPhzmLH1tKePfQCcsg=; b=DzX6tcpSYSk9j7QHV +EMwBA/10OxE8TVWLr6K+huXm9MJ53Bi6IxUgPIubvFX74ivmSImfisv3iXPZAIs uVJo45bg4cO2YTOSRzkZXiBSFQkiuPYjDsuJORjml0Bs/fO+u16RAic6UHbGuIK8 BkW333wARlfN/fCdjK1KeJS4UPSDYszqbsUqyVNcOBm47PQqJt5HQ5R5oQ0k9DYJ PQi1X64ymp6bOKP4HS60cIr/T/k1jeklixqZaPsRpz3ERurcT93fmsn/uPNkRrp6 g1aKzOcYnI9aUdBrHnAqfYGDjCz8DWeeaAA3vEqEzL0U1fyFK9/gNbyplQlRoCOl HIjEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefledgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofhrggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpedvieeutd ehtddthfegveekueevfedvueehjeeltdevgfejteekudfgvdelveekffenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Mar 2023 20:48:49 -0400 (EDT) From: Zi Yan To: "Matthew Wilcox (Oracle)" , Yang Shi , Yu Zhao , linux-mm@kvack.org Cc: Zi Yan , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 0/5] Split a folio to any lower order folios Date: Mon, 20 Mar 2023 20:48:24 -0400 Message-Id: <20230321004829.2012847-1-zi.yan@sent.com> X-Mailer: git-send-email 2.39.2 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 794C4C0019 X-Stat-Signature: uccwectfq866wm8ceumwoug3py77fdqs X-Rspam-User: X-HE-Tag: 1679359730-227722 X-HE-Meta: U2FsdGVkX19iQq3AYwBzP8SF0bXsSa6A8lHtOmgMgV0zsOB9SGPAo4BOvY4k0q1AzQtf69sARCoPCl/S+OF1TjK4hfEJ8JqVti46DqYM2Xbb/9PgnCrBdUn1V0LCgPVDhPR238SVqsVAdqXqYDSliSIV+cjMzbo31DQigVNyQxmYEBsb7QiepVbK89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F5GPLIjyuG+peGhypj/ygPStZa5zb/xpTMqWmWKPLvksNShNrvHUX39aGXtP9aEU1ocrBVPdHY+gc6sjY8OEuDgKZYsIxNc6IFuujk7Pj8Mi5lkRU0YmHjhNftxkMPsmh3ZeXh02/V0Gjze6n6/Lftft/iwNDNVytXtf1pT9a6WR8qDiSUkaPCXs5mp6vEgx1xY7NCTS/+Axtd5mWtTskOQGT/lN50zS/daBOOb6WcZYk9morYh8Z/kjSKezsR9YKipYxEbsG0tgRu4A== 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: From: Zi Yan Hi all, File folio supports any order and people would like to support flexible orders for anonymous folio[1] too. Currently, split_huge_page() only splits a huge page to order-0 pages, but splitting to orders higher than 0 is also useful. This patchset adds support for splitting a huge page to any lower order pages and uses it during folio truncate operations. The patchset is on top of mm-everything-2023-03-19-21-50. * Patch 1 and 2 add new_order parameter split_page_memcg() and split_page_owner() and prepare for upcoming changes. * Patch 3 adds split_huge_page_to_list_to_order() to split a huge page to any lower order. The original split_huge_page_to_list() calls split_huge_page_to_list_to_order() with new_order = 0. * Patch 4 uses split_huge_page_to_list_to_order() in large pagecache folio truncation instead of split the large folio all the way down to order-0. * Patch 5 adds a test API to debugfs and test cases in split_huge_page_test selftests. Comments and/or suggestions are welcome. [1] https://lore.kernel.org/linux-mm/Y%2FblF0GIunm+pRIC@casper.infradead.org/ Zi Yan (5): mm: memcg: make memcg huge page split support any order split. mm: page_owner: add support for splitting to any order in split page_owner. mm: thp: split huge page to any lower order pages. mm: truncate: split huge page cache page to a non-zero order if possible. mm: huge_memory: enable debugfs to split huge pages to any order. include/linux/huge_mm.h | 10 +- include/linux/memcontrol.h | 5 +- include/linux/page_owner.h | 12 +- mm/huge_memory.c | 138 ++++++++--- mm/memcontrol.c | 8 +- mm/page_alloc.c | 8 +- mm/page_owner.c | 11 +- mm/truncate.c | 21 +- .../selftests/mm/split_huge_page_test.c | 225 +++++++++++++++++- 9 files changed, 368 insertions(+), 70 deletions(-)