Re: mmotm 2019-07-06-22-00 uploaded

From: Yang Shi
Date: Mon Jul 08 2019 - 14:38:33 EST


On Mon, Jul 8, 2019 at 7:29 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Sun, Jul 7, 2019 at 7:05 AM <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > * mm-move-mem_cgroup_uncharge-out-of-__page_cache_release.patch
> > * mm-shrinker-make-shrinker-not-depend-on-memcg-kmem.patch
> > * mm-shrinker-make-shrinker-not-depend-on-memcg-kmem-fix.patch
> > * mm-thp-make-deferred-split-shrinker-memcg-aware.patch
>
> mm-shrinker-make-shrinker-not-depend-on-memcg-kmem-fix.patch fixes
> the compile-time error when memcg_expand_shrinker_maps() is not
> declared, but now we get a linker error instead because the
> function is still not built into the kernel:
>
> mm/vmscan.o: In function `prealloc_shrinker':
> vmscan.c:(.text+0x328): undefined reference to `memcg_expand_shrinker_maps'

Sorry for chiming in late, I just came back from vacation.

The below patch should fix the issue, which is for linux-next
2019-07-08 on top of Andrew's fix. And, this patch fixed the redundant
#ifdef CONFIG_MEMCG problem pointed out by Randy. Copied Randy too.

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index b7a1f98..5c4b15eb 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -128,9 +128,8 @@ struct mem_cgroup_per_node {

struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1];

-#ifdef CONFIG_MEMCG
struct memcg_shrinker_map __rcu *shrinker_map;
-#endif
+
struct rb_node tree_node; /* RB tree node */
unsigned long usage_in_excess;/* Set to the value by which */
/* the soft limit is exceeded*/
@@ -1296,6 +1295,8 @@ static inline bool
mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
struct kmem_cache *memcg_kmem_get_cache(struct kmem_cache *cachep);
void memcg_kmem_put_cache(struct kmem_cache *cachep);
extern int memcg_expand_shrinker_maps(int new_id);
+extern void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
+ int nid, int shrinker_id);

#ifdef CONFIG_MEMCG_KMEM
int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order);
@@ -1363,8 +1364,6 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
return memcg ? memcg->kmemcg_id : -1;
}

-extern void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
- int nid, int shrinker_id);
#else

static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
@@ -1405,9 +1404,6 @@ static inline void memcg_get_cache_ids(void)
static inline void memcg_put_cache_ids(void)
{
}
-
-static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
- int nid, int shrinker_id) { }
#endif /* CONFIG_MEMCG_KMEM */

#endif /* _LINUX_MEMCONTROL_H */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2ce3bda..dca063b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -313,6 +313,7 @@ void memcg_put_cache_ids(void)
EXPORT_SYMBOL(memcg_kmem_enabled_key);

struct workqueue_struct *memcg_kmem_cache_wq;
+#endif

static int memcg_shrinker_map_size;
static DEFINE_MUTEX(memcg_shrinker_map_mutex);
@@ -436,14 +437,6 @@ void memcg_set_shrinker_bit(struct mem_cgroup
*memcg, int nid, int shrinker_id)
}
}

-#else /* CONFIG_MEMCG_KMEM */
-static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
-{
- return 0;
-}
-static void memcg_free_shrinker_maps(struct mem_cgroup *memcg) { }
-#endif /* CONFIG_MEMCG_KMEM */
-
/**
* mem_cgroup_css_from_page - css of the memcg associated with a page
* @page: page of interest
>
> Arnd
>