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: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

A page is not added to the swap cache without being swap backed,
so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Lutomirski <luto@kernel.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Nicholas Piggin and committed by
Linus Torvalds
6326fec1 7c0f6ba6

+25 -18
+16 -8
include/linux/page-flags.h
··· 87 87 PG_private_2, /* If pagecache, has fs aux data */ 88 88 PG_writeback, /* Page is under writeback */ 89 89 PG_head, /* A head page */ 90 - PG_swapcache, /* Swap page: swp_entry_t in private */ 91 90 PG_mappedtodisk, /* Has blocks allocated on-disk */ 92 91 PG_reclaim, /* To be reclaimed asap */ 93 92 PG_swapbacked, /* Page is backed by RAM/swap */ ··· 108 109 109 110 /* Filesystems */ 110 111 PG_checked = PG_owner_priv_1, 112 + 113 + /* SwapBacked */ 114 + PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */ 111 115 112 116 /* Two page bits are conscripted by FS-Cache to maintain local caching 113 117 * state. These bits are set on pages belonging to the netfs's inodes ··· 316 314 #endif 317 315 318 316 #ifdef CONFIG_SWAP 319 - PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND) 317 + static __always_inline int PageSwapCache(struct page *page) 318 + { 319 + return PageSwapBacked(page) && test_bit(PG_swapcache, &page->flags); 320 + 321 + } 322 + SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND) 323 + CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND) 320 324 #else 321 325 PAGEFLAG_FALSE(SwapCache) 322 326 #endif ··· 709 701 * Flags checked when a page is freed. Pages being freed should not have 710 702 * these flags set. It they are, there is a problem. 711 703 */ 712 - #define PAGE_FLAGS_CHECK_AT_FREE \ 713 - (1UL << PG_lru | 1UL << PG_locked | \ 714 - 1UL << PG_private | 1UL << PG_private_2 | \ 715 - 1UL << PG_writeback | 1UL << PG_reserved | \ 716 - 1UL << PG_slab | 1UL << PG_swapcache | 1UL << PG_active | \ 717 - 1UL << PG_unevictable | __PG_MLOCKED) 704 + #define PAGE_FLAGS_CHECK_AT_FREE \ 705 + (1UL << PG_lru | 1UL << PG_locked | \ 706 + 1UL << PG_private | 1UL << PG_private_2 | \ 707 + 1UL << PG_writeback | 1UL << PG_reserved | \ 708 + 1UL << PG_slab | 1UL << PG_active | \ 709 + 1UL << PG_unevictable | __PG_MLOCKED) 718 710 719 711 /* 720 712 * Flags checked when a page is prepped for return by the page allocator.
-1
include/trace/events/mmflags.h
··· 95 95 {1UL << PG_private_2, "private_2" }, \ 96 96 {1UL << PG_writeback, "writeback" }, \ 97 97 {1UL << PG_head, "head" }, \ 98 - {1UL << PG_swapcache, "swapcache" }, \ 99 98 {1UL << PG_mappedtodisk, "mappedtodisk" }, \ 100 99 {1UL << PG_reclaim, "reclaim" }, \ 101 100 {1UL << PG_swapbacked, "swapbacked" }, \
+1 -3
mm/memory-failure.c
··· 764 764 */ 765 765 766 766 #define dirty (1UL << PG_dirty) 767 - #define sc (1UL << PG_swapcache) 767 + #define sc ((1UL << PG_swapcache) | (1UL << PG_swapbacked)) 768 768 #define unevict (1UL << PG_unevictable) 769 769 #define mlock (1UL << PG_mlocked) 770 770 #define writeback (1UL << PG_writeback) 771 771 #define lru (1UL << PG_lru) 772 - #define swapbacked (1UL << PG_swapbacked) 773 772 #define head (1UL << PG_head) 774 773 #define slab (1UL << PG_slab) 775 774 #define reserved (1UL << PG_reserved) ··· 818 819 #undef mlock 819 820 #undef writeback 820 821 #undef lru 821 - #undef swapbacked 822 822 #undef head 823 823 #undef slab 824 824 #undef reserved
+8 -6
mm/migrate.c
··· 466 466 */ 467 467 newpage->index = page->index; 468 468 newpage->mapping = page->mapping; 469 - if (PageSwapBacked(page)) 470 - __SetPageSwapBacked(newpage); 471 - 472 469 get_page(newpage); /* add cache reference */ 473 - if (PageSwapCache(page)) { 474 - SetPageSwapCache(newpage); 475 - set_page_private(newpage, page_private(page)); 470 + if (PageSwapBacked(page)) { 471 + __SetPageSwapBacked(newpage); 472 + if (PageSwapCache(page)) { 473 + SetPageSwapCache(newpage); 474 + set_page_private(newpage, page_private(page)); 475 + } 476 + } else { 477 + VM_BUG_ON_PAGE(PageSwapCache(page), page); 476 478 } 477 479 478 480 /* Move dirty while page refs frozen and newpage not yet exposed */