Johannes Weiner
9ea9cb00a8
mm: memcontrol: fix GFP_NOFS recursion in memory.high enforcement
Breno and Josef report a deadlock scenario from cgroup reclaim
re-entering the filesystem:
[ 361.546690] ======================================================
[ 361.559210] WARNING: possible circular locking dependency detected
[ 361.571703] 6.5.0-0_fbk700_debug_rc0_kbuilder_13159_gbf787a128001 #1 Tainted: G S E
[ 361.589704] ------------------------------------------------------
[ 361.602277] find/9315 is trying to acquire lock:
[ 361.611625] ffff88837ba140c0 (&delayed_node->mutex){+.+.}-{4:4}, at: __btrfs_release_delayed_node+0x68/0x4f0
[ 361.631437]
[ 361.631437] but task is already holding lock:
[ 361.643243] ffff8881765b8678 (btrfs-tree-01){++++}-{4:4}, at: btrfs_tree_read_lock+0x1e/0x40
[ 362.904457] mutex_lock_nested+0x1c/0x30
[ 362.912414] __btrfs_release_delayed_node+0x68/0x4f0
[ 362.922460] btrfs_evict_inode+0x301/0x770
[ 362.982726] evict+0x17c/0x380
[ 362.988944] prune_icache_sb+0x100/0x1d0
[ 363.005559] super_cache_scan+0x1f8/0x260
[ 363.013695] do_shrink_slab+0x2a2/0x540
[ 363.021489] shrink_slab_memcg+0x237/0x3d0
[ 363.050606] shrink_slab+0xa7/0x240
[ 363.083382] shrink_node_memcgs+0x262/0x3b0
[ 363.091870] shrink_node+0x1a4/0x720
[ 363.099150] shrink_zones+0x1f6/0x5d0
[ 363.148798] do_try_to_free_pages+0x19b/0x5e0
[ 363.157633] try_to_free_mem_cgroup_pages+0x266/0x370
[ 363.190575] reclaim_high+0x16f/0x1f0
[ 363.208409] mem_cgroup_handle_over_high+0x10b/0x270
[ 363.246678] try_charge_memcg+0xaf2/0xc70
[ 363.304151] charge_memcg+0xf0/0x350
[ 363.320070] __mem_cgroup_charge+0x28/0x40
[ 363.328371] __filemap_add_folio+0x870/0xd50
[ 363.371303] filemap_add_folio+0xdd/0x310
[ 363.399696] __filemap_get_folio+0x2fc/0x7d0
[ 363.419086] pagecache_get_page+0xe/0x30
[ 363.427048] alloc_extent_buffer+0x1cd/0x6a0
[ 363.435704] read_tree_block+0x43/0xc0
[ 363.443316] read_block_for_search+0x361/0x510
[ 363.466690] btrfs_search_slot+0xc8c/0x1520
This is caused by the mem_cgroup_handle_over_high() not respecting the
gfp_mask of the allocation context. We used to only call this function on
resume to userspace, where no locks were held. But c9afe31ec4 ("memcg:
synchronously enforce memory.high for large overcharges") added a call
from the allocation context without considering the gfp.
Link: https://lkml.kernel.org/r/20230914152139.100822-1-hannes@cmpxchg.org
Fixes: c9afe31ec4 ("memcg: synchronously enforce memory.high for large overcharges")
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Breno Leitao <leitao@debian.org>
Reported-by: Josef Bacik <josef@toxicpanda.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: <stable@vger.kernel.org> [5.17+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-09-19 13:21:34 -07:00
..
2023-08-31 14:56:27 +02:00
2023-08-22 14:13:11 -07:00
2023-09-01 09:53:54 -07:00
2023-08-22 16:32:35 +02:00
2023-09-01 09:53:54 -07:00
2023-08-29 17:45:22 -04:00
2023-09-04 13:47:59 -07:00
2023-08-23 08:25:28 +01:00
2023-08-27 17:08:45 -07:00
2023-08-25 11:45:51 +02:00
2023-08-28 16:37:38 +02:00
2023-08-25 07:42:58 +01:00
2023-09-01 08:09:48 -07:00
2023-09-07 16:07:35 -07:00
2023-08-23 08:21:37 +01:00
2023-09-06 22:53:55 +08:00
2023-08-29 14:53:51 -07:00
2023-08-30 19:53:39 -07:00
2023-09-03 10:20:57 -07:00
2023-08-31 15:36:41 -07:00
2023-09-01 09:23:34 -07:00
2023-08-25 20:55:47 +02:00
2023-08-31 01:29:28 +02:00
2023-08-21 13:38:01 -07:00
2023-08-30 17:35:54 +08:00
2023-08-30 17:35:54 +08:00
2023-08-30 17:35:54 +08:00
2023-08-25 09:23:16 -07:00
2023-08-31 22:01:06 +02:00
2023-09-02 11:10:50 -07:00
2023-09-17 10:33:53 -07:00
2023-08-24 16:20:25 -07:00
2023-09-01 15:58:21 -07:00
2023-08-22 13:51:26 -07:00
2023-08-28 15:04:43 -07:00
2023-08-29 20:51:40 +02:00
2023-08-24 16:25:13 -07:00
2023-08-21 13:37:37 -07:00
2023-08-24 16:20:30 -07:00
2023-09-01 09:43:18 -07:00
2023-08-25 16:07:30 -07:00
2023-08-30 13:34:34 -07:00
2023-08-23 14:17:42 -07:00
2023-09-12 17:42:00 +02:00
2023-09-01 00:29:34 +02:00
2023-08-28 11:04:18 -07:00
2023-08-31 12:47:15 +02:00
2023-08-22 05:20:34 -04:00
2023-08-31 10:38:03 +02:00
2023-08-21 14:28:43 -07:00
2023-08-21 14:28:43 -07:00
2023-09-04 11:26:29 -07:00
2023-09-13 10:48:48 +02:00
2023-08-22 21:43:27 +02:00
2023-08-25 08:08:27 +01:00
2023-09-07 11:19:36 -07:00
2023-09-12 17:50:53 +02:00
2023-08-22 01:11:32 +03:00
2023-08-24 17:16:20 -06:00
2023-08-29 20:21:42 -07:00
2023-09-01 16:54:25 -07:00
2023-09-01 08:11:51 +01:00
2023-09-06 22:54:16 +08:00
2023-08-21 13:46:24 -07:00
2023-08-24 16:25:14 -07:00
2023-08-31 13:48:50 -04:00
2023-09-11 15:09:11 +09:00
2023-08-30 09:07:09 -07:00
2023-08-24 16:20:32 -07:00
2023-08-21 13:37:47 -07:00
2023-09-19 13:21:34 -07:00
2023-08-21 13:37:48 -07:00
2023-08-21 13:37:49 -07:00
2023-09-06 20:49:04 -07:00
2023-08-30 13:45:05 -07:00
2023-08-24 16:20:28 -07:00
2023-08-31 12:20:12 -07:00
2023-09-05 05:34:14 -04:00
2023-08-23 16:34:02 +02:00
2023-09-05 13:02:13 -05:00
2023-09-09 08:18:16 -05:00
2023-08-21 13:37:31 -07:00
2023-08-24 16:20:18 -07:00
2023-08-21 14:28:45 -07:00
2023-08-29 14:25:26 -07:00
2023-09-01 09:38:00 -07:00
2023-08-30 20:23:07 -07:00
2023-08-25 08:06:53 -07:00
2023-09-01 08:09:48 -07:00
2023-08-31 12:20:12 -07:00
2023-09-06 07:46:49 +01:00
2023-08-21 13:37:59 -07:00
2023-08-22 21:31:57 +02:00
2023-08-22 22:03:43 +02:00
2023-08-24 21:34:28 -04:00
2023-09-19 13:21:34 -07:00
2023-09-02 15:17:33 -07:00
2023-08-27 23:50:22 +02:00
2023-08-30 10:08:38 +02:00
2023-08-24 16:20:31 -07:00
2023-08-30 09:07:09 -07:00
2023-08-22 11:10:26 -06:00
2023-08-21 13:46:24 -07:00
2023-08-28 12:55:04 -07:00
2023-08-24 16:20:28 -07:00
2023-08-21 13:37:26 -07:00
2023-08-31 12:20:12 -07:00
2023-09-11 17:16:40 +02:00
2023-09-11 18:22:00 -04:00
2023-08-22 14:58:15 +02:00
2023-08-22 14:58:15 +02:00
2023-08-27 11:47:44 +02:00
2023-09-03 18:10:22 -04:00
2023-08-24 13:27:47 -05:00
2023-09-04 13:44:11 -07:00
2023-09-05 19:01:38 -04:00
2023-08-21 13:37:27 -07:00