Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A338C433DB for ; Wed, 24 Feb 2021 22:36:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A05EE64F07 for ; Wed, 24 Feb 2021 22:36:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A05EE64F07 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 094C06B0005; Wed, 24 Feb 2021 17:36:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 043F66B006C; Wed, 24 Feb 2021 17:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E50706B006E; Wed, 24 Feb 2021 17:35:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id CD2876B0005 for ; Wed, 24 Feb 2021 17:35:59 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9334E82EB560 for ; Wed, 24 Feb 2021 22:35:59 +0000 (UTC) X-FDA: 77854620438.11.D3A2C19 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by imf26.hostedemail.com (Postfix) with ESMTP id 6ED6D407F8F8 for ; Wed, 24 Feb 2021 22:35:54 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 5EF08962; Wed, 24 Feb 2021 17:35:56 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 24 Feb 2021 17:35:57 -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=CEauTJhjuShQ+0bp1nXUqYL/A5 D3hihBflxPWGyYazY=; b=NHzrNx+aUaLWw7fpievjn5SY7YmXqfMUW+d5kA6K2x MxOBHRuZeDBsDncV0rlF9NTjPuVBN9OWEY0J52kLtaUiBd5zTCPsGTuDg6012tMA 8Dk+XKKWg+8gCckcbbQQBmT+mBJXNE5kt4y/66G0sLy7YBtFpOqMd5+GayxidpfU Ju3/NAZGSU3sRKsudLTwIVOWOKIPAZbk911wChzReTcWXAjSfzUXCmIbgDLQJFl/ 0uHVIEiVl3Rnzlmd9xBhi+hLpjWrNWHtgKkXYocOtr0T9o7yZ/ueDt48AdPLo1fG 29py4p/g49Mt8J3c6gj/pouWWK3VHzk47LhHz+y5fGVw== 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=fm2; bh=CEauTJ hjuShQ+0bp1nXUqYL/A5D3hihBflxPWGyYazY=; b=S2bxWuSDvdk1bF8p5DnTRQ z0xNakuU4tK8P25B5+7D5ZKqabLNNK4jt2oqy3j4ebxyIEMJyDaVbBjmoiGvSBYZ 0Uhx0JQ98Ie3mK4t93rPp4u3w1cjaNpED8nEQbRebyVWVIBeAHuhG0a0uzIw3D6p VRXJHh5dieQKfbA1qxUUNh22tjGrhoAhgjvyJn2T6Ics68+fE5KR0yDHZMrlxI1v svxM3gZGlN8DidtyohfOUOi8/ihuqKBALPnlFEMqUA6N2ZBpngjbNvaEsoQuqFlR 0SemKOZvWmBx4KKAHYcVv+Sy0tivONEgo5av5dpbMhBuuAlwI0QEkv5MFHGlSUEw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeejgdduieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfforhgggfestdhqredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhephfefiedvhf dvveehvdekledvieettdekvdektddvgfduudelueevtdfffeduvdfhnecuffhomhgrihhn pehgihhthhhusgdrtghomhdpkhgvrhhnvghlrdhorhhgpdhlfihnrdhnvghtnecukfhppe dvtdelrdeirdejuddrvddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Received: from Threadripper.local (209-6-71-213.s2259.c3-0.abr-cbr1.sbo-abr.ma.cable.rcncustomer.com [209.6.71.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 8598A240065; Wed, 24 Feb 2021 17:35:54 -0500 (EST) From: Zi Yan To: linux-mm@kvack.org Cc: Matthew Wilcox , "Kirill A . Shutemov" , Roman Gushchin , Andrew Morton , Yang Shi , Michal Hocko , John Hubbard , Ralph Campbell , David Nellans , Jason Gunthorpe , David Rientjes , Vlastimil Babka , David Hildenbrand , Mike Kravetz , Song Liu , Zi Yan Subject: [RFC PATCH v3 00/49] 1GB PUD THP support on x86_64 Date: Wed, 24 Feb 2021 17:35:36 -0500 Message-Id: <20210224223536.803765-1-zi.yan@sent.com> X-Mailer: git-send-email 2.30.0 Reply-To: Zi Yan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6ED6D407F8F8 X-Stat-Signature: gnekba5sed9rbr4dbjhrdqsprend4xxi Received-SPF: none (sent.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=wnew2-smtp.messagingengine.com; client-ip=64.147.123.27 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614206154-252225 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, I have rebased my 1GB PUD THP support patches on v5.11-mmotm-2021-02-18-18-= 29 and the code is available at https://github.com/x-y-z/linux-1gb-thp/tree/1gb_thp_v5.11-mmotm-2021-02-18-= 18-29 if you want to give it a try. The actual 49 patches are not sent out with t= his cover letter. :) Instead of asking for code review, I would like to discuss on the concerns = I got from previous RFCs. I think there are two major ones: 1. 1GB page allocation. Current implementation allocates 1GB pages from CMA regions that are reserved at boot time like hugetlbfs. The concerns on using CMA is that an educated guess is needed to avoid depleting kernel memory in case CMA regions are set too large. Recently David Rientjes proposes to use process_madvise() for hugepage collapse, which is an alternative [1] but might not work for 1GB pages, since there is no way = of _allocating_ a 1GB page to which collapse pages. I proposed a similar approach at LSF/MM 2019, generating physically contiguous memory after p= ages are allocated [2], which is usable for 1GB THPs. This approach does in-p= lace huge page promotion thus does not require page allocation. 2. Large amount of new code to review. I find most of added code is just a simply copy paste from existing PMD THP code. I have tried to reduce the new code size by reusing some existing code [3], but did not find a = good way of reusing PMD handling code for PUD, which is the major part of this patchset. I am all ears if you have any idea on how to reduce new code s= ize or make code review easier. Any comment or suggestion is welcome. Thanks. [1] https://lore.kernel.org/linux-mm/d098c392-273a-36a4-1a29-59731cdf5d3d@g= oogle.com/ [2] https://lwn.net/Articles/779979/ [3] https://lwn.net/Articles/837928/ Roman Gushchin (2): mm: cma: introduce cma_release_nowait() mm: hugetlb: don't drop hugetlb_lock around cma_release() call Zi Yan (47): 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: thp: use single linked list for THP page table page deposit. mm: add new helper functions to allocate one PMD page with HPAGE_PMD_NR PTE pages. mm: thp: add page table deposit/withdraw functions for PUD THP. mm: change thp_order and thp_nr as we will have not just PMD THPs. mm: thp: add anonymous PUD THP page fault support without enabling it. mm: thp: add PUD THP support for copy_huge_pud. mm: thp: add PUD THP support to zap_huge_pud. fs: proc: add PUD THP kpageflag. mm: thp: handling PUD THP reference bit. mm: rmap: add mappped/unmapped page order to anonymous page rmap functions. mm: rmap: add map_order to page_remove_anon_compound_rmap. mm: add pud manipulation functions. mm: thp: add PUDDoubleMap page flag for PUD- and PMD-mapped pages. mm: thp: add pmd_compound_mapcount for PMD mappings in PUD THPs. mm: thp: add split_huge_pud() function to split PUD entries. mm: thp: handle PMD-mapped PUD THP in split_huge_pmd functions. mm: thp: adjust page map counting functions for PMD- and PTE-mapped PUD THPs. mm: thp: new ttu_flags to split huge pud during try_to_unmap. mm: thp: add new checks for zap_huge_pmd. mm: thp: add pud split events. mm: thp: split pud when adjusting vma ranges. mm: thp: handle PUD THP properly at page allocation and deallocation. mm: rmap: handle PUD-, PMD- and PTE-mapped PUD THP properly in rmap. mm: page_walk: handle PUD after pud entry split. mm: thp: use split_huge_page_to_order_to_list for split huge pud page. mm: thp: add PUD THP to deferred split list when PUD mapping is gone. mm: debug: adapt dump_page to PUD THP. mm: thp: PUD THP COW splits PUD page and falls back to PMD page. mm: thp: PUD THP follow_p*d_page() support. mm: stats: make smap stats understand PUD THPs. mm: page_vma_walk: teach it about PMD-mapped PUD THP. mm: thp: PUD THP support in try_to_unmap(). mm: thp: split PUD THPs at page reclaim. mm: support PUD THP pagemap support. mm: madvise: add page size options to MADV_HUGEPAGE and MADV_NOHUGEPAGE. mm: vma: add VM_HUGEPAGE_PUD to vm_flags at bit 37. mm: thp: add a global knob to enable/disable PUD THPs. mm: thp: make PUD THP size public. hugetlb: cma: move cma reserve function to cma.c. mm: thp: use cma reservation for pud thp allocation. mm: thp: enable anonymous PUD THP at page fault path. mm: cma: only clear bitmap no freeing pages. mm: thp: clear cma bitmap during PUD THP split. mm: migrate: split PUD THP if it is going to be migrated. .../admin-guide/kernel-parameters.txt | 2 +- Documentation/admin-guide/mm/transhuge.rst | 1 + arch/arm64/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/x86/include/asm/pgalloc.h | 69 ++ arch/x86/include/asm/pgtable.h | 26 + arch/x86/kernel/setup.c | 8 +- arch/x86/mm/pgtable.c | 38 + drivers/base/node.c | 2 + fs/proc/meminfo.c | 2 + fs/proc/page.c | 2 + fs/proc/task_mmu.c | 126 ++- include/linux/cma.h | 20 + include/linux/huge_mm.h | 92 ++- include/linux/hugetlb.h | 12 - include/linux/llist.h | 11 + include/linux/memcontrol.h | 5 +- include/linux/mm.h | 53 +- include/linux/mm_types.h | 13 +- include/linux/mmu_notifier.h | 13 + include/linux/mmzone.h | 1 + include/linux/page-flags.h | 25 + include/linux/page_owner.h | 10 +- include/linux/pgtable.h | 34 + include/linux/rmap.h | 10 +- include/linux/vm_event_item.h | 7 + include/uapi/asm-generic/mman-common.h | 23 + include/uapi/linux/kernel-page-flags.h | 1 + kernel/events/uprobes.c | 4 +- kernel/fork.c | 10 +- mm/cma.c | 226 ++++++ mm/cma.h | 5 + mm/debug.c | 6 +- mm/gup.c | 60 +- mm/huge_memory.c | 748 ++++++++++++++++-- mm/hugetlb.c | 126 +-- mm/khugepaged.c | 16 +- mm/ksm.c | 4 +- mm/madvise.c | 17 +- mm/memcontrol.c | 6 +- mm/memory.c | 28 +- mm/mempolicy.c | 14 +- mm/migrate.c | 16 +- mm/page_alloc.c | 55 +- mm/page_owner.c | 13 +- mm/page_vma_mapped.c | 171 +++- mm/pagewalk.c | 6 +- mm/pgtable-generic.c | 49 +- mm/rmap.c | 297 +++++-- mm/swap_slots.c | 2 + mm/swapfile.c | 11 +- mm/userfaultfd.c | 2 +- mm/util.c | 18 +- mm/vmscan.c | 33 +- mm/vmstat.c | 8 + 55 files changed, 2160 insertions(+), 401 deletions(-) --=20 2.30.0