From: Vladimir Davydov <vdavydov@virtuozzo.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] memcg: simplify and inline __mem_cgroup_from_kmem
Date: Sat, 17 Oct 2015 17:58:44 +0300 [thread overview]
Message-ID: <20151017145843.GL11309@esperanza> (raw)
In-Reply-To: <alpine.LSU.2.11.1510161458280.26747@eggly.anvils>
On Fri, Oct 16, 2015 at 03:12:23PM -0700, Hugh Dickins wrote:
...
> Are you expecting to use mem_cgroup_from_kmem() from other places
> in future? Seems possible; but at present it's called from only
Not in the near future. At least, currently I can't think of any other
use for it except list_lru_from_kmem.
> one place, and (given how memcontrol.h has somehow managed to avoid
> including mm.h all these years), I thought it would be nice to avoid
> it for just this; and fixed my build with the patch below last night.
> Whatever you all think best: just wanted to point out an alternative.
Makes sense, thanks!
I would even inline mem_cgroup_from_kmem to list_lru_from_kmem:
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 47677acb4516..2077b9bb4883 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -831,16 +831,6 @@ static __always_inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
if (memcg_kmem_enabled())
__memcg_kmem_put_cache(cachep);
}
-
-static __always_inline struct mem_cgroup *mem_cgroup_from_kmem(void *ptr)
-{
- struct page *page;
-
- if (!memcg_kmem_enabled())
- return NULL;
- page = virt_to_head_page(ptr);
- return page->mem_cgroup;
-}
#else
#define for_each_memcg_cache_index(_idx) \
for (; NULL; )
@@ -886,11 +876,6 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
static inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
{
}
-
-static inline struct mem_cgroup *mem_cgroup_from_kmem(void *ptr)
-{
- return NULL;
-}
#endif /* CONFIG_MEMCG_KMEM */
#endif /* _LINUX_MEMCONTROL_H */
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 28237476b055..00d0a70af70a 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -68,10 +68,10 @@ list_lru_from_kmem(struct list_lru_node *nlru, void *ptr)
{
struct mem_cgroup *memcg;
- if (!nlru->memcg_lrus)
+ if (!memcg_kmem_enabled() || !nlru->memcg_lrus)
return &nlru->lru;
- memcg = mem_cgroup_from_kmem(ptr);
+ memcg = virt_to_head_page(ptr)->mem_cgroup;
if (!memcg)
return &nlru->lru;
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@virtuozzo.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] memcg: simplify and inline __mem_cgroup_from_kmem
Date: Sat, 17 Oct 2015 17:58:44 +0300 [thread overview]
Message-ID: <20151017145843.GL11309@esperanza> (raw)
In-Reply-To: <alpine.LSU.2.11.1510161458280.26747@eggly.anvils>
On Fri, Oct 16, 2015 at 03:12:23PM -0700, Hugh Dickins wrote:
...
> Are you expecting to use mem_cgroup_from_kmem() from other places
> in future? Seems possible; but at present it's called from only
Not in the near future. At least, currently I can't think of any other
use for it except list_lru_from_kmem.
> one place, and (given how memcontrol.h has somehow managed to avoid
> including mm.h all these years), I thought it would be nice to avoid
> it for just this; and fixed my build with the patch below last night.
> Whatever you all think best: just wanted to point out an alternative.
Makes sense, thanks!
I would even inline mem_cgroup_from_kmem to list_lru_from_kmem:
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 47677acb4516..2077b9bb4883 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -831,16 +831,6 @@ static __always_inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
if (memcg_kmem_enabled())
__memcg_kmem_put_cache(cachep);
}
-
-static __always_inline struct mem_cgroup *mem_cgroup_from_kmem(void *ptr)
-{
- struct page *page;
-
- if (!memcg_kmem_enabled())
- return NULL;
- page = virt_to_head_page(ptr);
- return page->mem_cgroup;
-}
#else
#define for_each_memcg_cache_index(_idx) \
for (; NULL; )
@@ -886,11 +876,6 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
static inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
{
}
-
-static inline struct mem_cgroup *mem_cgroup_from_kmem(void *ptr)
-{
- return NULL;
-}
#endif /* CONFIG_MEMCG_KMEM */
#endif /* _LINUX_MEMCONTROL_H */
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 28237476b055..00d0a70af70a 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -68,10 +68,10 @@ list_lru_from_kmem(struct list_lru_node *nlru, void *ptr)
{
struct mem_cgroup *memcg;
- if (!nlru->memcg_lrus)
+ if (!memcg_kmem_enabled() || !nlru->memcg_lrus)
return &nlru->lru;
- memcg = mem_cgroup_from_kmem(ptr);
+ memcg = virt_to_head_page(ptr)->mem_cgroup;
if (!memcg)
return &nlru->lru;
next prev parent reply other threads:[~2015-10-17 14:59 UTC|newest]
Thread overview: 33+ 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 ` Vladimir Davydov
2015-10-04 22:21 ` [PATCH 2/3] memcg: unify slab and other kmem pages charging Vladimir Davydov
2015-10-04 22:21 ` Vladimir Davydov
2015-10-08 15:10 ` Michal Hocko
2015-10-08 15:10 ` Michal Hocko
2015-10-17 0:19 ` Johannes Weiner
2015-10-17 0:19 ` Johannes Weiner
2015-10-17 15:05 ` Vladimir Davydov
2015-10-17 15:05 ` Vladimir Davydov
2015-10-19 8:09 ` Michal Hocko
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-04 22:21 ` Vladimir Davydov
2015-10-08 15:13 ` Michal Hocko
2015-10-08 15:13 ` Michal Hocko
2015-10-16 13:17 ` Kirill A. Shutemov
2015-10-16 13:17 ` Kirill A. Shutemov
2015-10-16 13:51 ` Vladimir Davydov
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:19 ` Johannes Weiner
2015-10-16 22:21 ` Andrew Morton
2015-10-16 22:21 ` Andrew Morton
2015-10-17 14:58 ` Vladimir Davydov [this message]
2015-10-17 14:58 ` Vladimir Davydov
2015-10-19 8:08 ` Michal Hocko
2015-10-19 8:08 ` Michal Hocko
2015-10-16 14:36 ` Michal Hocko
2015-10-16 14:36 ` Michal Hocko
2015-10-08 14:40 ` [PATCH 1/3] memcg: simplify charging kmem pages Michal Hocko
2015-10-08 14:40 ` 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=20151017145843.GL11309@esperanza \
--to=vdavydov@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.