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

mm: delete __ClearPageWaiters()

The PG_waiters bit is not included in PAGE_FLAGS_CHECK_AT_FREE, and
vmscan.c's free_unref_page_list() callers rely on that not to generate
bad_page() alerts. So __page_cache_release(), put_pages_list() and
release_pages() (and presumably copy-and-pasted free_zone_device_page())
are redundant and misleading to make a special point of clearing it (as
the "__" implies, it could only safely be used on the freeing path).

Delete __ClearPageWaiters(). Remark on this in one of the "possible"
comments in folio_wake_bit(), and delete the superfluous comments.

Link: https://lkml.kernel.org/r/3eafa969-5b1a-accf-88fe-318784c791a@google.com
Signed-off-by: Hugh Dickins <hughd@google.com>
Tested-by: Yu Zhao <yuzhao@google.com>
Reviewed-by: Yang Shi <shy828301@gmail.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
bb43b14b 6f6a841f

+9 -22
+1 -1
include/linux/page-flags.h
··· 481 481 TESTSETFLAG_FALSE(uname, lname) TESTCLEARFLAG_FALSE(uname, lname) 482 482 483 483 __PAGEFLAG(Locked, locked, PF_NO_TAIL) 484 - PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) 484 + PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) 485 485 PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) 486 486 PAGEFLAG(Referenced, referenced, PF_HEAD) 487 487 TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
+8 -15
mm/filemap.c
··· 1185 1185 } 1186 1186 1187 1187 /* 1188 - * It is possible for other pages to have collided on the waitqueue 1189 - * hash, so in that case check for a page match. That prevents a long- 1190 - * term waiter 1188 + * It's possible to miss clearing waiters here, when we woke our page 1189 + * waiters, but the hashed waitqueue has waiters for other pages on it. 1190 + * That's okay, it's a rare case. The next waker will clear it. 1191 1191 * 1192 - * It is still possible to miss a case here, when we woke page waiters 1193 - * and removed them from the waitqueue, but there are still other 1194 - * page waiters. 1192 + * Note that, depending on the page pool (buddy, hugetlb, ZONE_DEVICE, 1193 + * other), the flag may be cleared in the course of freeing the page; 1194 + * but that is not required for correctness. 1195 1195 */ 1196 - if (!waitqueue_active(q) || !key.page_match) { 1196 + if (!waitqueue_active(q) || !key.page_match) 1197 1197 folio_clear_waiters(folio); 1198 - /* 1199 - * It's possible to miss clearing Waiters here, when we woke 1200 - * our page waiters, but the hashed waitqueue has waiters for 1201 - * other pages on it. 1202 - * 1203 - * That's okay, it's a rare case. The next waker will clear it. 1204 - */ 1205 - } 1198 + 1206 1199 spin_unlock_irqrestore(&q->lock, flags); 1207 1200 } 1208 1201
-2
mm/memremap.c
··· 456 456 if (WARN_ON_ONCE(!page->pgmap->ops || !page->pgmap->ops->page_free)) 457 457 return; 458 458 459 - __ClearPageWaiters(page); 460 - 461 459 mem_cgroup_uncharge(page_folio(page)); 462 460 463 461 /*
-4
mm/swap.c
··· 97 97 mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages); 98 98 count_vm_events(UNEVICTABLE_PGCLEARED, nr_pages); 99 99 } 100 - __ClearPageWaiters(page); 101 100 } 102 101 103 102 static void __put_single_page(struct page *page) ··· 151 152 continue; 152 153 } 153 154 /* Cannot be PageLRU because it's passed to us using the lru */ 154 - __ClearPageWaiters(page); 155 155 } 156 156 157 157 free_unref_page_list(pages); ··· 968 970 dec_zone_page_state(page, NR_MLOCK); 969 971 count_vm_event(UNEVICTABLE_PGCLEARED); 970 972 } 971 - 972 - __ClearPageWaiters(page); 973 973 974 974 list_add(&page->lru, &pages_to_free); 975 975 }