History

mm: Fix PageHead when !CONFIG_PAGEFLAGS_EXTENDED

Unfortunately with !CONFIG_PAGEFLAGS_EXTENDED, (!PageHead) is false, and (PageHead) is true, for tail pages. If this is indeed the intended behavior, which I doubt because it breaks cache cleaning on some ARM systems, then the nomenclature is highly problematic. This patch makes sure PageHead is only true for head pages and PageTail is only true for tail pages, and neither is true for non-compound pages. [ This buglet seems ancient - seems to have been introduced back in Apr 2008 in commit 6a1e7f777f61: "pageflags: convert to the use of new macros". And the reason nobody noticed is because the PageHead() tests are almost all about just sanity-checking, and only used on pages that are actual page heads. The fact that the old code returned true for tail pages too was thus not really noticeable. - Linus ]

Christoffer Dall committed 13 years ago

Commit ad4b3fb1 parent 637704c1 file · +7 −1Browse files

Showing the changes to include (1 of 1 file). Show all

Unified · Split

include/linux/page-flags.h+7−1
@@ -362,7 +362,7 @@ static inline void ClearPageCompound(struct page *page) · 361 unmodified lines
362 * pages on the LRU and/or pagecache.362 * pages on the LRU and/or pagecache.
363 */363 */
364TESTPAGEFLAG(Compound, compound)364TESTPAGEFLAG(Compound, compound)
365__PAGEFLAG(Head, compound)365__SETPAGEFLAG(Head, compound) __CLEARPAGEFLAG(Head, compound)
366 366
367/*367/*
368 * PG_reclaim is used in combination with PG_compound to mark the368 * PG_reclaim is used in combination with PG_compound to mark the
@@ -374,8 +374,14 @@ __PAGEFLAG(Head, compound) · 5 unmodified lines
374 * PG_compound & PG_reclaim => Tail page374 * PG_compound & PG_reclaim => Tail page
375 * PG_compound & ~PG_reclaim => Head page375 * PG_compound & ~PG_reclaim => Head page
376 */376 */
377#define PG_head_mask ((1L << PG_compound))
377#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))378#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
378 379
380static inline int PageHead(struct page *page)
381{
382 return ((page->flags & PG_head_tail_mask) == PG_head_mask);
383}
384
379static inline int PageTail(struct page *page)385static inline int PageTail(struct page *page)
380{386{
381 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);387 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);