Re: page cache: Store only head pages in i_pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 22, 2019 at 04:12:48PM -0400, Qian Cai wrote:
> FYI, every thing involve swapping seems triggered a panic now since this patch.

Thanks for the report!  Does this fix it?

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 41858a3744b4..975aea9a49a5 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -335,6 +335,8 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
 static inline struct page *find_subpage(struct page *page, pgoff_t offset)
 {
 	VM_BUG_ON_PAGE(PageTail(page), page);
+	if (unlikely(PageSwapCache(page)))
+		return page;
 	VM_BUG_ON_PAGE(page->index > offset, page);
 	VM_BUG_ON_PAGE(page->index + compound_nr(page) <= offset, page);
 	return page - page->index + offset;

Huang, I'm pretty sure this isn't right for CONFIG_THP_SWAP, but I'm
not sure what the right answer is.  The patch this is on top of includes:

@@ -132,7 +132,7 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp)
                for (i = 0; i < nr; i++) {
                        VM_BUG_ON_PAGE(xas.xa_index != idx + i, page);
                        set_page_private(page + i, entry.val + i);
-                       xas_store(&xas, page + i);
+                       xas_store(&xas, page);
                        xas_next(&xas);
                }
                address_space->nrpages += nr;

so if we've added a THP page, we're going to find the head page.  I'm not
sure I understand how to get from the head page to the right subpage.  Is
it as simple as:

+	if (unlikely(PageSwapCache(page)))
+		return page + (offset & (compound_nr(page) - 1));

or are they not stored at an aligned location?

