rue/mm: fix file page_counter 'memcg->pagecache' error when THP enabled
When the CONFIG_MEM_QPS feature is enabled, the __mod_lruvec_state function is called to increase the page_counter 'pagecache' value in per-memcg by 'NR_FILE_PAGES', which is not a problem if THP is not enabled, but if THP is enabled, the CONFIG_MEM_QPS feature forgot to increase the value of page_counter 'pagecache', because THP pagecache becomes 'NR_FILE_THPS' type. it will lead to the page_counter 'pagecache' val becomes negative val when these THP pagecache pages is released, so the results in the following warning situation. [55530.397796] ------------[ cut here ]------------ [55530.398854] page_counter underflow: -512 nr_pages=512 [55530.399864] WARNING: CPU: 1 PID: 3026157 at mm/page_counter.c:63 page_counter_cancel+0x55/0x60 [55530.412193] CPU: 1 PID: 3026157 Comm: bash Kdump: loaded Tainted: G [55530.416075] RIP: 0010:page_counter_cancel+0x55/0x60 [55530.421353] RAX: 0000000000000000 RBX: ffff8888161a8270 RCX: 0000000000000006 [55530.422680] RDX: 0000000000000007 RSI: 0000000000000092 RDI: ffff88881f85bb60 [55530.424008] RBP: ffffc90004ceba58 R08: 0000000000009617 R09: ffff88881584c820 [55530.425330] R10: 0000000000000000 R11: ffffffffa00d60b0 R12: 0000000000000200 [55530.426663] R13: ffff8888194f7000 R14: 0000000000000000 R15: 0000000000000000 [55530.427999] FS: 00007fe2932d1740(0000) GS:ffff88881f840000(0000) knlGS:0000000000000000 [55530.429447] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [55530.430645] CR2: 00007f97c4e00000 CR3: 00000007e7256004 CR4: 00000000003706e0 [55530.432007] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [55530.433360] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [55530.434711] Call Trace: [55530.435541] page_counter_uncharge+0x22/0x40 [55530.436571] __mod_memcg_state.part.80+0x79/0xe0 [55530.437645] __mod_memcg_lruvec_state+0x27/0x110 [55530.438712] __mod_lruvec_state+0x39/0x40 [55530.439712] unaccount_page_cache_page+0xd0/0x210 [55530.440803] __delete_from_page_cache+0x3d/0x1d0 [55530.441877] __remove_mapping+0xeb/0x220 [55530.442871] remove_mapping+0x16/0x30 [55530.443836] invalidate_inode_page+0x84/0x90 [55530.444869] invalidate_mapping_pages+0x162/0x3e0 [55530.445957] ? pick_next_task_fair+0x1f2/0x520 [55530.446996] drop_pagecache_sb+0xac/0x130 [55530.447972] iterate_supers+0xa2/0x110 [55530.448907] ? do_coredump+0xb20/0xb20 [55530.449840] drop_caches_sysctl_handler+0x5d/0x90 [55530.450893] proc_sys_call_handler+0x1d0/0x290 [55530.451906] proc_sys_write+0x14/0x20 [55530.452830] __vfs_write+0x1b/0x40 [55530.453722] vfs_write+0xab/0x1b0 [55530.454598] ksys_write+0x61/0xe0 [55530.455471] __x64_sys_write+0x1a/0x20 [55530.456392] do_syscall_64+0x4d/0x120 [55530.457296] entry_SYSCALL_64_after_hwframe+0x5c/0xc1 [55530.458346] RIP: 0033:0x7fe292836bc8 Fixes: a0d7d9851512 ("rue/mm: pagecache limit per cgroup support") Signed-off-by: Xin Hao <vernhao@tencent.com>
This commit is contained in:
parent
b82ababba6
commit
4e6f350b03
|
@ -1794,6 +1794,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
|
|||
struct page *page;
|
||||
struct page *tmp;
|
||||
struct folio *folio;
|
||||
struct mem_cgroup *memcg;
|
||||
pgoff_t index = 0, end = start + HPAGE_PMD_NR;
|
||||
LIST_HEAD(pagelist);
|
||||
XA_STATE_ORDER(xas, &mapping->i_pages, start, HPAGE_PMD_ORDER);
|
||||
|
@ -2123,8 +2124,14 @@ immap_locked:
|
|||
nr = thp_nr_pages(hpage);
|
||||
if (is_shmem)
|
||||
__mod_lruvec_page_state(hpage, NR_SHMEM_THPS, nr);
|
||||
else
|
||||
else {
|
||||
memcg = page_memcg(hpage);
|
||||
|
||||
if (!mem_cgroup_disabled() && memcg)
|
||||
page_counter_charge(&memcg->pagecache, nr);
|
||||
|
||||
__mod_lruvec_page_state(hpage, NR_FILE_THPS, nr);
|
||||
}
|
||||
|
||||
if (nr_none) {
|
||||
__mod_lruvec_page_state(hpage, NR_FILE_PAGES, nr_none);
|
||||
|
|
Loading…
Reference in New Issue