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: 65165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2125947wrd; Mon, 6 Mar 2023 15:15:14 -0800 (PST) X-Google-Smtp-Source: AK7set+hRXmrM8O6Va8Zt92Aw0mMRbyod+EqU4auQKd62VQjacZJSbpZClPjlIGUXhRga8kie583 X-Received: by 2002:a17:906:99c6:b0:8de:920d:a4bb with SMTP id s6-20020a17090699c600b008de920da4bbmr12795977ejn.26.1678144513926; Mon, 06 Mar 2023 15:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678144513; cv=none; d=google.com; s=arc-20160816; b=os3zt4IsJf7N8rRmjHWeFVGYKPaolVMBADQ31N1CciQZgu3jr4AwX3VRLpSz2ynt9r 57nAyZ6hpkit46hmjO5b7iDZkxeEonVSkw9uOJrseFFGaM/YAwOwAJ03Plt9/BI8an2m 2qnwwqz+ER+5TDRm/291gJ60UqzkhEQEWdKOg+IS5mxDaqNQH2bWwXC3I1Mcv7rq5FMl 5Ee8vqYqScFyMbg52bOfxswWKIVN8akR2603L7Wm2FLeem/gmgcQQCzCSnqrYRyk5G/i 57ZRJTdklvaHZNx8wE55h2yc4MLJVyCu3SdxOG0WQ6Tfv+OieMAXyxg8pmd2gHmGWlLA agng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=0jScJs8gPXRLiSO6nJC4f1UlDdjOsBUk8woW1tgEqwQ=; b=PEvBghaTE0p63o8yfVewRv0b/PtjFjT/OGg6i0o6vaTfJCFNIQz/mn1X5xRnymdJ2m fzdHl49DsUfWsGHKebOEh6RtzYteAtVhZrzAOD9poSN0Y8M3fcPzZjV2YpQIJjYFb12v ytZfO8SJghUM6XcB8GGJhytadNixzA2E5+5hfFP5rdjeveoa7zkC0Md1J3+a6+Q52Toj 3O2m6pTsPi42e6PS7cLtzzbxDlOMRgQi1VpYycx/B16uc8UXBqzsrV0Y1tbGMWXgck79 AE2BkO+XgNvXCgC+GdsVKQh69qEwMf6EKsITvM1YHycR5d0qHtK6OMjPpqGOxul2Nkd7 771g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CA7NJzzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a170906520b00b008d06906f662si10094149ejm.666.2023.03.06.15.14.49; Mon, 06 Mar 2023 15:15:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CA7NJzzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbjCFXAX (ORCPT + 99 others); Mon, 6 Mar 2023 18:00:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjCFXAU (ORCPT ); Mon, 6 Mar 2023 18:00:20 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0896580E9 for ; Mon, 6 Mar 2023 15:00:12 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536c525d470so117563117b3.18 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=UiKY+R73TQk5TNJ5b37zulWFj49TFeolq6y0W4C6bZX7UX4NtZ5Tq5t/3g8V7bGGU+ Oh08dpSpqbicLgLTkBVnyZTlNQxcojnFY/pCCkzlxOB8DtEPZ5kitfdw9dBEBNpM7uCz zRokz6Pzudy5UrtJSTjTNIw0FYYySFv1zZ75jtSmc/lFaB4LPckBBWDJeJXR2Dju+XxJ pNg4jnvWx4MkoY0In0x6842xL66hzX1ie2D/Mh18gSNfjj8fBFRcZ1itlSSV5hGhtwd9 H04UspnlOa6mwY3hDMHSnw8rLrRftxG6ZhXOr6De2sqsJymrmUDyeA2Q9bHbBsVRdkk8 9iNg== X-Gm-Message-State: AO0yUKUidfHt5YzXKrhT8lfSUExeerqyNcLR53fDBjUQKJCApaYCG5wK 9xtPKHX4o9SmNWd4Fzw9K4KHIEkaA5BKZOif 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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759662061581283574?= X-GMAIL-MSGID: =?utf-8?q?1759662061581283574?= 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: 65170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2126899wrd; Mon, 6 Mar 2023 15:17:27 -0800 (PST) X-Google-Smtp-Source: AK7set+EgnO6XF9zgK2e7wFNdaDBFkCjpHaYKsm90ntTIlXA1v7huPgEc7u59UhIGBQU48nIyY0a X-Received: by 2002:a17:907:6eac:b0:8b1:2d7f:ed57 with SMTP id sh44-20020a1709076eac00b008b12d7fed57mr15316180ejc.42.1678144646892; Mon, 06 Mar 2023 15:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678144646; cv=none; d=google.com; s=arc-20160816; b=eyYNTiRnTRjxmvaq+mvRK4WUjLXF0fsgRd/HMjG/TckHCEqCJg7z9tsxiBTq4NOUyw rIdmXmOMHXiRkOqQIVm1WST4CsXCAV7NihDtVq1fVaKoFv8Auq94nc2Ldh1PvCqpjzS7 jaUZFsN6hJcKjiU91hi7pzXIptcuSYs2uFelLyC7Z1mJtKmAXEhN77hRfW/0dUYLOb1K xkE353PmZaYuM7Hg2b8TIbzhcJNmSY4M12abvTs+WSH+OpmBoRZRoZuzNXwHDi9PJ4vS zfTGnINDCXc5y5o2yEKkab8qU+FozSpAtDcD32rF2KWfCnBJAqjkvxuLdLaR+fz0i6xY 0Tzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=hIx3kaJ7v5MfcJ3bC83E2C9/NBXIacneT6tynRm3EnA=; b=F3uUrkVmLfiiqLmmF1UAtmdnBMXMTMQc5IHnKsCdACNzJ+2F/b55TnIFCLjjHzgAW4 ZCghWAkeBSocb7KLxtnJ/XIeJNyjJj28TqvHNCN6XAEtVDsV/bBAleBCkAZfeiXGk3es xx4p1lgYu4wTdvsXTTI7u9npyuEhZVr/lrFzdbHYd9hkmhk+o3HNCU+zyr8ys748GmuT Gy2kltBBHEy/UmZEhEXugc5Xfnhg3RobMJxDs71oTO06R0cRDDHvAtYDLs2XX7whu8vj DRWlHU6b+R78rwrRMzYm4ci3WS1cHNQVKnIwGBBhvoHQClx7gt6BipHoyRYOQ9H0lWpb ASAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qvAewIdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a170906805800b008c0f93e4de3si11388107ejw.99.2023.03.06.15.17.02; Mon, 06 Mar 2023 15:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qvAewIdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbjCFXA1 (ORCPT + 99 others); Mon, 6 Mar 2023 18:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjCFXAW (ORCPT ); Mon, 6 Mar 2023 18:00:22 -0500 Received: from mail-ua1-x94a.google.com (mail-ua1-x94a.google.com [IPv6:2607:f8b0:4864:20::94a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91D804A1CB for ; Mon, 6 Mar 2023 15:00:13 -0800 (PST) Received: by mail-ua1-x94a.google.com with SMTP id r18-20020ab06f52000000b00654ed50c29fso5452217uat.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=6xGtQ4FahIB9MP1F0jUCspFEK7guusjRFbIItNpfcCSss4IVbodKGlZ6Qs+nninpDE 2xy5od+OSKutBWttPQG5yt3bJLBArAhU/2T70MV5G71ROmHHrZ84ACd7xuayp2J6i7yO 7lel4uanF1AiChHxxsPA8X6T1TpPzImgoe0jdQyFIjYNpigXdSPORhIAWl2mlwa1gxoH l3/iQ2v3RQ0m2FFm9+92YKUjinOM0KTjn0P/TtQBFeo+TgAsIDVHos3Veqrd/eIIis1e LScrP7DU1DM7sFh/yMVbLG+nLR2iJhTLz0beJJFcXWfqyJRoJ2HvsA6PaBIQrPCyda/x coRg== X-Gm-Message-State: AO0yUKVJXdw2ljIUlCk6IL2lZJeZm19KDp/tyjHgPZQbZgc5o0iG2uA+ n9qi+bTgzFfGKEm3t/aujVFQYcR+13GwNeZN 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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759662201537229406?= X-GMAIL-MSGID: =?utf-8?q?1759662201537229406?= 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) /*