On Wed, Mar 23, 2022 at 04:52:18PM +0000, Steve Capper wrote: > +#define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ > + do { \ > + unsigned long _sz = huge_page_size(h); \ > + if (_sz == CONT_PTE_SIZE) \ > + tlb_flush_pte_range(tlb, address, _sz); \ > + else if (_sz == PMD_SIZE) \ > + tlb_flush_pmd_range(tlb, address, _sz); \ > + else if (_sz == CONT_PMD_SIZE) \ > + tlb_flush_pmd_range(tlb, address, _sz); \ > + else if (_sz == PUD_SIZE) \ > + tlb_flush_pud_range(tlb, address, _sz); \ > + __tlb_remove_tlb_entry(tlb, ptep, address); \ > + } while (0) It occurs to me that perhaps this can be written like: unsigned long _sz = huge_page_size(h); if (_sz >= P4D_SIZE) tlb_flush_p4d_range(tlb, address, _sz); else if (_sz >= PUD_SIZE) tlb_flush_pud_range(tlb, address, _sz); else if (_sz >= PMD_SIZE) tlb_flush_pmd_range(tlb, address, _sz); else tlb_flush_pte_range(tlb, address, _sz); __tlb_remove_tlb_entry(tlb, ptep, address); And then it can still be generic..