On Mon, 2019-04-01 at 12:27 +0300, Kirill A. Shutemov wrote: > What about patch like this? (completely untested) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index f939e004c5d1..e3b9bf843dcb 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -335,12 +335,12 @@ static inline struct page *grab_cache_page_nowait(struct > address_space *mapping, > > static inline struct page *find_subpage(struct page *page, pgoff_t offset) > { > - unsigned long index = page_index(page); > + unsigned long mask; > > VM_BUG_ON_PAGE(PageTail(page), page); > - VM_BUG_ON_PAGE(index > offset, page); > - VM_BUG_ON_PAGE(index + (1 << compound_order(page)) <= offset, page); > - return page - index + offset; > + > + mask = (1UL << compound_order(page)) - 1; > + return page + (offset & mask); > } > > struct page *find_get_entry(struct address_space *mapping, pgoff_t offset); No, this then leads to a panic below by LTP hugemmap05. Still reverting the whole "mm: page cache: store only head pages in i_pages" commit fixed the problem. # /opt/ltp/testcases/bin/hugemmap05 tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s hugemmap05.c:235: INFO: original nr_hugepages is 0 hugemmap05.c:248: INFO: original nr_overcommit_hugepages is 0 hugemmap05.c:116: INFO: check /proc/meminfo before allocation. hugemmap05.c:297: INFO: HugePages_Total is 192. hugemmap05.c:297: INFO: HugePages_Free is 192. hugemmap05.c:297: INFO: HugePages_Surp is 64. hugemmap05.c:297: INFO: HugePages_Rsvd is 192. hugemmap05.c:272: INFO: First hex is 7070707 hugemmap05.c:151: INFO: check /proc/meminfo. hugemmap05.c:297: INFO: HugePages_Total is 192. hugemmap05.c:297: INFO: HugePages_Free is 0. hugemmap05.c:297: INFO: HugePages_Surp is 64. hugemmap05.c:297: INFO: HugePages_Rsvd is 0. [10022.547977] ------------[ cut here ]------------ [10022.571941] kernel BUG at fs/hugetlbfs/inode.c:475! [10022.598304] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [10022.626383] CPU: 39 PID: 13074 Comm: hugemmap05 Kdump: loaded Tainted: G W 5.1.0-rc3-next-20190403+ #16 [10022.674421] Hardware name: HP ProLiant XL420 Gen9/ProLiant XL420 Gen9, BIOS U19 12/27/2015 [10022.711990] RIP: 0010:remove_inode_hugepages+0x706/0xa60 [10022.735997] Code: fd ff ff e8 9c a0 99 ff e9 bc fc ff ff 48 c7 c6 40 ae 50 9f 4c 89 f7 e8 c8 3f ca ff 0f 0b 48 c7 c7 80 18 ba 9f e8 2f 63 15 00 <0f> 0b 48 c7 c7 40 18 ba 9f e8 21 63 15 00 48 8b bd 88 fd ff ff e8 [10022.820547] RSP: 0018:ffff88883ea5f920 EFLAGS: 00010202 [10022.844039] RAX: 015fffe000002000 RBX: 0000000000000001 RCX: ffffffff9e2adf5c [10022.876130] RDX: 0000000000000001 RSI: 00000000000001df RDI: ffffea001a0f8048 [10022.908202] RBP: ffff88883ea5fbf8 R08: fffff9400341f00b R09: fffff9400341f00a [10022.940369] R10: fffff9400341f00a R11: ffffea001a0f8057 R12: 0000000000000001 [10022.972615] R13: ffff88883ea5fbd0 R14: ffffea001a0f8040 R15: dffffc0000000000 [10023.004633] FS: 00007ff5964d7740(0000) GS:ffff888847b80000(0000) knlGS:0000000000000000 [10023.040462] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [10023.066242] CR2: 00007ff595800000 CR3: 00000004be5d0006 CR4: 00000000001606a0 [10023.103426] Call Trace: [10023.114997] ? hugetlbfs_size_to_hpages+0xe0/0xe0 [10023.136032] ? fsnotify_grab_connector+0x9f/0x130 [10023.157131] ? __lock_acquire.isra.14+0x7d7/0x2130 [10023.178540] ? kasan_check_read+0x11/0x20 [10023.196471] ? do_raw_spin_unlock+0x59/0x250 [10023.215893] hugetlbfs_evict_inode+0x20/0x90 [10023.235249] evict+0x2a4/0x5c0 [10023.249393] ? do_raw_spin_unlock+0x59/0x250 [10023.268885] iput+0x3d9/0x790 [10023.282210] do_unlinkat+0x461/0x650 [10023.298318] ? __x64_sys_rmdir+0x40/0x40 [10023.316058] ? __check_object_size+0x4b4/0x7f1 [10023.336241] ? __kasan_kmalloc.constprop.1+0xac/0xc0 [10023.358681] ? blkcg_exit_queue+0x1a0/0x1a0 [10023.377428] ? getname_flags+0x90/0x400 [10023.394859] __x64_sys_unlink+0x3e/0x50 [10023.411987] do_syscall_64+0xeb/0xb78 [10023.428386] ? syscall_return_slowpath+0x160/0x160 [10023.449987] ? __do_page_fault+0x583/0x8d0 [10023.468333] ? schedule+0x81/0x180 [10023.483515] ? exit_to_usermode_loop+0xab/0x100 [10023.503763] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [10023.526369] RIP: 0033:0x7ff595bbcedb