From patchwork Sat Feb 18 00:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13145406 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 F2625C636D6 for ; Sat, 18 Feb 2023 00:29:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BF7F280025; Fri, 17 Feb 2023 19:29:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3972E280002; Fri, 17 Feb 2023 19:29:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D5F7280025; Fri, 17 Feb 2023 19:29:28 -0500 (EST) 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 E953D280002 for ; Fri, 17 Feb 2023 19:29:27 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CCD5B1A050F for ; Sat, 18 Feb 2023 00:29:27 +0000 (UTC) X-FDA: 80478528774.09.70BB1AF Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 2281F180009 for ; Sat, 18 Feb 2023 00:29:24 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jBDVTyUi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 35BvwYwoKCAMmwkrxjkwrqjrrjoh.frpolqx0-ppnydfn.ruj@flex--jthoughton.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=35BvwYwoKCAMmwkrxjkwrqjrrjoh.frpolqx0-ppnydfn.ruj@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676680165; 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=meim6QzwmgVJzeI2+Wk1IxU1uXO2GoWG7kArQ5zE/oE=; b=w0PpZbL3nSjpNs9GlRR0jW8Jj5qnDQCF7YETATU/rGB0zdU06JYlN+hkstULxfCf29E2FI 9ESsI3UfvxiAslY7pqkvd/e6dptmbr8TJWdI2VUBbKkIHgLVN1q3Ti5HWEKci1Ulp7aZZv L7nip3z+sCuT/HbcCJGZmfb0cCCx+us= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jBDVTyUi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 35BvwYwoKCAMmwkrxjkwrqjrrjoh.frpolqx0-ppnydfn.ruj@flex--jthoughton.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=35BvwYwoKCAMmwkrxjkwrqjrrjoh.frpolqx0-ppnydfn.ruj@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680165; a=rsa-sha256; cv=none; b=j/7LlhgME/pWJljLdOqUegpF9/bd+rc+anwWj++4N66lb7rJQyZw7bydo4YDDs9mgjRsu7 CcbO0Y6VQE6bCxfkDE/s3Nw+vP94uuW/N1eEoAG5rKnteatczHKjmkWvcoJJy/rzC/J2jS jopLFFRZCRQmy73ES5v9pa731yf7rTA= Received: by mail-yb1-f201.google.com with SMTP id l14-20020a056902072e00b008fa1d22bd55so1847441ybt.21 for ; Fri, 17 Feb 2023 16:29:24 -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=meim6QzwmgVJzeI2+Wk1IxU1uXO2GoWG7kArQ5zE/oE=; b=jBDVTyUiFjSinjlesXO7Wsr29fC05xWRfrl7nAZ2Vi6vctWsz/7+NsXy6Dx9zE02oD Zi9rU6CuILwSQ9MmYCjyB8BnkobSNAXN9wk5uSKN5uHSYEobIzebiBr+QJLAoe2BO2h7 BvQ5nLWnyJ34pOp7tHtrWAltvM5a5A6wWV9ntVMJs7Np7CHhXIh92iq7fs97WdSGdx7k chX9KZzHAChL7Krh0NrLbnAxcDgyvNutktvSzeK5qogN04D9EfgapHMPtcUexRrTONeu Lv9LpAtAQc7gW1fQL5eLIT4qqKfM5pCyZOYdI8D3vWXHR6ii/aIgrxnOVziUFMcqw1D2 IOGw== 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=meim6QzwmgVJzeI2+Wk1IxU1uXO2GoWG7kArQ5zE/oE=; b=zkyE5a2V+Jp/RRDUSJizNF7YJa2m5+PBW/2gbxmV31CZbteNdt0DM0E0oOe/Nq4KhH j405QBI15SKaaQgVAr1ofO1F/r9HbuGYJg3iIxQWLR/yvoDKHWsY8RZljtBzBpOp1ScK oswMmHCbMqCSIWvWWlYZwbSx+n9BCfP3XKPjcSRiCtKWZijHEMfvX4oOI+cqBOAcES/o D96aubx2wwpiJhL8aP+kz6UFVMOEdxQUmE3UID+0TcuR/BczOqTpv67lpsmjakcRuhYx t1dZBtJwKx+p9zre7L8pvOxD+aMNWAOGbXSsEeLwsij0T49WxrtCXdSNTJ6WMAH0nEFt X0nA== X-Gm-Message-State: AO0yUKW2JkLp3ecPPKEhJZZwTNGUspxW2Q8wcZrCMGgQcmerxpPzyKTY PnBmECbDoOI/bc8y5AFPCYjfuhh18OBdrByZ X-Google-Smtp-Source: AK7set8GEY/pRGyIuQeSw27GrNwKq4LLQxkMXSq0msXVI/vUEuxHEPRagJyvSuTMY/SNITKnNSR3i2I9F+YeDJM+ X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a5b:144:0:b0:91c:90b6:f48a with SMTP id c4-20020a5b0144000000b0091c90b6f48amr1373069ybp.580.1676680164340; Fri, 17 Feb 2023 16:29:24 -0800 (PST) Date: Sat, 18 Feb 2023 00:28:13 +0000 In-Reply-To: <20230218002819.1486479-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230218002819.1486479-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230218002819.1486479-41-jthoughton@google.com> Subject: [PATCH v2 40/46] docs: hugetlb: update hugetlb and userfaultfd admin-guides with HGM info 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: 2281F180009 X-Stat-Signature: tqe551hh3io63ihcrafyrw3oab3x388y X-HE-Tag: 1676680164-57331 X-HE-Meta: U2FsdGVkX18TYctr32ckVNfgXEIUnHRD0UscQ3Cvui3hqUl56NCZcvUD/ziwFOSlrX7ct8znfirodgPWpxdj815Krc7osumE6G08FzXguNYLCaxc8miflDVpv136XTZGO94+Bz6PgHAbPmNwNnU7HnX2QMesyJy202sWVNDxFCmA+MRm5BSUcU8T5J8P8bhrDEmNYNzG4kYDVSonjpL1T/UyfYloPb1P/k2p5PsvLEFs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RXckTxzVDNiJ8ty46269o1yAC8DhFpY4Fk1AubfZZVZ4QpU3PnReohabCXRVmLBjcU04x2XOAEBGt9DtmFrP6XFf/6Q2D7/tybc8/Lt2Fm3WWV/sJED/noaaIRIzWv5N3a+ICxvheeTzt+n6PuvqCs87H6Ec/FJIRhebs1Ek1ztfNfKbSX+kbt0GYXDsMKGad91huX2q3K71bmLuroweJZ5YAsotTyAg73GZZtk4Sm1GoG1LXCV9GsNp7LS/LPTQ== 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: Include information about how MADV_SPLIT should be used to enable high-granularity UFFDIO_CONTINUE operations, and include information about how MADV_COLLAPSE should be used to collapse the mappings at the end. Signed-off-by: James Houghton diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst b/Documentation/admin-guide/mm/hugetlbpage.rst index a969a2c742b2..c6eaef785609 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..cc496a307ea2 100644 --- a/Documentation/admin-guide/mm/userfaultfd.rst +++ b/Documentation/admin-guide/mm/userfaultfd.rst @@ -169,7 +169,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 ``MADV_SPLIT``), 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 undo + the effect of any ``UFFDIO_WRITEPROTECT`` calls on the collapsed address + range. Notes: