From patchwork Sat Feb 18 00:27:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13145367 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 5DF7EC05027 for ; Sat, 18 Feb 2023 00:28:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9152E6B0071; Fri, 17 Feb 2023 19:28:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C5536B0072; Fri, 17 Feb 2023 19:28:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78D7E6B0073; Fri, 17 Feb 2023 19:28:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 67B976B0071 for ; Fri, 17 Feb 2023 19:28:46 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 44A9AAAB6E for ; Sat, 18 Feb 2023 00:28:46 +0000 (UTC) X-FDA: 80478527052.28.60F4640 Received: from mail-vk1-f202.google.com (mail-vk1-f202.google.com [209.85.221.202]) by imf18.hostedemail.com (Postfix) with ESMTP id 804B31C0009 for ; Sat, 18 Feb 2023 00:28:44 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=V3JK4+P5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3uxvwYwoKCNgDNBIOABNIHAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jthoughton.bounces.google.com designates 209.85.221.202 as permitted sender) smtp.mailfrom=3uxvwYwoKCNgDNBIOABNIHAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676680124; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=mWeuLuNn4uyC0x6eZ6wlvm2QVk1yxpkiKp2+WFEPbUY=; b=UkBC/0qXcr/ThkknZrCxZfmj8P7EttTUrhH9zvPcxovuddYyTN3ar2lCCgmeZyEx26cXiK 8bq4lRGmR9s+aJArSbXCO3ABLHVjCZh4ttTYci3dMLRWZFWU+dyK7QTGsNAjmQCO72XOeT oR9bFs4RkSVASRSB+cVvJXmxUccHTTg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=V3JK4+P5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3uxvwYwoKCNgDNBIOABNIHAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jthoughton.bounces.google.com designates 209.85.221.202 as permitted sender) smtp.mailfrom=3uxvwYwoKCNgDNBIOABNIHAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680124; a=rsa-sha256; cv=none; b=q5SNPnunGnWrsF2pc3fxhRZjcXI8gIedzBhMKkmjL3OJpceGLKfBHX/HKuIo09zM2JGp+u wJUF28qowv8U2HsCatUXyYlWpkbqcvqFxLAo7+yynlE3z61l7mN46fRc27cPJY5VpoJoiA hfG1HGP4cbZ4Y8JwOeYk4NeuHmIDED4= Received: by mail-vk1-f202.google.com with SMTP id j5-20020a056122090500b004015f66acfdso720113vka.15 for ; Fri, 17 Feb 2023 16:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mWeuLuNn4uyC0x6eZ6wlvm2QVk1yxpkiKp2+WFEPbUY=; b=V3JK4+P5D4Qwq+Cd8+LnP4X808+qWrQ2UIjvUIgLq9RTmqo27E5kdoz84WCA2+OIaQ nwBp+DC+qRh3tvyimigIyBUOPfeM1eVm9uTeFNPGhtG51SDBaAlOLWrU09sypMF/TPFG ZbEeK43D1ANEWQDBZr70y8d/NT+5xOBGacDn8BnGYnafkKkSEvRUvUuz3YwNPQhPuYkF JAvZYgXdSJthWThMc985jfNbl9YoVj5V6TCRYpcNbV51ApzH7+HCd953eALIg/7QmNzA 94YSQru1UvYtUAzfeFGoVaycys+DvokZQ8KvX4+4O1Lm1as/wNgb/3EbHIdqB1P+3CHq DD6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mWeuLuNn4uyC0x6eZ6wlvm2QVk1yxpkiKp2+WFEPbUY=; b=0MQeAXjMIl3JwCUL0QsL1c/rgb/MXjVi/tMz6EVd2bydkJhAYLVef6DXtux/VlL7UV 2tvNvL95O4t+ikqZGOFTBjmVqbutL9Ap0hsnPjZHdrCfJn3SY1l95QoCYjvGF12emsxt SBXrZFYiKhc0jW8vclw1OFGLvNfQHKFpQoFcNaI87zUfGUlOzy0CqyhMlbfssobV4mXk vVI4fXXDRvW8GW4o/txg1wpr2Bl4nlSIHaIgtes0psl58IfhnGqZaXOKAVuksigQn7hJ T4lGDYNMitVQAdcVRbDbLKNXsJqzYoVio9TAt3o1QSL6HR/PPXj1vLj0oq/n+RWc6eCw TZFg== X-Gm-Message-State: AO0yUKWqRq+LY+XnbSrPGtK0tNnPk07ZVWusnQ4hVpCGr40XsxXiQZzN 95Als4vjz1gKmMcBdUzWwwFjiZaOC7p5cCxM X-Google-Smtp-Source: AK7set9rBoLXQVFin5khRVpuQJJvoRMICCVv99Ww1d88YMJESU8I2NCVScn/h2NF+Yub/Esf2uFtnVk2fNtQ6H+E X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a1f:ad86:0:b0:409:9240:daa1 with SMTP id w128-20020a1fad86000000b004099240daa1mr112496vke.30.1676680123527; Fri, 17 Feb 2023 16:28:43 -0800 (PST) Date: Sat, 18 Feb 2023 00:27:33 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230218002819.1486479-1-jthoughton@google.com> Subject: [PATCH v2 00/46] hugetlb: introduce HugeTLB high-granularity mapping From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu , Andrew Morton Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , "Zach O'Keefe" , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Frank van der Linden , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 804B31C0009 X-Stat-Signature: cbuzp73pxfwiox9q5rfpig89fdoq79bx X-HE-Tag: 1676680124-620151 X-HE-Meta: U2FsdGVkX18mdStDE7cBdwCGWu8Gi55RlaxpYA1r8x0PJJGCpHTK1cMfz4NR0g35bJxwH5ZGl8UON4Uh0ehIl5ph5oU+0DiTDSEwBlazk8lMUvnqHf/FxZHF15zrJuUfOow66yRRwH9a0EGR8e3Y+3eGfqxElrRA/oTYq5RsWZzVKlLLNgDqd07ixA0peKqzIVnUfvlh5o3jGLZDep3fuX5BHcJ6ni7WquqRSR8Ao/7Q2DAVW4mGUKlB+HgHduV9KBYop1lbD0pDoYM+pGP8M6seXiIKgPlSGKRIQj3vjiYSt9y1rPIo6N3sFFG8g68c8RYysJNcCOfFvILRo94hl39vD606Y1fy3CzwT0zYAck1IOaR7gVdH3FOshfH25fmYCthts7ctHOunJsMVC9GsngD6l8dlSr+Fzfejs0hZltsR2JsLOF22jXYV7hv6DpAN55e2f7MoyTz/O1kMIbVJLcBEQBxtDFvEY3VB8LErmOUBHLeDbBF8sb2BkOicVw8/9SKFg4FHLE23mUNNWJka/ePvwN204sHoU/jeaHFkBxLQN63ltnL4NeJ2QF4YuGpUjScVu0tLFkFyFo4irPk/HT4fWARKbMi1sNL7DRU8jGWbzp2VQja0tW49pCqDlClszyIN8+dqWt5CmN3UH7F+DMfzKTskjlJUC4fmvuWC4kjkVKE2gjtuONjTuRcikxZGCP0MZDusC6iJf3oKEkjWDdEaFTr+9k1Y+zAlpjjSp8AuWJHZh+HONUSoG2aVKsGeOvcvUqq/HP3BXpMMkTB5zCSuTJxEFDqtvU93X72HqkdjnF+/WsdxYJnOzBQZLdthyc4B1lbZRlegF/3ArVyT8iGgvKui7/hRbRQZUgtfzTWDZHSI8s2TfPO2JnnMRJO0RRFzkvCDg4ZydnTU/dJxp8dTjuYz5zSq4aPTwVIUNW/7cpYbdkpndivNBxRiyCTrjb/QbGOTt4KD9FQThf 83XtYUCy tViJ1PZpk0VBbis+6tiU5Ma3rZKOip/NLYZv3FzBFWycR7Bke230KRPKUosWwZIg9YBCV1gCsOK8gk13Zo3QXmmYJWtrUAShLQFn+aNxihj/oq4IH9DBwoewsEe76qn8YOiyUbK+EAtrZPAPq5v1/OQRKOEojeaVN4NAHZOQpsoxa4ekPek7Ts8WbNb1XoE4rO0q6UdclYkQEQSGOCd5fp6em/IztQbfdDtz8tUSl1Em1kZyZz5N3w1mkE68MHSSsLAH5ro+d38uUGuYIakvsz++1Hm6N6UCRStBVnBhDncXJYWpcOA1s8wU0E4r4JyVZhuTWfwnsJNBGlZ0mRPaCT7XVx2gt6EiaJtvCM/1AalczsTkgjiyQMBtxYCYJV/PWAE6wDg98EG2IutdDTwTElJxMBNbUBdHXqCWjYZnudcRq0XiMNCG/QMp8bFvomPuEnbRKRObtRho89MLSDWAex1jqwWyIpL1jbvicDGxSLnoyHSRttX3T7O/DK0/ErqhMSxq7qUFXX7d8PsDRsnpocvIEdppob0OdaKdeo7z6x5GLoxUPYTkUaZM+SZboI5bwinRh2mjcJtYGmb92VR0fpAvP31mOvposEs+ZV2eQ6Iuff1O/LJ3kYtR6BgorQto1I9SnhiL9p5/2bqCcYfIak19J/og3uVUebQOxymTOaL+bypOLb0ckczydM9w5VXyV+2KvYm3BTQLsApTbffiPyTU2cdiP52aI7cbAK4+dAm3RbdN0pN2GgpKS7w1TjKetscWNAIxQXiway/nUZ6ErE/byp3CMP1u4jbdx 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: This series introduces the concept of HugeTLB high-granularity mapping (HGM). This series teaches HugeTLB how to map HugeTLB pages at high-granularity, similar to how THPs can be PTE-mapped. Support for HGM in this series is for MAP_SHARED VMAs on x86_64 only. Other architectures and (some) support for MAP_PRIVATE will come later. This series is based on latest mm-unstable (ccd6a73daba9). Notable changes with this series ================================ - hugetlb_add_file_rmap / hugetlb_remove_rmap are added to handle mapcounting for non-anon hugetlb. - The mapcounting scheme uses subpages' mapcounts for high-granularity mappings, but it does not use subpages_mapcount(). This scheme prevents the HugeTLB VMEMMAP optimization from being used, so it will be improved in a later series. - page_add_file_rmap and page_remove_rmap are updated so they can be used by hugetlb_add_file_rmap / hugetlb_remove_rmap. - MADV_SPLIT has been added to enable the userspace API changes that HGM allows for: high-granularity UFFDIO_CONTINUE (and maybe other changes in the future). MADV_SPLIT does NOT force all the mappings to be PAGE_SIZE. - MADV_COLLAPSE is expanded to include HugeTLB mappings. Old versions: v1: https://lore.kernel.org/linux-mm/20230105101844.1893104-1-jthoughton@google.com/ RFC v2: https://lore.kernel.org/linux-mm/20221021163703.3218176-1-jthoughton@google.com/ RFC v1: https://lore.kernel.org/linux-mm/20220624173656.2033256-1-jthoughton@google.com/ Changelog: v1 -> v2 (thanks Peter for all your suggestions!): - Changed mapcount to be more THP-like, and make HGM incompatible with HVO. - HGM is now disabled by default to leave HVO enabled by default. - Added refcount overflow check. - Removed cond_resched() in hugetlb_collapse(). - Take mmap_lock for writing in hugetlb_collapse(). - Fixed high-granularity UFFDIO_CONTINUE on a UFFDIO_WRITEPROTECTed page (+tests) - Fixed vaddr math in follow_hugetlb_page. - Fixed Kconfig to limit HGM to x86_64. - Fixed some compile errors. RFC v2 -> v1: - Userspace API to enable HGM changed from UFFD_FEATURE_MINOR_HUGETLBFS_HGM to MADV_SPLIT. - Picked up Acked-bys and Reviewed-bys. Thanks Mike, Peter, and Mina! - Rebased onto latest mm-unstable, notably picking up Peter's HugeTLB walk synchronization fix [1]. - Changed MADV_COLLAPSE to take i_mmap_rwsem for writing to make its synchronization the same as huge_pmd_unshare, so anywhere where hugetlb_pte_walk() is safe, HGM walks are also safe. - hugetlb_hgm_walk API has changed -- should reduce complexity where callers wish to do HGM walks. - Always round addresses properly before populating hugetlb_ptes (always pick up first PTE in a contiguous bunch). - Added a VMA flag for HGM: VM_HUGETLB_HGM; the hugetlb_shared_vma_data struct has been removed. - Make hugetlb_pte.ptl always hold the PTL to use. - Added a requirement that overlapping contiguous and non-contiguous PTEs must use the same PTL. - Some things have been slightly renamed for clarity, and I've added lots of comments that I said I would. - Added a test for fork() + uffd-wp to cover copy_hugetlb_page_range(). Patch breakdown: Patches 1-4: Cleanup. Patch 5: rmap preliminary changes. Patches 6-9: Add HGM config option, VM flag, MADV_SPLIT. Patches 10-15: Create hugetlb_pte and implement HGM basics. Patches 16-30: Make existing routines compatible with HGM. Patches 31-34: Extend userfaultfd to support high-granularity CONTINUEs. Patch 35: Add HugeTLB HGM support to MADV_COLLAPSE. Patch 36: Add refcount overflow check. Patches 37-40: Cleanup, add HGM stats, and enable HGM for x86_64. Patches 41-47: Documentation and selftests. Motivation ========== Being able to map HugeTLB pages at PAGE_SIZE has important use cases in post-copy live migration and memory poisoning. - Live Migration (userfaultfd) For post-copy live migration, using userfaultfd, currently we have to install an entire hugepage before we can allow a guest to access that page. This is because, right now, either the WHOLE hugepage is mapped or NONE of it is. So either the guest can access the WHOLE hugepage or NONE of it. This makes post-copy live migration for 1G HugeTLB-backed VMs completely infeasible. With high-granularity mapping, we can map PAGE_SIZE pieces of a hugepage, thereby allowing the guest to access only PAGE_SIZE chunks, and getting page faults on the rest (and triggering another demand-fetch). This gives userspace the flexibility to install PAGE_SIZE chunks of memory into a hugepage, making migration of 1G-backed VMs perfectly feasible, and it vastly reduces the vCPU stall time during post-copy for 2M-backed VMs. At Google, for a 48 vCPU VM in post-copy, we can expect these approximate per-page median fetch latencies: 4K: <100us 2M: >10ms Being able to unpause a vCPU 100x quicker is helpful for guest stability, and being able to use 1G pages at all can significant improve steady-state guest performance. After fully copying a hugepage over the network, we will want to collapse the mapping down to what it would normally be (e.g., one PUD for a 1G page). Rather than having the kernel do this automatically, we leave it up to userspace to tell us to collapse a range (via MADV_COLLAPSE). - Memory Failure When a memory error is found within a HugeTLB page, it would be ideal if we could unmap only the PAGE_SIZE section that contained the error. This is what THPs are able to do. Using high-granularity mapping, we could do this, but this isn't tackled in this patch series. Userspace API ============= This series introduces the first application of high-granularity mapping: high-granularity userfaultfd post-copy for HugeTLB. The userspace API for this consists of: - MADV_SPLIT: to enable the following userfaultfd API changes. 1. read(uffd): addresses are rounded to PAGE_SIZE instead of the hugepage size. 2. UFFDIO_CONTINUE for HugeTLB VMAs is now allowed in PAGE_SIZE-aligned chunks. - MADV_COLLAPSE is now available for MAP_SHARED HugeTLB VMAs. It is used to collapse the page table mappings, but it does not undo the API changes that MADV_SPLIT provides. HugeTLB changes =============== - hugetlb_pte `hugetlb_pte` is used to keep track of "HugeTLB" PTEs, which are PTEs at any level and of any size. page_vma_mapped_walk and pagewalk have both been changed to provide `hugetlb_pte`s to callers so that they can get size+level information that, before, came from the hstate. - Mapcount Previously, file-backed HugeTLB pages had their mapcount incremented by page_dup_file_rmap. This is replaced with page_add_file_rmap, which is wrapped by hugetlb_add_file_rmap to implement new mapcount behavior. HugeTLB pages mapped at hugepage-granularity still have their compound_mapcount incremented by 1, but when a page is mapped at high granularity, we increase the subpages' mapcounts for all the subpages that get mapped. For example, for a 1G page, if a 2M piece of it is mapped with a PMD, the mapcount for all the 4K pages within the 2M piece have their mapcount's incremented. This behavior means that HGM is incompatible with the HugeTLB Vmemmap Optimization (HVO). HGM is disabled by default, and if it gets enabled, HVO will be disabled. Also, collapsing to the hugepage size requires us to decrement the subpage mapcounts for all of the subpages we had mapped. For a 1G page, this can get really slow. This thread[3] has some discussion. - Synchronization Collapsing high-granularity HugeTLB mappings requires taking the mmap_lock for writing. Supporting arm64 & contiguous PTEs ================================== As implemented, HGM does not yet fully support contiguous PTEs. To do this, the HugeTLB API that architectures implement will need to change. For example, set_huge_pte_at merely takes a `pte_t *`; there is no information about the "size" of that PTE (like, if we need to overwrite multiple contiguous PTEs). To handle this, in a follow-up series, set_huge_pte_at and many other similar functions will be replaced with variants that take `hugetlb_pte`s. See [2] for how this may be implemented, plus a full HGM implementation for arm64. Supporting architectures beyond arm64 ===================================== Each architecture must audit their HugeTLB implementations to make sure that they support HGM. For example, architectures that implement arch_make_huge_pte need to ensure that a `shift` of `PAGE_SHIFT` is acceptable. Architectures must also audit code that might depend on HugeTLB always having large mappings (i.e., check huge_page_size(), huge_page_shift(), vma_kernel_pagesize(), and vma_mmu_pagesize() callers). For example, the arm64 KVM MMU implementation thinks that all hugepages are mapped at huge_page_size(), and thus builds the second-stage page table accordingly. In an HGM world, this isn't true; it is corrected in [2]. [1]: https://lore.kernel.org/linux-mm/20221216155100.2043537-1-peterx@redhat.com/ [2]: https://github.com/48ca/linux/tree/hgmv1-dec19-2 [3]: https://lore.kernel.org/linux-mm/CADrL8HUSx6=K0QXQtTmv9ZJQmvhe6KEb+FiAviRfO3HjmRUeTw@mail.gmail.com/ James Houghton (46): hugetlb: don't set PageUptodate for UFFDIO_CONTINUE hugetlb: remove mk_huge_pte; it is unused hugetlb: remove redundant pte_mkhuge in migration path hugetlb: only adjust address ranges when VMAs want PMD sharing rmap: hugetlb: switch from page_dup_file_rmap to page_add_file_rmap hugetlb: add CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING mm: add VM_HUGETLB_HGM VMA flag hugetlb: add HugeTLB HGM enablement helpers mm: add MADV_SPLIT to enable HugeTLB HGM hugetlb: make huge_pte_lockptr take an explicit shift argument hugetlb: add hugetlb_pte to track HugeTLB page table entries hugetlb: add hugetlb_alloc_pmd and hugetlb_alloc_pte hugetlb: add hugetlb_hgm_walk and hugetlb_walk_step hugetlb: split PTE markers when doing HGM walks hugetlb: add make_huge_pte_with_shift hugetlb: make default arch_make_huge_pte understand small mappings hugetlbfs: do a full walk to check if vma maps a page hugetlb: add HGM support to __unmap_hugepage_range hugetlb: add HGM support to hugetlb_change_protection hugetlb: add HGM support to follow_hugetlb_page hugetlb: add HGM support to hugetlb_follow_page_mask hugetlb: add HGM support to copy_hugetlb_page_range hugetlb: add HGM support to move_hugetlb_page_tables hugetlb: add HGM support to hugetlb_fault and hugetlb_no_page hugetlb: use struct hugetlb_pte for walk_hugetlb_range mm: rmap: provide pte_order in page_vma_mapped_walk mm: rmap: update try_to_{migrate,unmap} to handle mapcount for HGM mm: rmap: in try_to_{migrate,unmap}, check head page for hugetlb page flags hugetlb: update page_vma_mapped to do high-granularity walks hugetlb: add high-granularity migration support hugetlb: sort hstates in hugetlb_init_hstates hugetlb: add for_each_hgm_shift hugetlb: userfaultfd: add support for high-granularity UFFDIO_CONTINUE hugetlb: add MADV_COLLAPSE for hugetlb hugetlb: add check to prevent refcount overflow via HGM hugetlb: remove huge_pte_lock and huge_pte_lockptr hugetlb: replace make_huge_pte with make_huge_pte_with_shift mm: smaps: add stats for HugeTLB mapping size hugetlb: x86: enable high-granularity mapping for x86_64 docs: hugetlb: update hugetlb and userfaultfd admin-guides with HGM info docs: proc: include information about HugeTLB HGM selftests/mm: add HugeTLB HGM to userfaultfd selftest KVM: selftests: add HugeTLB HGM to KVM demand paging selftest selftests/mm: add anon and shared hugetlb to migration test selftests/mm: add hugetlb HGM test to migration selftest selftests/mm: add HGM UFFDIO_CONTINUE and hwpoison tests Documentation/admin-guide/mm/hugetlbpage.rst | 4 + Documentation/admin-guide/mm/userfaultfd.rst | 8 +- Documentation/filesystems/proc.rst | 56 +- arch/alpha/include/uapi/asm/mman.h | 2 + arch/mips/include/uapi/asm/mman.h | 2 + arch/parisc/include/uapi/asm/mman.h | 2 + arch/powerpc/mm/pgtable.c | 6 +- arch/s390/include/asm/hugetlb.h | 5 - arch/s390/mm/gmap.c | 12 +- arch/x86/Kconfig | 1 + arch/xtensa/include/uapi/asm/mman.h | 2 + fs/Kconfig | 13 + fs/hugetlbfs/inode.c | 17 +- fs/proc/task_mmu.c | 190 ++- fs/userfaultfd.c | 14 +- include/asm-generic/hugetlb.h | 5 - include/asm-generic/tlb.h | 6 +- include/linux/huge_mm.h | 12 +- include/linux/hugetlb.h | 170 +- include/linux/mm.h | 7 + include/linux/pagewalk.h | 10 +- include/linux/rmap.h | 1 + include/linux/swapops.h | 8 +- include/trace/events/mmflags.h | 7 + include/uapi/asm-generic/mman-common.h | 2 + mm/damon/vaddr.c | 41 +- mm/debug_vm_pgtable.c | 2 +- mm/hmm.c | 20 +- mm/hugetlb.c | 1390 ++++++++++++++--- mm/khugepaged.c | 4 +- mm/madvise.c | 56 +- mm/memory-failure.c | 17 +- mm/mempolicy.c | 28 +- mm/migrate.c | 21 +- mm/mincore.c | 17 +- mm/mprotect.c | 18 +- mm/page_vma_mapped.c | 60 +- mm/pagewalk.c | 20 +- mm/rmap.c | 85 +- mm/userfaultfd.c | 40 +- .../selftests/kvm/demand_paging_test.c | 2 +- .../testing/selftests/kvm/include/test_util.h | 2 + .../selftests/kvm/include/userfaultfd_util.h | 6 +- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- tools/testing/selftests/kvm/lib/test_util.c | 14 + .../selftests/kvm/lib/userfaultfd_util.c | 14 +- tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/hugetlb-hgm.c | 608 +++++++ tools/testing/selftests/mm/migration.c | 229 ++- tools/testing/selftests/mm/userfaultfd.c | 84 +- 50 files changed, 2841 insertions(+), 502 deletions(-) create mode 100644 tools/testing/selftests/mm/hugetlb-hgm.c