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: have zap_huge_pmd return a boolean, add kdoc

There's no need to use the ancient approach of returning an integer here,
just return a boolean.

Also update flush_needed to be a boolean, similarly.

Also add a kdoc comment describing the function.

No functional change intended.

Link: https://lkml.kernel.org/r/132274566cd49d2960a2294c36dd2450593dfc55.1774029655.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Qi Zheng <zhengqi.arch@bytedance.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: 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
b92b9d4f 6886f937

+18 -9
+2 -2
include/linux/huge_mm.h
··· 27 27 vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf); 28 28 bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, 29 29 pmd_t *pmd, unsigned long addr, unsigned long next); 30 - int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, 31 - unsigned long addr); 30 + bool zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, 31 + unsigned long addr); 32 32 int zap_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma, pud_t *pud, 33 33 unsigned long addr); 34 34 bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
+16 -7
mm/huge_memory.c
··· 2402 2402 mm_dec_nr_ptes(mm); 2403 2403 } 2404 2404 2405 - int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, 2405 + /** 2406 + * zap_huge_pmd - Zap a huge THP which is of PMD size. 2407 + * @tlb: The MMU gather TLB state associated with the operation. 2408 + * @vma: The VMA containing the range to zap. 2409 + * @pmd: A pointer to the leaf PMD entry. 2410 + * @addr: The virtual address for the range to zap. 2411 + * 2412 + * Returns: %true on success, %false otherwise. 2413 + */ 2414 + bool zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, 2406 2415 pmd_t *pmd, unsigned long addr) 2407 2416 { 2408 2417 struct folio *folio = NULL; 2409 - int flush_needed = 1; 2418 + bool flush_needed = true; 2410 2419 spinlock_t *ptl; 2411 2420 pmd_t orig_pmd; 2412 2421 ··· 2423 2414 2424 2415 ptl = __pmd_trans_huge_lock(pmd, vma); 2425 2416 if (!ptl) 2426 - return 0; 2417 + return false; 2427 2418 /* 2428 2419 * For architectures like ppc64 we look at deposited pgtable 2429 2420 * when calling pmdp_huge_get_and_clear. So do the ··· 2438 2429 if (arch_needs_pgtable_deposit()) 2439 2430 zap_deposited_table(tlb->mm, pmd); 2440 2431 spin_unlock(ptl); 2441 - return 1; 2432 + return true; 2442 2433 } 2443 2434 if (is_huge_zero_pmd(orig_pmd)) { 2444 2435 if (!vma_is_dax(vma) || arch_needs_pgtable_deposit()) 2445 2436 zap_deposited_table(tlb->mm, pmd); 2446 2437 spin_unlock(ptl); 2447 - return 1; 2438 + return true; 2448 2439 } 2449 2440 2450 2441 if (pmd_present(orig_pmd)) { ··· 2458 2449 const softleaf_t entry = softleaf_from_pmd(orig_pmd); 2459 2450 2460 2451 folio = softleaf_to_folio(entry); 2461 - flush_needed = 0; 2452 + flush_needed = false; 2462 2453 2463 2454 if (!thp_migration_supported()) 2464 2455 WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); ··· 2492 2483 if (flush_needed) 2493 2484 tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE); 2494 2485 2495 - return 1; 2486 + return true; 2496 2487 } 2497 2488 2498 2489 #ifndef pmd_move_must_withdraw