From 8caca6a93ebe3b0e4adabfb1b8d13e86d41fd329 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 29 Oct 2022 10:42:25 -0700 Subject: [PATCH 1/2] mm: zap_page_range: narrow down 'page' variable scope We're using the same 'struct page *page' variable for three very distinct cases. That works and the compiler does the right thing, but I'm about to add some page-related attributes that only affects one of them, so let's make the whole "these are really different uses" explicit. Signed-off-by: Linus Torvalds --- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index f88c351aecd4..d52f5a68c561 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1423,7 +1423,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, arch_enter_lazy_mmu_mode(); do { pte_t ptent = *pte; - struct page *page; if (pte_none(ptent)) continue; @@ -1432,7 +1431,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, break; if (pte_present(ptent)) { - page = vm_normal_page(vma, addr, ptent); + struct page *page = vm_normal_page(vma, addr, ptent); if (unlikely(!should_zap_page(details, page))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, @@ -1467,7 +1466,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, entry = pte_to_swp_entry(ptent); if (is_device_private_entry(entry) || is_device_exclusive_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + struct page *page = pfn_swap_entry_to_page(entry); if (unlikely(!should_zap_page(details, page))) continue; /* @@ -1489,7 +1488,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (unlikely(!free_swap_and_cache(entry))) print_bad_pte(vma, addr, ptent, NULL); } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + struct page *page = pfn_swap_entry_to_page(entry); if (!should_zap_page(details, page)) continue; rss[mm_counter(page)]--; -- 2.37.1.289.g45aa1e5c72.dirty