From mboxrd@z Thu Jan 1 00:00:00 1970 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 D1BEBC433FE for ; Fri, 21 Oct 2022 16:38:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 467C88E0005; Fri, 21 Oct 2022 12:37:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C95B8E0001; Fri, 21 Oct 2022 12:37:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21B2E8E0005; Fri, 21 Oct 2022 12:37:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 02C4D8E0001 for ; Fri, 21 Oct 2022 12:37:56 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D25A11212F6 for ; Fri, 21 Oct 2022 16:37:55 +0000 (UTC) X-FDA: 80045513310.25.4BB2C64 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf16.hostedemail.com (Postfix) with ESMTP id 850EA180034 for ; Fri, 21 Oct 2022 16:37:55 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-36ab1ae386bso3394957b3.16 for ; Fri, 21 Oct 2022 09:37:55 -0700 (PDT) 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=u2L8dpQwPLEEtV1+N27Ru5/DaXt/OYV1HEOgWR9nKqQ=; b=hQEOt5qbhtIciEkifW3aJtfdGkwkMFYThz3+zH4m+l0DZeOwkOHljylI87o4133YIY +9qlJoQYYs5X58L9fVYGOUcAW3htdR4wJqVgJegiRWhoDZN6Hw6rLU1Q3Xarnd4Z6B2S 0Qm/YGHX8i6NhqgYKz1MbFHfMwocZZ13peTo4v5Lo7uK+rU6z8w5PasvDpHbgItoLjy/ kO/NxxIWM2aQQDZLQNut8OALQcGGq9dp7sd0njpT2gzPLMMoFH/CqGvCCb5bZ8st1noJ mGHFYBCd4aJ2Q+Rh1Ul7ceCnhLsZNJJXbbirMkaOkrcUY5VvqDaCqxSFUg1RZviE76DG R0lw== 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=u2L8dpQwPLEEtV1+N27Ru5/DaXt/OYV1HEOgWR9nKqQ=; b=5rFj6nDCzyMxSkheTqjEB45bB1ZF01WMYjNZmpC71gfTwMoNGkt1dTNh0LnmFCG59H OeyXdzI/JY21s8zuerBh9MFgVTPd7DjO3RA3vVdpNvSylKPCUcyzAL1t4LOrcac9jfHk FqNJmvLhZZ4J4tZz5t5QOnQeAsJxSxET0kCuCLl1sbatKftriGmpuDHmHQWTtBSES788 RjJzTFKUrsKjZMhKR66lImMiktl3my0YuDsl8xpwu7Vg3XTbDA2PZS5G5dRl5W2KsTK3 7b/ceL1HPMBQkoAOldyuVizaCv75mtUMxDmCJMvRm2nIqlLb5NNZVYIe70QSrYhIaZo9 YqIg== X-Gm-Message-State: ACrzQf2bCBrwxHO2mjfkkVATYGV4S2iTf8OlvQmFzCtou6qnM/Zxc18I sf4Oum/mCwAjCMv7GqZpapaNIVfDaXz3Zk+f X-Google-Smtp-Source: AMsMyM7qrRczE0kSxjQO7MrMYsn4Vq7Fy76rcBbW8wGxpKnFBq1NTfYQXCvfTxYgtyY5kNNK/TDw3Sq2i3AbtMvh X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:105:b0:6bc:fb54:f4da with SMTP id o5-20020a056902010500b006bcfb54f4damr17650934ybh.284.1666370275067; Fri, 21 Oct 2022 09:37:55 -0700 (PDT) Date: Fri, 21 Oct 2022 16:36:57 +0000 In-Reply-To: <20221021163703.3218176-1-jthoughton@google.com> Mime-Version: 1.0 References: <20221021163703.3218176-1-jthoughton@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221021163703.3218176-42-jthoughton@google.com> Subject: [RFC PATCH v2 41/47] 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 Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666370275; 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=u2L8dpQwPLEEtV1+N27Ru5/DaXt/OYV1HEOgWR9nKqQ=; b=2UqG7gGdq/m91lB7J8Z2aWamiJ/pj9GJ7MmkVFbS/hh7ntR8+BKD6z9cGR58fDARd4goae IFYpb/scJiqQpIBs/Cjf417AXT6whRS2jeaVfzlFhgy/+cta70kk3uCxRh3o9DGMVVsQy4 PwSZZiorMT2R7zK0yPIVaOk1df3y6+E= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hQEOt5qb; spf=pass (imf16.hostedemail.com: domain of 348pSYwoKCOQPZNUaMNZUTMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=348pSYwoKCOQPZNUaMNZUTMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666370275; a=rsa-sha256; cv=none; b=VeHUnJgepQm6CYeVA/6zbD0i04DgmhaI4TAbX50YfbGYaxXmNJ3GzYQXF8WpjkMegalrJv 3pBZmFPmmR3gKfQT+aWyqx3eLEEe2jW5CRqW8Ifj78WhoUMSnK/jO0NF9xwknswks4yoMr FDAy03ZW2Vd0PK2BLLYpvnh0gYKMyBk= X-Stat-Signature: zkm1eo1io8a6ripjprazcxdgx77fcs7t X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hQEOt5qb; spf=pass (imf16.hostedemail.com: domain of 348pSYwoKCOQPZNUaMNZUTMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=348pSYwoKCOQPZNUaMNZUTMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 850EA180034 X-HE-Tag: 1666370275-877795 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: -- 2.38.0.135.g90850a2211-goog