From patchwork Wed Nov 11 20:40:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11898513 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 587C0921 for ; Wed, 11 Nov 2020 20:40:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D024320797 for ; Wed, 11 Nov 2020 20:40:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="ArZDMod3"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fO5Nrhfv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D024320797 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6000C6B0074; Wed, 11 Nov 2020 15:40:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4EC436B0072; Wed, 11 Nov 2020 15:40:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3144A6B0073; Wed, 11 Nov 2020 15:40:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 003BA6B006E for ; Wed, 11 Nov 2020 15:40:45 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AF11A180AD802 for ; Wed, 11 Nov 2020 20:40:45 +0000 (UTC) X-FDA: 77473306050.27.wren24_4000fc527300 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 9101E3D663 for ; Wed, 11 Nov 2020 20:40:45 +0000 (UTC) X-Spam-Summary: 1,0,0,2b0ae3876c8da2b2,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:355:379:541:560:800:960:967:973:988:989:1260:1261:1311:1314:1345:1437:1513:1515:1521:1535:1542:1711:1730:1747:1777:1792:1801:2198:2199:2393:2525:2559:2565:2570:2682:2685:2693:2703:2731:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3354:3865:3866:3867:3868:3870:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4250:4321:4605:5007:6117:6119:6120:6261:7576:7903:8603:9025:11658:13161:13215:13229:30056,0,RBL:64.147.123.26:@sent.com:.lbl8.mailshell.net-62.18.0.100 64.100.201.100;04yr79wb9zj65ncgmm63tgoubeptyyp1woag47w6aazgfpuyj38jwbiw7xe3qby.1s44pk783c8z8sftgexhwrx6whiiumnh514pj3w6ky6jsgi5d9se8u3e59qiee4.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:67,LUA_SUMMARY:none X-HE-Tag: wren24_4000fc527300 X-Filterd-Recvd-Size: 6789 Received: from wnew1-smtp.messagingengine.com (wnew1-smtp.messagingengine.com [64.147.123.26]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Nov 2020 20:40:44 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 51EADB2F; Wed, 11 Nov 2020 15:40:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 11 Nov 2020 15:40:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; s=fm2; bh=2sl0hzEO2/NiJTtpzxt0U3pBP+ C9s4dcDTT4dzafDPo=; b=ArZDMod3L9ZYYUSziIS9vaKt50TESpps3cLmeg9cG0 7RFLLYc2uxpPVSsLuqytAhBjqsOqMHo0zjS3HmWwrlUy7MwPnpNJcQFdyEyW52MR hh0XmwvBSkPL8t/aqGulika0uVtWECwx6tuWexYIoEVxk0WblYzRqPWdN+SMqVBb CN6BfJ53OXdFQFZt46/9v7XC5T+8AThGu18Xla/wVC2D0a45FCjnnW2sdGjkfBaP Ve5jqXi2xFvU2236mGX4gDDYjzW9zgh7ll3eVu9DXr3Q/86AxZ/DAwWE2SjUm5C9 JiDCGA6qTudBRb2503yPvVwodkeseg1O0O1rWZbxQx8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:reply-to:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=2sl0hz EO2/NiJTtpzxt0U3pBP+C9s4dcDTT4dzafDPo=; b=fO5NrhfvxbYIOoJbO3uzLL 2TfDImSoUqelLhT5J1WOHlHKi20wwXm1klVWQLaZgw25t+5et257/iTS9wVNdJeW tIVvvAtvaylEI5ht5QrTrGwxkrDCjlD4RxE1c6SnUTg3cKlpqCtS/t8OYkF//TQx 9OPBj44o9hIUr/2oGimltmbOt69MWxpYIvDTNgRmI4lJ3tY7Twda1yJSltRbidv1 f3RRupFNhhgok/q6i2lVyPkEw7kCq/2ieMFf4CcFt/EKAurez3jB0ipzQj0+X7Uf vxejILPZtBqsOMK+yKrGtfG/LujfSzS/JMNn2nA9hYIN9PaD64MqkmAYTBbHP3NA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfforhgggfestdhqredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepgeegieehgf effeffleefgeevueegvdffteffhefhkeevvddtjedvudeljeetvdegnecuffhomhgrihhn pehkvghrnhgvlhdrohhrghdpihhnfhhrrgguvggrugdrohhrghenucfkphepuddvrdegie druddtiedrudeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id 833F3328006A; Wed, 11 Nov 2020 15:40:39 -0500 (EST) From: Zi Yan To: linux-mm@kvack.org, Matthew Wilcox Cc: "Kirill A . Shutemov" , Roman Gushchin , Andrew Morton , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Yang Shi , Michal Hocko , John Hubbard , Ralph Campbell , David Nellans , Zi Yan Subject: [RFC PATCH 0/6] Split huge pages to any lower order pages. Date: Wed, 11 Nov 2020 15:40:02 -0500 Message-Id: <20201111204008.21332-1-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 Reply-To: Zi Yan MIME-Version: 1.0 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, With Matthew's THP in pagecache patches[1], we will be able to handle any size pagecache THPs, but currently split_huge_page can only split a THP to order-0 pages. This can easily erase the benefit of having pagecache THPs, when operations like truncate might want to keep pages larger than order-0. In response, here is the patches to add support for splitting a THP to any lower order pages. In addition, this patchset prepares for my PUD THP patchset[2], since splitting a PUD THP to multiple PMD THPs can be handled by split_huge_page_to_list_to_order function added by this patchset, which reduces a lot of redundant code without just replicating split_huge_page for PUD THP. The patchset is on top of Matthew's pagecache/next tree[3]. To ease the tests of split_huge_page functions, I added a new debugfs interface at /split_huge_pages_in_range_pid, so developers can split THPs in a given range from a process with the given pid by writing ",,," to the interface. I also added a new test program to test 1) split PMD THPs, 2) split pagecache THPs to any lower order, and 3) truncating a pagecache THP to a page with a lower order. Suggestions and comments are welcome. Thanks. [1] https://lore.kernel.org/linux-mm/20201029193405.29125-1-willy@infradead.org/ [2] https://lore.kernel.org/linux-mm/20200928175428.4110504-1-zi.yan@sent.com/ [3] https://git.infradead.org/users/willy/pagecache.git/shortlog/refs/heads/next Zi Yan (6): mm: huge_memory: add new debugfs interface to trigger split huge page on any page range. 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: add support for split huge page to any lower order pages. mm: truncate: split thp to a non-zero order if possible. mm: huge_memory: enable debugfs to split huge pages to any order. include/linux/huge_mm.h | 8 + include/linux/memcontrol.h | 5 +- include/linux/page_owner.h | 7 +- mm/huge_memory.c | 177 ++++++++++-- mm/internal.h | 1 + mm/memcontrol.c | 4 +- mm/migrate.c | 2 +- mm/page_alloc.c | 2 +- mm/page_owner.c | 6 +- mm/swap.c | 1 - mm/truncate.c | 22 +- tools/testing/selftests/vm/Makefile | 1 + .../selftests/vm/split_huge_page_test.c | 255 ++++++++++++++++++ 13 files changed, 453 insertions(+), 38 deletions(-) create mode 100644 tools/testing/selftests/vm/split_huge_page_test.c --- 2.28.0