Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1454466
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Michal Hocko <mhocko@kernel.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] radix-tree: account nodes to memcg only if explicitly requested |
| Date | Tue, 02 Aug 2016 16:00:03 +0200 |
| Message-ID | <s1HCh-4RK-9@gated-at.bofh.it> (permalink) |
| References | <s1nke-834-19@gated-at.bofh.it> |
| X-Original-To | Vladimir Davydov <vdavydov@virtuozzo.com> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x0gHp/aNNkVEMw6SgwbRIGyT9aiw5RXZu81LudokLn8=; b=PODfGHiubxdjY1WYEPOOLnr00NJy9BZWvjvisdobRVxNgctJ5t4QKZDwd2jS7jh0V+ HqRrKWl1tNJ0zWsAs0+VpALNFUe8rZIyEzIlVjKv7K2GB0F0RIcaQs4XlCvWwFpwsUSG NjgW6bwQNh2bp9rTwG4v5K1yQdnCBmqJNXI3SsPsKdhquFuTtLQAvjeDZcJOcTUaba3b sv121BziI0LuYnQRdw2Y6vJMP+w5tkmeYRRkMhJjS+cut3TkPIVYlDQDTgM4Xz53vkHf CAL19TGc8VEmktC5L+2PolNOwG9fjfcsiUqNi5s5HKvJ+MXLzDj+1XnDXE8cbv07Q7xH d4Dw== |
| X-Gm-Message-State | AEkoousMGcXRkCsOEpVIPhmJ+qnYQo/Cmb3ueVtFMT47Oa6wj+s9l4ezhItS1X9KHWYv8Q== |
| X-Received | by 10.66.43.164 with SMTP id x4mr5695256pal.11.1470138675659; Tue, 02 Aug 2016 04:51:15 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.6.0 (2016-04-01) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 90 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Andrew Morton <akpm@linux-foundation.org>, Johannes Weiner <hannes@cmpxchg.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Tue, 2 Aug 2016 13:51:12 +0200 |
| X-Original-Message-ID | <20160802115111.GG12403@dhcp22.suse.cz> |
| X-Original-References | <1470057188-7864-1-git-send-email-vdavydov@virtuozzo.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1454466 |
Show key headers only | View raw
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
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH] radix-tree: account nodes to memcg only if explicitly requested Michal Hocko <mhocko@kernel.org> - 2016-08-02 16:00 +0200
csiph-web