From patchwork Thu Jan 5 10:18:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13089673 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 3A672C3DA7D for ; Thu, 5 Jan 2023 10:19:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CD56940020; Thu, 5 Jan 2023 05:19:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 830FE940008; Thu, 5 Jan 2023 05:19:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 681CB940020; Thu, 5 Jan 2023 05:19:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 52AB7940008 for ; Thu, 5 Jan 2023 05:19:55 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 372C5140854 for ; Thu, 5 Jan 2023 10:19:55 +0000 (UTC) X-FDA: 80320349550.14.E87DC2A Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf07.hostedemail.com (Postfix) with ESMTP id 9E3774000C for ; Thu, 5 Jan 2023 10:19:53 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MCxyEzTT; spf=pass (imf07.hostedemail.com: domain of 3SKS2YwoKCI82C07Dz0C76z77z4x.v75416DG-553Etv3.7Az@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3SKS2YwoKCI82C07Dz0C76z77z4x.v75416DG-553Etv3.7Az@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672913993; a=rsa-sha256; cv=none; b=xoq1F9ev0S/Iyy+vhRqd3IYkeIiy9IJ/x8XBgNMXRzrrPsqJA6D0UFx/oFk9jaaajK4inY r81a/tY1wcuH5h6hnyy71V+ZydaAIYAO/qB/9qvR13AyBdIJF0QLXHkElJ4/o5ZcDpn9Vz YYKwCMnLg14SQ7b6imZ54lgixtfuIK8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MCxyEzTT; spf=pass (imf07.hostedemail.com: domain of 3SKS2YwoKCI82C07Dz0C76z77z4x.v75416DG-553Etv3.7Az@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3SKS2YwoKCI82C07Dz0C76z77z4x.v75416DG-553Etv3.7Az@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672913993; 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:in-reply-to:references:references:dkim-signature; bh=ksh61HdFJKW5FzhQ3xBVqQbws7N9eS43eLhKNpPeqew=; b=mmqgaAVbK9QTNVGo/uD/YTGCBTMvUxKAWiPO2hy8voW5jGM1ZJ6QROLxwDTDGxMI7l/JZP EOTaototAK2k84Ka683AkakNbEt6eaQiyTV9jyHOyrF6rrCDH03JoZU+rQoAVZxTP3A1SL jFXwJZx8K3UA/RNuJ8hhorI1x8GZfPQ= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-410f1a84ed2so372090297b3.15 for ; Thu, 05 Jan 2023 02:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ksh61HdFJKW5FzhQ3xBVqQbws7N9eS43eLhKNpPeqew=; b=MCxyEzTTO0yqg91shqPo6Ni+5EFzxsgTqYc3+pyMOGf0oatdr3BfMXYm2vwczO7xxN 6eXisofnTjW6ihZw5N2TmlX/02IpUvl2Obfz7KJBIRlML8eUYj2RVscTVOTPLqUOfEUl 7ALcPn6iafF/zuFvLcOWLr1Ggm27nMtZb4wuXZmie98LQOT+8Oo6f9LCBYicU9kTcsva a2UPiZZmZL+sjQYo2rL2gE+wftIxhHkEnB5vkmujJzydzSbw5WDTc7LnG3S0nQMS6Apd oD0DG4TxblVTSmtrDjw3jcw1qYcj6bz1oBV8ULyJY3Xpek6MnVH6iGGXHSiY51d0n8u/ xlOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ksh61HdFJKW5FzhQ3xBVqQbws7N9eS43eLhKNpPeqew=; b=Rj7hRGHF4jPhxyfStpltum7DLWoh0goYL8T2yN0dkxjsAn2NwKtnxZA+V9hOKTSrWN NkCViuCwIdmw4o1UkCzwO4hdjwg2nJiE1yqaf1k5zX84A0EuvioZbDcESnDTyOdmvuWq hePgNMY+ylNvy5Ia1yyjtUP12+m+2Mm7OlOQai/7haRI4hE5iSElT3DjHYZsRwXU64iT My4FLMoNwAGkObhCKkFKrsw0e493W4MHxxmIIsK8/9bS/dwac8y7MH+XwTeuWxgt5Ax9 gbGTnBPvntvPRgkGgiBF4w83Wqf7VA6/X75EgunXCZt0FvMJ3KM4E0Xk4U7NBl5Or7PZ 8JNw== X-Gm-Message-State: AFqh2kpO7QViu1ykjJR8w2BKJddjlBTjdRCE+EHmF5G3yy5pw8xubNgp 7sCLDjbfzrbVGM/eV/Z1bEp3vb6eprHO2gDY X-Google-Smtp-Source: AMrXdXuUdtLbHKVzfYol7vn49W5JNTDiD617kfFDgxP5DZEb9ADfn2YrSfngVZdq4KyN5rcGwmq3pEoz4PydDJ4S X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:1c17:0:b0:475:7911:2119 with SMTP id c23-20020a811c17000000b0047579112119mr5474920ywc.359.1672913992847; Thu, 05 Jan 2023 02:19:52 -0800 (PST) Date: Thu, 5 Jan 2023 10:18:38 +0000 In-Reply-To: <20230105101844.1893104-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230105101844.1893104-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230105101844.1893104-41-jthoughton@google.com> Subject: [PATCH 40/46] docs: hugetlb: update hugetlb and userfaultfd admin-guides with HGM info From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu 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 , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Rspam-User: X-Rspamd-Queue-Id: 9E3774000C X-Rspamd-Server: rspam01 X-Stat-Signature: ojfpqw4r9qnb48xjs8wgja7wroy47khc X-HE-Tag: 1672913993-23645 X-HE-Meta: U2FsdGVkX19bUmr1WytNF14q6IP7KFPZhKJHfr1ZZHze3ZNiF0+pAJlK4RkWyzZYS8ISxQj2z44R7er+4juqCriSwk76sT7Vzg2DFfWad2ne4Tqde1qtN64cXPANbC2mf9bslQZpHN/g0qgBxZTedllr92Q2G220lfbjpvyibjoBTrjijVvtB5nh/gjEOIi2GHs+3/sjK6ThOimUVlJigB8cSA1s5APVaP7XYgjsp3kTp0OLdntBKbEauM+OXkfYgata3N9XEnVfp9ty1aF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yfWEPrOpl+o5+LxRBMLkuEhCiIquS4= 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 includes information about how UFFD_FEATURE_MINOR_HUGETLBFS_HGM should be used and when MADV_COLLAPSE should be used with it. Signed-off-by: James Houghton --- Documentation/admin-guide/mm/hugetlbpage.rst | 4 ++++ Documentation/admin-guide/mm/userfaultfd.rst | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst b/Documentation/admin-guide/mm/hugetlbpage.rst index 19f27c0d92e0..ca7db15ae768 100644 --- a/Documentation/admin-guide/mm/hugetlbpage.rst +++ b/Documentation/admin-guide/mm/hugetlbpage.rst @@ -454,6 +454,10 @@ errno set to EINVAL or exclude hugetlb pages that extend beyond the length if not hugepage aligned. For example, munmap(2) will fail if memory is backed by a hugetlb page and the length is smaller than the hugepage size. +It is possible for users to map HugeTLB pages at a higher granularity than +normal using HugeTLB high-granularity mapping (HGM). For example, when using 1G +pages on x86, a user could map that page with 4K PTEs, 2M PMDs, a combination of +the two. See Documentation/admin-guide/mm/userfaultfd.rst. Examples ======== diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/admin-guide/mm/userfaultfd.rst index 83f31919ebb3..19877aaad61b 100644 --- a/Documentation/admin-guide/mm/userfaultfd.rst +++ b/Documentation/admin-guide/mm/userfaultfd.rst @@ -115,6 +115,14 @@ events, except page fault notifications, may be generated: areas. ``UFFD_FEATURE_MINOR_SHMEM`` is the analogous feature indicating support for shmem virtual memory areas. +- ``UFFD_FEATURE_MINOR_HUGETLBFS_HGM`` indicates that the kernel supports + small-page-aligned regions for ``UFFDIO_CONTINUE`` in HugeTLB-backed + virtual memory areas. ``UFFD_FEATURE_MINOR_HUGETLBFS_HGM`` and + ``UFFD_FEATURE_EXACT_ADDRESS`` must both be specified explicitly to enable + this behavior. If ``UFFD_FEATURE_MINOR_HUGETLBFS_HGM`` is specified but + ``UFFD_FEATURE_EXACT_ADDRESS`` is not, then ``UFFDIO_API`` will fail with + ``EINVAL``. + The userland application should set the feature flags it intends to use when invoking the ``UFFDIO_API`` ioctl, to request that those features be enabled if supported. @@ -169,7 +177,13 @@ like to do to resolve it: the page cache). Userspace has the option of modifying the page's contents before resolving the fault. Once the contents are correct (modified or not), userspace asks the kernel to map the page and let the - faulting thread continue with ``UFFDIO_CONTINUE``. + faulting thread continue with ``UFFDIO_CONTINUE``. If this is done at the + base-page size in a transparent-hugepage-eligible VMA or in a HugeTLB VMA + (requires ``UFFD_FEATURE_MINOR_HUGETLBFS_HGM``), then userspace may want to + use ``MADV_COLLAPSE`` when a hugepage is fully populated to inform the kernel + that it may be able to collapse the mapping. ``MADV_COLLAPSE`` will may undo + the effect of any ``UFFDIO_WRITEPROTECT`` calls on the collapsed address + range. Notes: