public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Yang Shi <yang.shi@linux.alibaba.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Kirill Tkhai <ktkhai@virtuozzo.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.com>, Hugh Dickins <hughd@google.com>,
	Shakeel Butt <shakeelb@google.com>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Roman Gushchin <guro@fb.com>, Chris Down <chris@chrisdown.name>,
	Yafang Shao <laoar.shao@gmail.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] vmscan: fix memcg_kmem build failure
Date: Mon,  8 Jul 2019 14:41:03 +0200	[thread overview]
Message-ID: <20190708124120.3400683-1-arnd@arndb.de> (raw)

When CONFIG_MEMCG_KMEM is disabled, we get a build failure
for calling a nonexisting memcg_expand_shrinker_maps():

mm/vmscan.c:220:7: error: implicit declaration of function 'memcg_expand_shrinker_maps' [-Werror,-Wimplicit-function-declaration]
                if (memcg_expand_shrinker_maps(id)) {
                    ^
mm/vmscan.c:220:7: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
mm/vmscan.c:608:56: error: no member named 'shrinker_map' in 'struct mem_cgroup_per_node'
        map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map,
                                        ~~~~~~~~~~~~~~~~~~~~  ^
include/linux/rcupdate.h:498:31: note: expanded from macro 'rcu_dereference_protected'
        __rcu_dereference_protected((p), (c), __rcu)
                                     ^
include/linux/rcupdate.h:321:12: note: expanded from macro '__rcu_dereference_protected'
        ((typeof(*p) __force __kernel *)(p)); \
                  ^
mm/vmscan.c:608:6: error: assigning to 'struct memcg_shrinker_map *' from incompatible type 'void'
        map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map,

and another issue trying to access invalid struct fields:

mm/vmscan.c:608:56: error: no member named 'shrinker_map' in 'struct mem_cgroup_per_node'
        map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map,
                                        ~~~~~~~~~~~~~~~~~~~~  ^
include/linux/rcupdate.h:498:31: note: expanded from macro 'rcu_dereference_protected'
        __rcu_dereference_protected((p), (c), __rcu)
                                     ^
include/linux/rcupdate.h:321:12: note: expanded from macro '__rcu_dereference_protected'
        ((typeof(*p) __force __kernel *)(p)); \
                  ^
mm/vmscan.c:608:6: error: assigning to 'struct memcg_shrinker_map *' from incompatible type 'void'
        map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map,

Add a dummy definition for memcg_expand_shrinker_maps() that always fails,
and hide the obviously nonworking shrink_slab_memcg() function.

Fixes: 8236f517d69e ("mm: shrinker: make shrinker not depend on memcg kmem")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
No idea what the intended behavior is supposed to be for this case.
Rather than failing, should we actually provide that function?
Or maybe a more elaborate change is needed?
---
 include/linux/memcontrol.h | 5 +++++
 mm/vmscan.c                | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 5901a90f58eb..6b15e2066fc7 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1407,6 +1407,11 @@ static inline void memcg_put_cache_ids(void)
 {
 }
 
+static inline int memcg_expand_shrinker_maps(int new_id)
+{
+	return -ENOMEM;
+}
+
 static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
 					  int nid, int shrinker_id) { }
 #endif /* CONFIG_MEMCG_KMEM */
diff --git a/mm/vmscan.c b/mm/vmscan.c
index a0301edd8d03..323a9c50c0fe 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -591,7 +591,7 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
 	return freed;
 }
 
-#ifdef CONFIG_MEMCG
+#ifdef CONFIG_MEMCG_KMEM
 static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
 			struct mem_cgroup *memcg, int priority)
 {
-- 
2.20.0


             reply	other threads:[~2019-07-08 12:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 12:41 Arnd Bergmann [this message]
2019-07-08 13:27 ` [PATCH] vmscan: fix memcg_kmem build failure Arnd Bergmann

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=20190708124120.3400683-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chrisdown.name \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=ktkhai@virtuozzo.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=shakeelb@google.com \
    --cc=yang.shi@linux.alibaba.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