Zhang Xiaoxu
c78bfac87e
cifs: Fix double add page to memcg when cifs_readpages
[ Upstream commit 95a3d8f3af ]
When xfstests generic/451, there is an BUG at mm/memcontrol.c:
page:ffffea000560f2c0 refcount:2 mapcount:0 mapping:000000008544e0ea
index:0xf
mapping->aops:cifs_addr_ops dentry name:"tst-aio-dio-cycle-write.451"
flags: 0x2fffff80000001(locked)
raw: 002fffff80000001 ffffc90002023c50 ffffea0005280088 ffff88815cda0210
raw: 000000000000000f 0000000000000000 00000002ffffffff ffff88817287d000
page dumped because: VM_BUG_ON_PAGE(page->mem_cgroup)
page->mem_cgroup:ffff88817287d000
------------[ cut here ]------------
kernel BUG at mm/memcontrol.c:2659!
invalid opcode: 0000 [#1] SMP
CPU: 2 PID: 2038 Comm: xfs_io Not tainted 5.8.0-rc1 #44
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_
073836-buildvm-ppc64le-16.ppc.4
RIP: 0010:commit_charge+0x35/0x50
Code: 0d 48 83 05 54 b2 02 05 01 48 89 77 38 c3 48 c7
c6 78 4a ea ba 48 83 05 38 b2 02 05 01 e8 63 0d9
RSP: 0018:ffffc90002023a50 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff88817287d000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff88817ac97ea0 RDI: ffff88817ac97ea0
RBP: ffffea000560f2c0 R08: 0000000000000203 R09: 0000000000000005
R10: 0000000000000030 R11: ffffc900020237a8 R12: 0000000000000000
R13: 0000000000000001 R14: 0000000000000001 R15: ffff88815a1272c0
FS: 00007f5071ab0800(0000) GS:ffff88817ac80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055efcd5ca000 CR3: 000000015d312000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
mem_cgroup_charge+0x166/0x4f0
__add_to_page_cache_locked+0x4a9/0x710
add_to_page_cache_locked+0x15/0x20
cifs_readpages+0x217/0x1270
read_pages+0x29a/0x670
page_cache_readahead_unbounded+0x24f/0x390
__do_page_cache_readahead+0x3f/0x60
ondemand_readahead+0x1f1/0x470
page_cache_async_readahead+0x14c/0x170
generic_file_buffered_read+0x5df/0x1100
generic_file_read_iter+0x10c/0x1d0
cifs_strict_readv+0x139/0x170
new_sync_read+0x164/0x250
__vfs_read+0x39/0x60
vfs_read+0xb5/0x1e0
ksys_pread64+0x85/0xf0
__x64_sys_pread64+0x22/0x30
do_syscall_64+0x69/0x150
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f5071fcb1af
Code: Bad RIP value.
RSP: 002b:00007ffde2cdb8e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000011
RAX: ffffffffffffffda RBX: 00007ffde2cdb990 RCX: 00007f5071fcb1af
RDX: 0000000000001000 RSI: 000055efcd5ca000 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: 0000000000000001
R13: 000000000009f000 R14: 0000000000000000 R15: 0000000000001000
Modules linked in:
---[ end trace 725fa14a3e1af65c ]---
Since commit 3fea5a499d ("mm: memcontrol: convert page cache to a new
mem_cgroup_charge() API") not cancel the page charge, the pages maybe
double add to pagecache:
thread1 | thread2
cifs_readpages
readpages_get_pages
add_to_page_cache_locked(head,index=n)=0
| readpages_get_pages
| add_to_page_cache_locked(head,index=n+1)=0
add_to_page_cache_locked(head, index=n+1)=-EEXIST
then, will next loop with list head page's
index=n+1 and the page->mapping not NULL
readpages_get_pages
add_to_page_cache_locked(head, index=n+1)
commit_charge
VM_BUG_ON_PAGE
So, we should not do the next loop when any page add to page cache
failed.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-16 09:16:41 +09:00
..
2023-05-16 08:47:30 +09:00
2023-05-15 14:09:05 +09:00
2023-05-16 09:05:59 +09:00
2023-05-15 16:47:08 +09:00
2023-05-15 16:08:48 +09:00
2016-10-15 12:09:13 -07:00
2023-05-15 09:57:32 +09:00
2023-05-16 09:16:29 +09:00
2023-05-15 17:29:57 +09:00
2023-05-16 09:16:35 +09:00
2023-05-16 09:16:41 +09:00
2023-05-15 14:09:19 +09:00
2023-05-15 17:28:38 +09:00
2023-05-15 09:23:12 +09:00
2023-05-15 13:58:33 +09:00
2023-05-15 12:38:42 +09:00
2023-05-15 12:05:59 +09:00
2023-05-16 08:47:10 +09:00
2023-05-15 17:01:52 +09:00
2016-10-10 20:16:43 -07:00
2016-05-20 17:58:30 -07:00
2020-02-04 13:48:58 +09:00
2023-05-15 09:51:17 +09:00
2023-05-15 16:42:45 +09:00
2023-05-16 08:48:08 +09:00
2023-05-16 08:57:17 +09:00
2023-05-16 08:43:56 +09:00
2023-05-15 17:33:02 +09:00
2016-06-13 10:20:39 +02:00
2023-05-15 10:31:45 +09:00
2023-05-16 09:16:23 +09:00
2023-05-16 08:19:53 +09:00
2023-05-15 15:18:29 +09:00
2023-05-15 17:14:59 +09:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2023-05-15 12:59:23 +09:00
2017-11-30 08:39:04 +00:00
2023-05-16 08:57:16 +09:00
2023-05-16 08:54:54 +09:00
2023-05-15 16:44:34 +09:00
2023-05-15 15:09:25 +09:00
2023-05-15 09:22:56 +09:00
2018-03-02 13:27:29 -08:00
2023-05-16 08:47:27 +09:00
2023-05-15 11:49:44 +09:00
2023-05-16 09:13:13 +09:00
2018-02-03 17:05:38 +01:00
2023-05-16 08:18:35 +09:00
2023-05-15 17:32:23 +09:00
2023-05-15 11:16:44 +09:00
2016-10-30 13:09:42 -04:00
2023-05-16 08:48:09 +09:00
2016-10-10 20:16:43 -07:00
2016-09-27 21:06:21 -04:00
2023-05-15 16:59:58 +09:00
2023-05-15 17:32:42 +09:00
2023-05-15 17:32:44 +09:00
2023-05-15 16:32:06 +09:00
2016-05-09 11:41:14 -04:00
2016-05-09 11:41:14 -04:00
2023-05-15 16:21:05 +09:00
2016-10-10 20:16:43 -07:00
2023-05-15 16:59:50 +09:00
2023-05-16 08:54:39 +09:00
2020-12-17 17:32:09 +09:00
2023-05-12 17:14:36 +09:00
2023-05-12 17:16:51 +09:00
2023-05-15 10:31:02 +09:00
2016-09-27 21:06:21 -04:00
2023-05-16 09:16:04 +09:00
2023-05-15 16:58:58 +09:00
2023-05-16 08:48:37 +09:00
2023-05-16 09:15:51 +09:00
2023-05-15 10:36:26 +09:00
2017-01-31 10:47:22 -08:00
2017-01-09 08:32:24 +01:00
2016-05-28 16:34:59 -07:00
2016-07-25 16:51:49 +10:00
2023-05-15 17:30:19 +09:00
2016-08-02 19:35:15 -04:00
2023-05-15 13:55:59 +09:00
2018-06-26 08:08:09 +08:00
2023-05-15 14:54:58 +09:00
2023-05-16 09:16:10 +09:00
2023-05-16 08:57:17 +09:00
2023-05-15 17:27:22 +09:00
2018-02-25 11:05:55 +01:00
2023-05-15 16:30:53 +09:00
2016-09-27 21:20:53 -04:00
2017-07-05 16:18:14 +02:00
2018-02-28 10:18:33 +01:00
2023-05-15 12:07:04 +09:00
2023-05-15 11:45:37 +09:00
2023-05-15 11:50:41 +09:00
2016-03-22 15:36:02 -07:00
2023-05-16 09:04:33 +09:00
2023-05-15 17:28:10 +09:00
2018-01-31 12:55:52 +01:00
2016-03-22 15:36:02 -07:00
2023-05-15 17:28:32 +09:00
2016-01-19 12:02:23 -05:00
2017-01-31 15:46:26 -08:00
2023-05-16 08:57:38 +09:00
2023-05-15 17:11:10 +09:00
2017-09-20 09:59:51 +02:00
2016-09-15 13:29:52 -07:00
2017-09-20 08:19:59 +02:00
2017-09-26 00:32:37 -07:00
2016-08-12 16:47:05 +01:00
2023-05-15 17:12:18 +09:00
2023-05-15 16:30:25 +09:00
2017-09-26 00:32:37 -07:00
2018-02-22 15:43:48 +01:00
2017-07-21 07:42:22 +02:00
2018-12-17 17:21:59 +08:00
2023-05-15 17:02:00 +09:00
2023-05-15 17:23:05 +09:00
2018-02-17 13:21:15 +01:00
2023-05-15 17:09:26 +09:00
2023-05-15 13:40:35 +09:00
2023-05-15 17:24:29 +09:00
2017-03-15 02:21:16 +00:00
2017-01-26 08:24:37 +01:00
2017-01-31 10:47:20 -08:00
2023-05-15 13:41:13 +09:00
2023-05-15 16:21:37 +09:00
2016-10-11 15:06:30 -07:00
2016-10-07 18:46:30 -07:00
2023-05-15 13:40:35 +09:00
2017-06-14 15:06:01 +02:00
2023-05-15 11:16:43 +09:00
2017-03-14 13:16:06 -07:00
2017-05-08 07:47:54 +02:00
2023-05-15 14:21:05 +09:00
2017-01-31 10:47:21 -08:00
2023-05-16 08:45:19 +09:00