Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/huge_memory: deduplicate zap deposited table call

Rather than having separate logic for each case determining whether to zap
the deposited table, simply track this via a boolean.

We default this to whether the architecture requires it, and update it as
required elsewhere.

Link: https://lkml.kernel.org/r/71f576a1fbcd27a86322d12caa937bcdacf75407.1774029655.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nico Pache <npache@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
d490940f 07f26468

+10 -12
+10 -12
mm/huge_memory.c
··· 2414 2414 bool zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, 2415 2415 pmd_t *pmd, unsigned long addr) 2416 2416 { 2417 + bool has_deposit = arch_needs_pgtable_deposit(); 2417 2418 struct folio *folio = NULL; 2418 2419 bool flush_needed = false; 2419 2420 spinlock_t *ptl; ··· 2435 2434 tlb->fullmm); 2436 2435 arch_check_zapped_pmd(vma, orig_pmd); 2437 2436 tlb_remove_pmd_tlb_entry(tlb, pmd, addr); 2438 - if (vma_is_special_huge(vma)) { 2439 - if (arch_needs_pgtable_deposit()) 2440 - zap_deposited_table(tlb->mm, pmd); 2437 + if (vma_is_special_huge(vma)) 2441 2438 goto out; 2442 - } 2443 2439 if (is_huge_zero_pmd(orig_pmd)) { 2444 - if (!vma_is_dax(vma) || arch_needs_pgtable_deposit()) 2445 - zap_deposited_table(tlb->mm, pmd); 2440 + if (!vma_is_dax(vma)) 2441 + has_deposit = true; 2446 2442 goto out; 2447 2443 } 2448 2444 2449 2445 if (pmd_present(orig_pmd)) { 2450 - struct page *page = pmd_page(orig_pmd); 2446 + folio = pmd_folio(orig_pmd); 2451 2447 2452 2448 flush_needed = true; 2453 - folio = page_folio(page); 2454 - folio_remove_rmap_pmd(folio, page, vma); 2449 + folio_remove_rmap_pmd(folio, &folio->page, vma); 2455 2450 WARN_ON_ONCE(folio_mapcount(folio) < 0); 2456 2451 } else if (pmd_is_valid_softleaf(orig_pmd)) { 2457 2452 const softleaf_t entry = softleaf_from_pmd(orig_pmd); ··· 2462 2465 } 2463 2466 2464 2467 if (folio_test_anon(folio)) { 2465 - zap_deposited_table(tlb->mm, pmd); 2468 + has_deposit = true; 2466 2469 add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); 2467 2470 } else { 2468 - if (arch_needs_pgtable_deposit()) 2469 - zap_deposited_table(tlb->mm, pmd); 2470 2471 add_mm_counter(tlb->mm, mm_counter_file(folio), 2471 2472 -HPAGE_PMD_NR); 2472 2473 ··· 2484 2489 } 2485 2490 2486 2491 out: 2492 + if (has_deposit) 2493 + zap_deposited_table(tlb->mm, pmd); 2494 + 2487 2495 spin_unlock(ptl); 2488 2496 if (flush_needed) 2489 2497 tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE);