From patchwork Mon Mar 6 23:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13162511 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 9D8C3C61DA4 for ; Mon, 6 Mar 2023 23:00:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E087280002; Mon, 6 Mar 2023 18:00:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 16A2D280001; Mon, 6 Mar 2023 18:00:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E87E8280002; Mon, 6 Mar 2023 18:00:14 -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 CE601280001 for ; Mon, 6 Mar 2023 18:00:14 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 912C2120D21 for ; Mon, 6 Mar 2023 23:00:14 +0000 (UTC) X-FDA: 80539993548.29.4578637 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf20.hostedemail.com (Postfix) with ESMTP id B8EEF1C0026 for ; Mon, 6 Mar 2023 23:00:12 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CA7NJzzA; spf=pass (imf20.hostedemail.com: domain of 3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@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=1678143612; 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=0jScJs8gPXRLiSO6nJC4f1UlDdjOsBUk8woW1tgEqwQ=; b=R9XAy8Mu6mRAzmxl5/0SnR6rHtz3Iy7L2QWd1wHDCrpWmGAClO7dQeyJD85dti78tFI1pM BGImxRllztjwP8t5NN2EYWxdE2fJL642I02MrfdxgPVs2rMVdS3lgqO8euRJ9nVPfex9I6 Sz5d5mTvJ+bJ3iuXjcfPljiN2bZQvNU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CA7NJzzA; spf=pass (imf20.hostedemail.com: domain of 3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678143612; a=rsa-sha256; cv=none; b=GJJ6AEyUy8MGFTXycD9qizIJlgiJA5V3AqRIpi+/guDW8wla56MQTph+RAUoNxJWYrNE9G sGDnFt9MHMUKggedP5uQLH2vbSoYTMQAurNxaFs5qZSlLutZfTUsSy+otFgD9xf9+x9O+b VCyE0cc6VieQTWqV7RoeFPG6GF8+pq4= Received: by mail-yb1-f201.google.com with SMTP id m202-20020a2526d3000000b00ae90d688ab4so12009637ybm.5 for ; Mon, 06 Mar 2023 15:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678143612; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0jScJs8gPXRLiSO6nJC4f1UlDdjOsBUk8woW1tgEqwQ=; b=CA7NJzzABDuyMIx39yOVjD21ZazHLorgmgYJs4KgfHCpwfeQmmuT82P7+v0L3PDuOx +K+K6CXCu5109HuQycvHX4rNE+5yUkqzz7V5wjda3TF59JpZBwR5LMmISRtqmwD/HN+T ZdW0MWMPZEpd7l8FJtBIGTBAXEg57BN5Mc5nCohnUPmoUs3BwPLkTWyvSCp8TfhkrJ3N aEH2Pet/7Pykpn6PU2oKL/9mdp5vBBduTXvq9sgjipXTJycSyVdMfrIpWUQoivnDKfpT pLKYm+C7JsL/ywpCGZh8qcyRRbEaMfY+ds2x/8xEHrZ5RzxgvfbXGS0JaZN4c7kW+S1S iorw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678143612; 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=0jScJs8gPXRLiSO6nJC4f1UlDdjOsBUk8woW1tgEqwQ=; b=OBmC9Rwrv/4A7ojBNoEX1nEFI51LgOpKo5WEVvBMe9fDeYKsqQbFUSAqmoV5X8VEPX +SM4FVfUu5O0fhTXEtJlXVB6TGeB6uIl3VC8FIO2MlznQvXiBKzyNCQuR0mJhPA6Drg1 Q4xDQ5oW2an4YI+K7BR91Kj6nltMR8QZW6puw9zdR5Ef8fSiwl9bgVhl4c1ZzHqs7w27 m2QC7XvJSpHdRdYvvglfn9iov/+6cMYabsjKgyTOhgDr00pWMJW4ymsRo5chcSXQLk6R 14FCDt6umG8dRlO2eFtsOrUQHe4exlVjXocfH5VyHtpqkdhrIb+BU/vC5lPovC3nvxCu nRqw== X-Gm-Message-State: AO0yUKVI1GKLNbQrU6cIYkwhSh38RPjiVKm7Ef7GwcMbCruDe57ueeFk dVzVIgGBZQ7qUyyRSuYNCUzsnPkP8HcenLnF X-Google-Smtp-Source: AK7set8+h6XVzMynblTqho9bgX5+xF0hOFYOMqIT0/C64hcBJetdsYtWLYMthVmrbzbpZLQWnVDBI1Sfi4C4coRB X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a5b:1cb:0:b0:aa2:475c:2982 with SMTP id f11-20020a5b01cb000000b00aa2475c2982mr5814442ybp.1.1678143611858; Mon, 06 Mar 2023 15:00:11 -0800 (PST) Date: Mon, 6 Mar 2023 23:00:03 +0000 In-Reply-To: <20230306230004.1387007-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230306230004.1387007-1-jthoughton@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306230004.1387007-2-jthoughton@google.com> Subject: [PATCH 1/2] mm: rmap: make hugetlb pages participate in _nr_pages_mapped From: James Houghton To: Mike Kravetz , Hugh Dickins , Muchun Song , Peter Xu , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: "Kirill A . Shutemov" , David Hildenbrand , David Rientjes , Axel Rasmussen , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: mciw8druk3bgmksareutqjky3p4ou365 X-Rspamd-Queue-Id: B8EEF1C0026 X-HE-Tag: 1678143612-95888 X-HE-Meta: U2FsdGVkX1/ygSKil+YPEHgi7QTkNJHXWTVjTNf/VQyCsGykVtDnksOItpmvrtBfL1Ge7exWERZHBkECLo/OetfQwCUZvLhJlS5COoouTUzTA3k1cvhHeXkQC1RKORQ5tyuYYfspG4T+i2ymL4dJvivyGAgHiB1NNghdEvBV3qI5N+wOZEfTjzb3zAprK6rUzCXDNKYpw6BMYEynNQRa/sUsxT48urcjB6t8qpVmqq7ooO6tdYwtvIol6mK2d+QBmw8fPSpF8M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at0N7AvZcOJDLAEn84C78NQMcl0iXZwX7BaBoR24Es70kqm/Lz6IJadSL3xgeamk02chOCUXBzdyoaxvRvrgd1RUfh1o9ApBVW6y+FShALy2TxRLSaKUGxU7zKrLto3ri51OtDYkVGOLxDA44PZfniUKohk8cZ7e6qaC4yaEF8W4zdPutqYjKKSRY4VY9IYNExRBrMdYqj9csU3L6i0P53YPgL/OfS+X8x3pCeqQdlgeUnzglgpr914ePjmoihBqy2NUQ2XHlkTTQFYoBN744qEKp2OEYHBad7GKROqxDy3SCyVSPYZpUNoJinhjdewcEfA1hXs/KnzEJMz2/zFIGibihh8Sud7TTuC3B4s/H5h1HTU= 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: For compound mappings (compound=true), _nr_pages_mapped will now be incremented by COMPOUND_MAPPED when the first compound mapping is created. For small mappings, _nr_pages_mapped is incremented by 1 when the particular small page is mapped for the first time. This is incompatible with HPageVmemmapOptimize()ed folios, as most of the tail page structs will be mapped read-only. Currently HugeTLB always passes compound=true, but in the future, HugeTLB pages may be mapped with small mappings. To implement this change: 1. Replace most of HugeTLB's calls to page_dup_file_rmap() with page_add_file_rmap(). The call in copy_hugetlb_page_range() is kept. 2. Update page_add_file_rmap() and page_remove_rmap() to support HugeTLB folios. 3. Update hugepage_add_anon_rmap() and hugepage_add_new_anon_rmap() to also increment _nr_pages_mapped properly. With these changes, folio_large_is_mapped() no longer needs to check _entire_mapcount. HugeTLB doesn't use LRU or mlock, so page_add_file_rmap() and page_remove_rmap() excludes those pieces. It is also important that the folio_test_pmd_mappable() check is removed (or changed), as it's possible to have a HugeTLB page whose order is not >= HPAGE_PMD_ORDER, like arm64's CONT_PTE_SIZE HugeTLB pages. This patch limits HugeTLB pages to 16G in size. That limit can be increased if COMPOUND_MAPPED is raised. Signed-off-by: James Houghton Acked-by: Mike Kravetz diff --git a/include/linux/mm.h b/include/linux/mm.h index ce1590933995..25c898c51129 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1143,12 +1143,7 @@ static inline int total_mapcount(struct page *page) static inline bool folio_large_is_mapped(struct folio *folio) { - /* - * Reading _entire_mapcount below could be omitted if hugetlb - * participated in incrementing nr_pages_mapped when compound mapped. - */ - return atomic_read(&folio->_nr_pages_mapped) > 0 || - atomic_read(&folio->_entire_mapcount) >= 0; + return atomic_read(&folio->_nr_pages_mapped) > 0; } /** diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 07abcb6eb203..bf3d327cd1b9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5911,7 +5911,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, if (anon_rmap) hugepage_add_new_anon_rmap(folio, vma, haddr); else - page_dup_file_rmap(&folio->page, true); + page_add_file_rmap(&folio->page, vma, true); new_pte = make_huge_pte(vma, &folio->page, ((vma->vm_flags & VM_WRITE) && (vma->vm_flags & VM_SHARED))); /* @@ -6293,7 +6293,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, goto out_release_unlock; if (folio_in_pagecache) - page_dup_file_rmap(&folio->page, true); + page_add_file_rmap(&folio->page, dst_vma, true); else hugepage_add_new_anon_rmap(folio, dst_vma, dst_addr); diff --git a/mm/internal.h b/mm/internal.h index fce94775819c..400451a4dd49 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -55,8 +55,7 @@ void page_writeback_init(void); /* * If a 16GB hugetlb folio were mapped by PTEs of all of its 4kB pages, * its nr_pages_mapped would be 0x400000: choose the COMPOUND_MAPPED bit - * above that range, instead of 2*(PMD_SIZE/PAGE_SIZE). Hugetlb currently - * leaves nr_pages_mapped at 0, but avoid surprise if it participates later. + * above that range, instead of 2*(PMD_SIZE/PAGE_SIZE). */ #define COMPOUND_MAPPED 0x800000 #define FOLIO_PAGES_MAPPED (COMPOUND_MAPPED - 1) diff --git a/mm/migrate.c b/mm/migrate.c index 476cd24e8f32..c95c1cbc7a47 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -254,7 +254,7 @@ static bool remove_migration_pte(struct folio *folio, hugepage_add_anon_rmap(new, vma, pvmw.address, rmap_flags); else - page_dup_file_rmap(new, true); + page_add_file_rmap(new, vma, true); set_huge_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte); } else #endif diff --git a/mm/rmap.c b/mm/rmap.c index ba901c416785..4a975429b91a 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1316,19 +1316,21 @@ void page_add_file_rmap(struct page *page, struct vm_area_struct *vma, int nr = 0, nr_pmdmapped = 0; bool first; - VM_BUG_ON_PAGE(compound && !PageTransHuge(page), page); + VM_BUG_ON_PAGE(compound && !PageTransHuge(page) + && !folio_test_hugetlb(folio), page); /* Is page being mapped by PTE? Is this its first map to be added? */ if (likely(!compound)) { + if (unlikely(folio_test_hugetlb(folio))) + VM_BUG_ON_PAGE(HPageVmemmapOptimized(&folio->page), + page); first = atomic_inc_and_test(&page->_mapcount); nr = first; if (first && folio_test_large(folio)) { nr = atomic_inc_return_relaxed(mapped); nr = (nr < COMPOUND_MAPPED); } - } else if (folio_test_pmd_mappable(folio)) { - /* That test is redundant: it's for safety or to optimize out */ - + } else { first = atomic_inc_and_test(&folio->_entire_mapcount); if (first) { nr = atomic_add_return_relaxed(COMPOUND_MAPPED, mapped); @@ -1345,6 +1347,9 @@ void page_add_file_rmap(struct page *page, struct vm_area_struct *vma, } } + if (folio_test_hugetlb(folio)) + return; + if (nr_pmdmapped) __lruvec_stat_mod_folio(folio, folio_test_swapbacked(folio) ? NR_SHMEM_PMDMAPPED : NR_FILE_PMDMAPPED, nr_pmdmapped); @@ -1373,24 +1378,18 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma, VM_BUG_ON_PAGE(compound && !PageHead(page), page); - /* Hugetlb pages are not counted in NR_*MAPPED */ - if (unlikely(folio_test_hugetlb(folio))) { - /* hugetlb pages are always mapped with pmds */ - atomic_dec(&folio->_entire_mapcount); - return; - } - /* Is page being unmapped by PTE? Is this its last map to be removed? */ if (likely(!compound)) { + if (unlikely(folio_test_hugetlb(folio))) + VM_BUG_ON_PAGE(HPageVmemmapOptimized(&folio->page), + page); last = atomic_add_negative(-1, &page->_mapcount); nr = last; if (last && folio_test_large(folio)) { nr = atomic_dec_return_relaxed(mapped); nr = (nr < COMPOUND_MAPPED); } - } else if (folio_test_pmd_mappable(folio)) { - /* That test is redundant: it's for safety or to optimize out */ - + } else { last = atomic_add_negative(-1, &folio->_entire_mapcount); if (last) { nr = atomic_sub_return_relaxed(COMPOUND_MAPPED, mapped); @@ -1407,6 +1406,9 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma, } } + if (folio_test_hugetlb(folio)) + return; + if (nr_pmdmapped) { if (folio_test_anon(folio)) idx = NR_ANON_THPS; @@ -2541,9 +2543,11 @@ void hugepage_add_anon_rmap(struct page *page, struct vm_area_struct *vma, first = atomic_inc_and_test(&folio->_entire_mapcount); VM_BUG_ON_PAGE(!first && (flags & RMAP_EXCLUSIVE), page); VM_BUG_ON_PAGE(!first && PageAnonExclusive(page), page); - if (first) + if (first) { + atomic_add(COMPOUND_MAPPED, &folio->_nr_pages_mapped); __page_set_anon_rmap(folio, page, vma, address, !!(flags & RMAP_EXCLUSIVE)); + } } void hugepage_add_new_anon_rmap(struct folio *folio, @@ -2552,6 +2556,7 @@ void hugepage_add_new_anon_rmap(struct folio *folio, BUG_ON(address < vma->vm_start || address >= vma->vm_end); /* increment count (starts at -1) */ atomic_set(&folio->_entire_mapcount, 0); + atomic_set(&folio->_nr_pages_mapped, COMPOUND_MAPPED); folio_clear_hugetlb_restore_reserve(folio); __page_set_anon_rmap(folio, &folio->page, vma, address, 1); } From patchwork Mon Mar 6 23:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13162512 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 30402C6FD1A for ; Mon, 6 Mar 2023 23:00:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDB77280003; Mon, 6 Mar 2023 18:00:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E3B9F280001; Mon, 6 Mar 2023 18:00:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6706280003; Mon, 6 Mar 2023 18:00:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A7654280001 for ; Mon, 6 Mar 2023 18:00:15 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5DA71160C46 for ; Mon, 6 Mar 2023 23:00:15 +0000 (UTC) X-FDA: 80539993590.15.0135663 Received: from mail-vs1-f73.google.com (mail-vs1-f73.google.com [209.85.217.73]) by imf20.hostedemail.com (Postfix) with ESMTP id 972A51C001B for ; Mon, 6 Mar 2023 23:00:13 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qvAewIdd; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3fHAGZAoKCJ0GQELRDEQLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jthoughton.bounces.google.com designates 209.85.217.73 as permitted sender) smtp.mailfrom=3fHAGZAoKCJ0GQELRDEQLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678143613; 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=hIx3kaJ7v5MfcJ3bC83E2C9/NBXIacneT6tynRm3EnA=; b=LjjFS/qgg5/FQCph2nQyrB4uEc8VCQhETrjh4DtMeW60y7PZCdjVP8YeyZp1ZCcYLnVti5 FGaaQgSqkJatLIE+aErwj6BPwl/IiUu10LA76TPV9VYK5FE9pQlp+4kuOFXn/vJ/KyO8I4 /wbmJ/me011kNmlxGU7vlswB4WL8kas= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qvAewIdd; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3fHAGZAoKCJ0GQELRDEQLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jthoughton.bounces.google.com designates 209.85.217.73 as permitted sender) smtp.mailfrom=3fHAGZAoKCJ0GQELRDEQLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678143613; a=rsa-sha256; cv=none; b=vhaKqGib7lBMfecTrbbM76uZ4ERlqGdef8XpmkYkaa7bM/S/G0HzstmW771FEisa8UplkF g5V75H/3OM647AuSKpOyp4QIeYmYHhDvrZmh7znl8jqfN9meFwKknpVSIFaDHJMn28qlDa HLaOWyGu5I2Azv3WrRWdS0TkCviLsBo= Received: by mail-vs1-f73.google.com with SMTP id v13-20020a0561020f0d00b0041f24dc9c47so3856745vss.9 for ; Mon, 06 Mar 2023 15:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678143612; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hIx3kaJ7v5MfcJ3bC83E2C9/NBXIacneT6tynRm3EnA=; b=qvAewIddK0QuhCdcxur8X/IPKYUlFdGMwHQ7wfqwcDsA+ABbNXYVt7Xpud40PyavmQ IgS0CnzzxQ+sURvHsBxhn6GPimrIzKhfHCMChWPpYFWrjeNJ7XSWoE70RERcx6Z4TZ31 Bj3E+88BJofX7eT4wjNwD6s4Tx7DTBBBF/5xs9U7P8rvtXXYIlfW3ttOVJ5Zx1beuTvM TqsqrigZMh7wFnRxKO0xdlf2NGmbwV2th7ywzvaTiOqCG5bnzZXoB7p+fVW1yLJQkwTL bGvPzcmjgTxl+W/H7JWrIJU/d/ADu31M5bVostl04gzRlaNtJrzUFBuglPdaHCUlbFJE UsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678143612; 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=hIx3kaJ7v5MfcJ3bC83E2C9/NBXIacneT6tynRm3EnA=; b=f6Z2wozhO8FDk0+gU8pO0f+yZksCf/eX/GUZW0JXk2EZksDiL1lw8KDichE2t1Z5HX F10mDLMvpKY1C8YebtZ5pVXR0OlkFNWcyFSIWShoRyfUcgwlqk/NaEhGEbUVPlnK7SYy tr1uJk5pN1o8DudPROJNDxHbsWH/FNSwQ8ZoYjK6FzKRRuMcDG4QEIg7FWYigJZlPrvY hXbn2bOjyNpjkXYgTX/a0HOgBWQoN8DLNk3KKovlKl5tbR3+H/fh4lf2d8lZInD9TP2G qODk0Z/2PgPkN9HjX9/B5NmffyyVqAbgax6eKTxA7l4HunRXsyIXqSuW87WPiU84ykuX IGPQ== X-Gm-Message-State: AO0yUKXEkKtFHfyGY65+5NGT1pl9De2RetbSn1An+MAvCaYyLe0Z7RF1 oLFoRD7wLaCUxS4ETDBaPWz9m47FEmaxOzUV X-Google-Smtp-Source: AK7set910gI7f4wEAiHLGM5tPuw0JcdSRnZOvRyh4XmPDvpbk+ahzqZvHdoFgr9rOMIgHs0nPGCKWy/u/Ys/1cG8 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a67:d583:0:b0:411:fff6:3cc4 with SMTP id m3-20020a67d583000000b00411fff63cc4mr8672319vsj.3.1678143612654; Mon, 06 Mar 2023 15:00:12 -0800 (PST) Date: Mon, 6 Mar 2023 23:00:04 +0000 In-Reply-To: <20230306230004.1387007-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230306230004.1387007-1-jthoughton@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306230004.1387007-3-jthoughton@google.com> Subject: [PATCH 2/2] mm: rmap: increase COMPOUND_MAPPED to support 512G HugeTLB pages From: James Houghton To: Mike Kravetz , Hugh Dickins , Muchun Song , Peter Xu , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: "Kirill A . Shutemov" , David Hildenbrand , David Rientjes , Axel Rasmussen , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Rspamd-Queue-Id: 972A51C001B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: nre75bx31nqi1euki3exf7irodsbeiwf X-HE-Tag: 1678143613-769653 X-HE-Meta: U2FsdGVkX18LfJNyX5iQ7C6uHEHTC3538wCy5RreNDaS+gRXWWy83k2s1bsNS4GqD3xd/hxp705Ouv98I4JuK2hMcBOJbWh6/2qgOwUCdE7yfX04QEipGmsL+f2vuLHeqDmKWe3qfJ8ChPEIHLtIGV94QvtesqdCQEuKmy8Ytc3kCwDeJ9caksrYofI76+QGtQH9KhcRnsRHgGQnh1EOjvxgTpRVxrn8KDszckUDfUL74Diovnp+4k+zEMues/oN2Ery9jBquxnSYLwdpNNo3QPnHaoRhkoPdTxwpasjdlQzzoNrhAO3NdRIDIYebHF/dN5dlv0bREIeDixydwr2UgS9Jbf/uY21Sa/sxehmFtuzUtC9otyx27HEFmTie0YVIGJaOY6dBDV2JfUyFRgbfTiP4zlfNwtmCg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Uwklp7pyMR4OdtEyOrP3/PRXHPKazNOk57Of32fD545sp8R2fwobLH4ix9s3rcPx3aKGKDFEf7lX1EmE/Ygz5SkBqH5xQokeMqA/lvm7ZDQHF4VG9OBjk5/sbDJEpe0CPG67tHMYQ0/uCUi5MrRXTuzi9WB7k/OsLUC736CIaz+f5BZc05yWQ19dFGDqO6jgnUrqtKmu6Pt7R5w= 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: Some architectures may want to support 512G HugeTLB pages in the future. Adjust COMPOUND_MAPPED to support this page size. Signed-off-by: James Houghton diff --git a/mm/internal.h b/mm/internal.h index 400451a4dd49..994381fd5155 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -53,11 +53,11 @@ struct folio_batch; void page_writeback_init(void); /* - * If a 16GB hugetlb folio were mapped by PTEs of all of its 4kB pages, - * its nr_pages_mapped would be 0x400000: choose the COMPOUND_MAPPED bit - * above that range, instead of 2*(PMD_SIZE/PAGE_SIZE). + * If a 512G hugetlb folio were mapped by PTEs of all of its 4kB pages, + * its nr_pages_mapped would be 2^27 (0x8000000): choose the COMPOUND_MAPPED bit + * above that range. */ -#define COMPOUND_MAPPED 0x800000 +#define COMPOUND_MAPPED (1 << 28) #define FOLIO_PAGES_MAPPED (COMPOUND_MAPPED - 1) /*