Rongwei Wang
55fc0d9174
mm, thp: lock filemap when truncating page cache
...
Patch series "fix two bugs for file THP".
This patch (of 2):
Transparent huge page has supported read-only non-shmem files. The
file- backed THP is collapsed by khugepaged and truncated when written
(for shared libraries).
However, there is a race when multiple writers truncate the same page
cache concurrently.
In that case, subpage(s) of file THP can be revealed by find_get_entry
in truncate_inode_pages_range, which will trigger PageTail BUG_ON in
truncate_inode_page, as follows:
page:000000009e420ff2 refcount:1 mapcount:0 mapping:0000000000000000 index:0x7ff pfn:0x50c3ff
head:0000000075ff816d order:9 compound_mapcount:0 compound_pincount:0
flags: 0x37fffe0000010815(locked|uptodate|lru|arch_1|head)
raw: 37fffe0000000000 fffffe0013108001 dead000000000122 dead000000000400
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
head: 37fffe0000010815 fffffe001066bd48 ffff000404183c20 0000000000000000
head: 0000000000000600 0000000000000000 00000001ffffffff ffff000c0345a000
page dumped because: VM_BUG_ON_PAGE(PageTail(page))
------------[ cut here ]------------
kernel BUG at mm/truncate.c:213!
Internal error: Oops - BUG: 0 [#1 ] SMP
Modules linked in: xfs(E) libcrc32c(E) rfkill(E) ...
CPU: 14 PID: 11394 Comm: check_madvise_d Kdump: ...
Hardware name: ECS, BIOS 0.0.0 02/06/2015
pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--)
Call trace:
truncate_inode_page+0x64/0x70
truncate_inode_pages_range+0x550/0x7e4
truncate_pagecache+0x58/0x80
do_dentry_open+0x1e4/0x3c0
vfs_open+0x38/0x44
do_open+0x1f0/0x310
path_openat+0x114/0x1dc
do_filp_open+0x84/0x134
do_sys_openat2+0xbc/0x164
__arm64_sys_openat+0x74/0xc0
el0_svc_common.constprop.0+0x88/0x220
do_el0_svc+0x30/0xa0
el0_svc+0x20/0x30
el0_sync_handler+0x1a4/0x1b0
el0_sync+0x180/0x1c0
Code: aa0103e0 900061e1 910ec021 9400d300 (d4210000)
This patch mainly to lock filemap when one enter truncate_pagecache(),
avoiding truncating the same page cache concurrently.
Link: https://lkml.kernel.org/r/20211025092134.18562-1-rongwei.wang@linux.alibaba.com
Link: https://lkml.kernel.org/r/20211025092134.18562-2-rongwei.wang@linux.alibaba.com
Fixes: eb6ecbed0aa2 ("mm, thp: relax the VM_DENYWRITE constraint on file-backed THPs")
Signed-off-by: Xu Yu <xuyu@linux.alibaba.com>
Signed-off-by: Rongwei Wang <rongwei.wang@linux.alibaba.com>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: Song Liu <song@kernel.org>
Cc: Collin Fijalkovich <cfijalkovich@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-11-06 13:30:41 -07:00
..
2021-10-04 22:07:46 +01:00
2021-06-29 10:53:48 -07:00
2021-06-29 10:53:48 -07:00
2021-10-07 11:20:08 -07:00
2021-10-20 21:09:02 -04:00
2021-08-19 09:02:55 +09:00
2021-06-29 10:53:48 -07:00
2021-10-29 10:46:59 -07:00
2021-08-27 13:34:02 +01:00
2021-10-19 09:36:06 +02:00
2021-09-23 21:12:53 -05:00
2021-04-23 14:42:39 -07:00
2021-08-25 07:58:49 +02:00
2021-07-25 20:47:05 -07:00
2021-09-21 09:09:06 +02:00
2021-09-01 11:29:14 -05:00
2021-06-29 10:53:48 -07:00
2021-04-12 15:04:29 +02:00
2021-09-23 23:23:04 +08:00
2021-07-06 11:06:04 -07:00
2021-09-22 13:05:23 +02:00
2021-10-03 13:56:53 -07:00
2021-09-04 10:48:47 -07:00
2021-09-02 12:32:12 -07:00
2021-10-04 22:13:12 +01:00
2021-10-21 10:01:39 +02:00
2021-09-09 12:45:26 -07:00
2021-07-15 10:13:49 -07:00
2021-07-01 11:06:06 -07:00
2021-08-26 22:28:02 +02:00
2021-07-27 11:00:36 +02:00
2021-07-23 17:43:28 -07:00
2021-08-26 09:18:53 -07:00
2021-08-12 16:07:14 +02:00
2021-08-30 23:36:50 -04:00
2021-08-18 22:08:24 +02:00
2021-08-18 22:08:24 +02:00
2021-10-04 10:27:18 +02:00
2021-10-20 00:07:10 -05:00
2021-09-22 09:21:02 -07:00
2021-06-29 10:53:48 -07:00
2021-10-05 11:22:06 +01:00
2021-09-04 10:25:26 -07:00
2021-10-04 22:02:17 +01:00
2021-10-07 14:11:40 -07:00
2021-09-08 12:55:35 -07:00
2021-09-10 09:46:48 -07:00
2021-07-03 11:30:04 -07:00
2021-10-15 09:58:11 -04:00
2021-11-06 13:30:32 -07:00
2021-06-29 10:53:48 -07:00
2021-03-12 22:15:22 -05:00
2021-08-18 22:08:24 +02:00
2021-09-28 09:16:12 +02:00
2021-11-06 13:30:33 -07:00
2021-06-30 12:21:16 -07:00
2021-09-21 08:36:48 -07:00
2021-06-22 10:40:52 +02:00
2021-06-29 10:53:48 -07:00
2021-09-03 15:33:47 -07:00
2021-09-13 14:51:10 -05:00
2021-08-16 10:50:32 -06:00
2021-08-06 13:05:28 +02:00
2021-06-29 10:53:48 -07:00
2021-03-23 14:08:18 -04:00
2021-07-25 20:01:07 -07:00
2021-08-23 13:35:19 +02:00
2021-08-19 09:02:55 +09:00
2021-05-02 00:43:35 +09:00
2021-09-27 11:26:21 -07:00
2021-09-22 10:56:34 -07:00
2021-09-09 11:39:57 -07:00
2021-08-30 10:24:50 -07:00
2021-08-28 01:33:02 +02:00
2021-08-13 00:41:05 -04:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2021-09-03 18:42:01 +02:00
2021-10-03 14:02:58 -07:00
2021-06-29 10:53:50 -07:00
2021-03-13 11:27:30 -08:00
2021-09-24 16:13:35 -07:00
2021-09-08 11:50:27 -07:00
2021-11-06 13:30:32 -07:00
2021-08-31 11:13:35 -07:00
2021-04-15 22:36:45 -04:00
2021-04-09 14:54:23 -07:00
2021-09-03 09:58:10 -07:00
2021-09-06 07:20:56 -04:00
2021-09-09 13:25:49 -07:00
2021-09-04 11:35:47 -07:00
2021-09-03 10:08:28 -07:00
2021-04-07 13:56:43 -04:00
2021-09-11 14:48:42 -07:00
2021-08-23 01:25:40 -04:00
2021-09-03 09:58:12 -07:00
2021-09-07 16:07:47 -04:00
2021-09-03 10:08:28 -07:00
2021-09-17 13:39:23 +02:00
2021-09-07 08:39:40 -06:00
2021-10-21 11:19:38 -06:00
2021-10-19 17:09:34 -06:00
2021-08-29 07:55:55 -06:00
2021-08-31 11:06:32 -07:00
2021-09-12 10:10:21 -07:00
2021-07-25 22:33:03 -07:00
2021-10-18 20:22:03 -10:00
2021-06-29 10:53:48 -07:00
2021-09-07 11:21:48 -07:00
2021-09-12 10:10:21 -07:00
2021-03-11 07:47:48 -07:00
2021-09-07 16:14:05 -04:00
2021-09-03 10:08:28 -07:00
2021-11-06 13:30:41 -07:00
2021-09-07 11:03:45 -07:00
2021-11-06 13:30:32 -07:00
2021-08-24 07:52:45 -04:00
2021-04-17 11:39:49 -07:00
2021-08-23 06:15:36 -04:00
2021-09-07 11:26:23 -07:00
2021-07-19 17:18:48 -07:00
2021-07-23 13:16:43 -05:00
2021-08-17 11:47:43 +02:00
2021-11-06 13:30:34 -07:00
2021-08-10 17:57:22 +02:00
2021-10-18 20:22:02 -10:00
2021-03-23 11:20:26 +01:00