From: Michal Hocko <mhocko@kernel.org>
To: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] radix-tree: account nodes to memcg only if explicitly requested
Date: Tue, 2 Aug 2016 13:51:12 +0200 [thread overview]
Message-ID: <20160802115111.GG12403@dhcp22.suse.cz> (raw)
In-Reply-To: <1470057188-7864-1-git-send-email-vdavydov@virtuozzo.com>
On Mon 01-08-16 16:13:08, Vladimir Davydov wrote:
> Radix trees may be used not only for storing page cache pages, so
> unconditionally accounting radix tree nodes to the current memory cgroup
> is bad: if a radix tree node is used for storing data shared among
> different cgroups we risk pinning dead memory cgroups forever. So let's
> only account radix tree nodes if it was explicitly requested by passing
> __GFP_ACCOUNT to INIT_RADIX_TREE. Currently, we only want to account
> page cache entries, so mark mapping->page_tree so.
>
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
OK, the patch makes sense to me. Such a false sharing would be really
tedious to debug
Do we want to mark it for stable 4.6 to prevent from some pathological
issues. The patch is simple enough.
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> fs/inode.c | 2 +-
> lib/radix-tree.c | 14 ++++++++++----
> 2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/fs/inode.c b/fs/inode.c
> index 559a9da25237..1d04dab5211c 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -345,7 +345,7 @@ EXPORT_SYMBOL(inc_nlink);
> void address_space_init_once(struct address_space *mapping)
> {
> memset(mapping, 0, sizeof(*mapping));
> - INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC);
> + INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC | __GFP_ACCOUNT);
> spin_lock_init(&mapping->tree_lock);
> init_rwsem(&mapping->i_mmap_rwsem);
> INIT_LIST_HEAD(&mapping->private_list);
> diff --git a/lib/radix-tree.c b/lib/radix-tree.c
> index 61b8fb529cef..1b7bf7314141 100644
> --- a/lib/radix-tree.c
> +++ b/lib/radix-tree.c
> @@ -277,10 +277,11 @@ radix_tree_node_alloc(struct radix_tree_root *root)
>
> /*
> * Even if the caller has preloaded, try to allocate from the
> - * cache first for the new node to get accounted.
> + * cache first for the new node to get accounted to the memory
> + * cgroup.
> */
> ret = kmem_cache_alloc(radix_tree_node_cachep,
> - gfp_mask | __GFP_ACCOUNT | __GFP_NOWARN);
> + gfp_mask | __GFP_NOWARN);
> if (ret)
> goto out;
>
> @@ -303,8 +304,7 @@ radix_tree_node_alloc(struct radix_tree_root *root)
> kmemleak_update_trace(ret);
> goto out;
> }
> - ret = kmem_cache_alloc(radix_tree_node_cachep,
> - gfp_mask | __GFP_ACCOUNT);
> + ret = kmem_cache_alloc(radix_tree_node_cachep, gfp_mask);
> out:
> BUG_ON(radix_tree_is_internal_node(ret));
> return ret;
> @@ -351,6 +351,12 @@ static int __radix_tree_preload(gfp_t gfp_mask, int nr)
> struct radix_tree_node *node;
> int ret = -ENOMEM;
>
> + /*
> + * Nodes preloaded by one cgroup can be be used by another cgroup, so
> + * they should never be accounted to any particular memory cgroup.
> + */
> + gfp_mask &= ~__GFP_ACCOUNT;
> +
> preempt_disable();
> rtp = this_cpu_ptr(&radix_tree_preloads);
> while (rtp->nr < nr) {
> --
> 2.1.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-08-02 11:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 13:13 [PATCH] radix-tree: account nodes to memcg only if explicitly requested Vladimir Davydov
2016-08-01 15:24 ` Johannes Weiner
2016-08-01 16:06 ` Vladimir Davydov
2016-08-01 17:14 ` Johannes Weiner
2016-08-02 11:51 ` Michal Hocko [this message]
2016-08-02 12:42 ` Vladimir Davydov
2016-08-02 12:46 ` Michal Hocko
2016-08-02 18:51 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160802115111.GG12403@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vdavydov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).