linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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 3/3] memcg: simplify and inline __mem_cgroup_from_kmem
Date: Thu, 8 Oct 2015 17:13:18 +0200	[thread overview]
Message-ID: <20151008151318.GG426@dhcp22.suse.cz> (raw)
In-Reply-To: <517ab1701f4b53be8bfd6691a1499598efb358e7.1443996201.git.vdavydov@virtuozzo.com>

On Mon 05-10-15 01:21:43, Vladimir Davydov wrote:
> Before the previous patch, __mem_cgroup_from_kmem had to handle two
> types of kmem - slab pages and pages allocated with alloc_kmem_pages -
> differently, because slab pages did not store information about owner
> memcg in the page struct. Now we can unify it. Since after it, this
> function becomes tiny we can fold it into mem_cgroup_from_kmem.
> 
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/memcontrol.h |  7 ++++---
>  mm/memcontrol.c            | 18 ------------------
>  2 files changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 8a9b7a798f14..0e2e039609d1 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -769,8 +769,6 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
>  struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep);
>  void __memcg_kmem_put_cache(struct kmem_cache *cachep);
>  
> -struct mem_cgroup *__mem_cgroup_from_kmem(void *ptr);
> -
>  static inline bool __memcg_kmem_bypass(gfp_t gfp)
>  {
>  	if (!memcg_kmem_enabled())
> @@ -832,9 +830,12 @@ static __always_inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
>  
>  static __always_inline struct mem_cgroup *mem_cgroup_from_kmem(void *ptr)
>  {
> +	struct page *page;
> +
>  	if (!memcg_kmem_enabled())
>  		return NULL;
> -	return __mem_cgroup_from_kmem(ptr);
> +	page = virt_to_head_page(ptr);
> +	return page->mem_cgroup;
>  }
>  #else
>  #define for_each_memcg_cache_index(_idx)	\
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 1d6413e0dd29..6329e6182d89 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2430,24 +2430,6 @@ void __memcg_kmem_uncharge(struct page *page, int order)
>  	page->mem_cgroup = NULL;
>  	css_put_many(&memcg->css, nr_pages);
>  }
> -
> -struct mem_cgroup *__mem_cgroup_from_kmem(void *ptr)
> -{
> -	struct mem_cgroup *memcg = NULL;
> -	struct kmem_cache *cachep;
> -	struct page *page;
> -
> -	page = virt_to_head_page(ptr);
> -	if (PageSlab(page)) {
> -		cachep = page->slab_cache;
> -		if (!is_root_cache(cachep))
> -			memcg = cachep->memcg_params.memcg;
> -	} else
> -		/* page allocated by alloc_kmem_pages */
> -		memcg = page->mem_cgroup;
> -
> -	return memcg;
> -}
>  #endif /* CONFIG_MEMCG_KMEM */
>  
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> -- 
> 2.1.4

-- 
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>

  reply	other threads:[~2015-10-08 15:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-04 22:21 [PATCH 1/3] memcg: simplify charging kmem pages Vladimir Davydov
2015-10-04 22:21 ` [PATCH 2/3] memcg: unify slab and other kmem pages charging Vladimir Davydov
2015-10-08 15:10   ` Michal Hocko
2015-10-17  0:19   ` Johannes Weiner
2015-10-17 15:05     ` Vladimir Davydov
2015-10-19  8:09     ` Michal Hocko
2015-10-04 22:21 ` [PATCH 3/3] memcg: simplify and inline __mem_cgroup_from_kmem Vladimir Davydov
2015-10-08 15:13   ` Michal Hocko [this message]
2015-10-16 13:17   ` Kirill A. Shutemov
2015-10-16 13:51     ` Vladimir Davydov
2015-10-16 22:12       ` Hugh Dickins
2015-10-16 22:19         ` Johannes Weiner
2015-10-16 22:21         ` Andrew Morton
2015-10-17 14:58         ` Vladimir Davydov
2015-10-19  8:08         ` Michal Hocko
2015-10-16 14:36     ` Michal Hocko
2015-10-08 14:40 ` [PATCH 1/3] memcg: simplify charging kmem pages Michal Hocko

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=20151008151318.GG426@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).