> [11653.484481] page:ffffea0006ef7080 count:2 mapcount:0 mapping:0000000000000000
> index:0x0
> [11653.525397] swap_aops 
> [11653.525404] flags:
> 0x5fffe000080454(uptodate|lru|workingset|owner_priv_1|swapbacked)
> [11653.573631] raw: 005fffe000080454 ffffea0006ef7048 ffffea0007c9c7c8
> 0000000000000000
> [11653.608547] raw: 0000000000000000 0000000000001afd 00000002ffffffff
> 0000000000000000
> [11653.643436] page dumped because: VM_BUG_ON_PAGE(page->index + (1 <<
> compound_order(page)) <= offset)
> [11653.684322] page allocated via order 0, migratetype Movable, gfp_mask
> 0x100cca(GFP_HIGHUSER_MOVABLE)
> [11653.725462]  prep_new_page+0x3a4/0x4d0
> [11653.742373]  get_page_from_freelist+0xcde/0x3550
> [11653.763449]  __alloc_pages_nodemask+0x859/0x2ab0
> [11653.784105]  alloc_pages_vma+0xb2/0x430
> [11653.801248]  __read_swap_cache_async+0x49c/0xc30
> [11653.821943]  swap_cluster_readahead+0x4a1/0x8b0
> [11653.842224]  swapin_readahead+0xb6/0xc3e
> [11653.859894]  do_swap_page+0xc87/0x24b0
> [11653.876664]  __handle_mm_fault+0x1601/0x3bc0
> [11653.895818]  handle_mm_fault+0x326/0x6cf
> [11653.913443]  __do_page_fault+0x333/0x8d0
> [11653.931068]  do_page_fault+0x75/0x48e
> [11653.947560]  page_fault+0x1b/0x20
> [11653.962558] ------------[ cut here ]------------
> [11653.983290] kernel BUG at include/linux/pagemap.h:341!
> [11654.006336] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI
> [11654.036835] CPU: 12 PID: 14006 Comm: in:imjournal Kdump: loaded Tainted:
> G        W         5.1.0-rc1-mm1+ #17
> [11654.084191] Hardware name: HP ProLiant DL80 Gen9/ProLiant DL80 Gen9, BIOS U15
> 09/12/2016
> [11654.120401] RIP: 0010:find_get_entry+0x618/0x7f0
> [11654.141171] Code: c6 60 ae e9 97 4c 89 ff e8 c5 b2 0c 00 0f 0b 48 c7 c7 20 3b
> 42 98 e8 3c 3c 57 00 48 c7 c6 e0 b0 e9 97 4c 89 ff e8 a8 b2 0c 00 <0f> 0b 48 c7
> c7 e0 3a 42 98 e8 1f 3c 57 00 48 c7 c7 88 62 7e 98 e8
> [11654.226539] RSP: 0000:ffff8882095b7628 EFLAGS: 00010286
> [11654.249867] RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff9735700e
> [11654.281925] RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff888213e4d332
> [11654.313411] RBP: ffff8882095b7738 R08: ffffed1042d86a89 R09: ffffed1042d86a88
> [11654.346314] R10: ffffed1042d86a88 R11: ffff888216c35447 R12: 0000000000000000
> [11654.379144] R13: ffffea0006ef70a0 R14: ffff8881e5c16fc8 R15: ffffea0006ef7080
> [11654.411410] FS:  00007fb8daf56700(0000) GS:ffff888216c00000(0000)
> knlGS:0000000000000000
> [11654.447618] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [11654.473481] CR2: 00007f74c0647000 CR3: 0000000204860003 CR4: 00000000001606a0
> [11654.506282] Call Trace:
> [11654.517340]  ? __filemap_set_wb_err+0x1f0/0x1f0
> [11654.538684]  ? generic_make_request+0x283/0xc50
> [11654.562239]  ? mem_cgroup_uncharge+0x150/0x150
> [11654.582551]  pagecache_get_page+0x4a/0xb70
> [11654.600807]  ? release_pages+0xada/0x1750
> [11654.618847]  __read_swap_cache_async+0x1a8/0xc30
> [11654.640167]  ? lookup_swap_cache+0x570/0x570
> [11654.659274]  read_swap_cache_async+0x69/0xd0
> [11654.678354]  ? __read_swap_cache_async+0xc30/0xc30
> [11654.699775]  ? lru_add_drain_cpu+0x239/0x4e0
> [11654.718855]  swap_cluster_readahead+0x386/0x8b0
> [11654.739171]  ? read_swap_cache_async+0xd0/0xd0
> [11654.760517]  ? xas_load+0x8b/0xf0
> [11654.775357]  ? find_get_entry+0x39e/0x7f0
> [11654.793267]  swapin_readahead+0xb6/0xc3e
> [11654.810391]  ? exit_swap_address_space+0x1b0/0x1b0
> [11654.831816]  ? lookup_swap_cache+0x114/0x570
> [11654.850972]  ? xas_find+0x141/0x530
> [11654.866616]  ? free_pages_and_swap_cache+0x2f0/0x2f0
> [11654.889495]  ? swapcache_prepare+0x20/0x20
> [11654.907786]  ? filemap_map_pages+0x3af/0xec0
> [11654.926919]  do_swap_page+0xc87/0x24b0
> [11654.943758]  ? unmap_mapping_range+0x30/0x30
> [11654.962918]  ? kasan_check_read+0x11/0x20
> [11654.980900]  ? do_raw_spin_unlock+0x59/0x250
> [11655.000027]  __handle_mm_fault+0x1601/0x3bc0
> [11655.020130]  ? __lock_acquire.isra.14+0x7d7/0x2130
> [11655.041845]  ? vmf_insert_mixed_mkwrite+0x20/0x20
> [11655.066529]  ? lock_acquire+0x169/0x360
> [11655.085380]  handle_mm_fault+0x326/0x6cf
> [11655.102928]  __do_page_fault+0x333/0x8d0
> [11655.120429]  ? task_work_run+0xdd/0x190
> [11655.138322]  do_page_fault+0x75/0x48e
> [11655.154693]  ? page_fault+0x5/0x20
> [11655.170168]  page_fault+0x1b/0x20
> [11655.185007] RIP: 0033:0x7fb8dde3ae14
> [11655.201007] Code: 00 0f 1f 44 00 00 f3 0f 1e fa f2 ff 25 65 1a 29 00 0f 1f 44
> 00 00 f3 0f 1e fa f2 ff 25 5d 1a 29 00 0f 1f 44 00 00 f3 0f 1e fa <f2> ff 25 55
> 1a 29 00 0f 1f 44 00 00 f3 0f 1e fa f2 ff 25 4d 1a 29
> [11655.286038] RSP: 002b:00007fb8daf55b28 EFLAGS: 00010246
> [11655.309443] RAX: 0000000000000000 RBX: 0000562a76a844f0 RCX: 0000000000000000
> [11655.341503] RDX: 00007fb8daf55ac0 RSI: 0000000000000001 RDI: 0000562a76a844f0
> [11655.373906] RBP: 00000000000dbba0 R08: 0000000000000008 R09: 0000000000000000
> [11655.407498] R10: 0000000000000000 R11: 0000000000000000 R12: 000000000000000e
> [11655.439429] R13: 00007fb8da036760 R14: 00007fb8daf55be0 R15: 00007fb8daf55bd0
> [11655.471484] Modules linked in: brd nls_iso8859_1 nls_cp437 vfat fat ext4
> crc16 mbcache jbd2 overlay loop kvm_intel kvm irqbypass ip_tables x_tables xfs
> sd_mod igb ahci i2c_algo_bit libahci libata i2c_core dm_mirror dm_region_hash
> dm_log dm_mod




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux