LKML Archive on
help / color / mirror / Atom feed
* xarray breaks thrashing detection and cgroup isolation
@ 2019-05-23 17:43 Johannes Weiner
  2019-05-23 18:37 ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Weiner @ 2019-05-23 17:43 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, linux-mm, linux-fsdevel, linux-kernel, kernel-team


I noticed that recent upstream kernels don't account the xarray nodes
of the page cache to the allocating cgroup, like we used to do for the
radix tree nodes.

This results in broken isolation for cgrouped apps, allowing them to
escape their containment and harm other cgroups and the system with an
excessive build-up of nonresident information.

It also breaks thrashing/refault detection because the page cache
lives in a different domain than the xarray nodes, and so the shadow
shrinker can reclaim nonresident information way too early when there
isn't much cache in the root cgroup.

This appears to be the culprit:

commit a28334862993b5c6a8766f6963ee69048403817c
Author: Matthew Wilcox <>
Date:   Tue Dec 5 19:04:20 2017 -0500

    page cache: Finish XArray conversion
    With no more radix tree API users left, we can drop the GFP flags
    and use xa_init() instead of INIT_RADIX_TREE().
    Signed-off-by: Matthew Wilcox <>

diff --git a/fs/inode.c b/fs/inode.c
index 42f6d25f32a5..9b808986d440 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -349,7 +349,7 @@ EXPORT_SYMBOL(inc_nlink);
 static void __address_space_init_once(struct address_space *mapping)
-       INIT_RADIX_TREE(&mapping->i_pages, GFP_ATOMIC | __GFP_ACCOUNT);
+       xa_init_flags(&mapping->i_pages, XA_FLAGS_LOCK_IRQ);

It fairly blatantly drops __GFP_ACCOUNT.

I'm not quite sure how to fix this, since the xarray code doesn't seem
to have per-tree gfp flags anymore like the radix tree did. We cannot
add SLAB_ACCOUNT to the radix_tree_node_cachep slab cache. And the
xarray api doesn't seem to really support gfp flags, either (xas_nomem
does, but the optimistic internal allocations have fixed gfp flags).

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-24 17:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 17:43 xarray breaks thrashing detection and cgroup isolation Johannes Weiner
2019-05-23 18:37 ` Matthew Wilcox
2019-05-23 18:49   ` Shakeel Butt
2019-05-23 19:00     ` Matthew Wilcox
2019-05-23 19:21       ` Johannes Weiner
2019-05-23 19:41         ` Matthew Wilcox
2019-05-23 19:59           ` Johannes Weiner
2019-05-24 16:11             ` Matthew Wilcox
2019-05-24 17:06               ` Johannes Weiner
2019-05-24 17:18                 ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).