Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 127424c8 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds
Browse files

mm: memcontrol: move kmem accounting code to CONFIG_MEMCG



The cgroup2 memory controller will account important in-kernel memory
consumers per default.  Move all necessary components to CONFIG_MEMCG.

Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3893e302
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@ struct list_lru_node {
	spinlock_t		lock;
	spinlock_t		lock;
	/* global list, used for the root cgroup in cgroup aware lrus */
	/* global list, used for the root cgroup in cgroup aware lrus */
	struct list_lru_one	lru;
	struct list_lru_one	lru;
#ifdef CONFIG_MEMCG_KMEM
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
	/* for cgroup aware lrus points to per cgroup lists, otherwise NULL */
	/* for cgroup aware lrus points to per cgroup lists, otherwise NULL */
	struct list_lru_memcg	*memcg_lrus;
	struct list_lru_memcg	*memcg_lrus;
#endif
#endif
@@ -48,7 +48,7 @@ struct list_lru_node {


struct list_lru {
struct list_lru {
	struct list_lru_node	*node;
	struct list_lru_node	*node;
#ifdef CONFIG_MEMCG_KMEM
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
	struct list_head	list;
	struct list_head	list;
#endif
#endif
};
};
+4 −3
Original line number Original line Diff line number Diff line
@@ -236,7 +236,7 @@ struct mem_cgroup {
#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET)
#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET)
	struct cg_proto tcp_mem;
	struct cg_proto tcp_mem;
#endif
#endif
#if defined(CONFIG_MEMCG_KMEM)
#ifndef CONFIG_SLOB
        /* Index in the kmem_cache->memcg_params.memcg_caches array */
        /* Index in the kmem_cache->memcg_params.memcg_caches array */
	int kmemcg_id;
	int kmemcg_id;
	enum memcg_kmem_state kmem_state;
	enum memcg_kmem_state kmem_state;
@@ -735,7 +735,7 @@ static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
}
}
#endif
#endif


#ifdef CONFIG_MEMCG_KMEM
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
extern struct static_key_false memcg_kmem_enabled_key;
extern struct static_key_false memcg_kmem_enabled_key;


extern int memcg_nr_cache_ids;
extern int memcg_nr_cache_ids;
@@ -891,5 +891,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 void memcg_kmem_put_cache(struct kmem_cache *cachep)
{
{
}
}
#endif /* CONFIG_MEMCG_KMEM */
#endif /* CONFIG_MEMCG && !CONFIG_SLOB */

#endif /* _LINUX_MEMCONTROL_H */
#endif /* _LINUX_MEMCONTROL_H */
+2 −2
Original line number Original line Diff line number Diff line
@@ -1476,10 +1476,10 @@ struct task_struct {
	unsigned in_iowait:1;
	unsigned in_iowait:1;
#ifdef CONFIG_MEMCG
#ifdef CONFIG_MEMCG
	unsigned memcg_may_oom:1;
	unsigned memcg_may_oom:1;
#endif
#ifndef CONFIG_SLOB
#ifdef CONFIG_MEMCG_KMEM
	unsigned memcg_kmem_skip_account:1;
	unsigned memcg_kmem_skip_account:1;
#endif
#endif
#endif
#ifdef CONFIG_COMPAT_BRK
#ifdef CONFIG_COMPAT_BRK
	unsigned brk_randomized:1;
	unsigned brk_randomized:1;
#endif
#endif
+1 −1
Original line number Original line Diff line number Diff line
@@ -86,7 +86,7 @@
#else
#else
# define SLAB_FAILSLAB		0x00000000UL
# define SLAB_FAILSLAB		0x00000000UL
#endif
#endif
#ifdef CONFIG_MEMCG_KMEM
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
# define SLAB_ACCOUNT		0x04000000UL	/* Account to memcg */
# define SLAB_ACCOUNT		0x04000000UL	/* Account to memcg */
#else
#else
# define SLAB_ACCOUNT		0x00000000UL
# define SLAB_ACCOUNT		0x00000000UL
+2 −1
Original line number Original line Diff line number Diff line
@@ -69,7 +69,8 @@ struct kmem_cache {
	 */
	 */
	int obj_offset;
	int obj_offset;
#endif /* CONFIG_DEBUG_SLAB */
#endif /* CONFIG_DEBUG_SLAB */
#ifdef CONFIG_MEMCG_KMEM

#ifdef CONFIG_MEMCG
	struct memcg_cache_params memcg_params;
	struct memcg_cache_params memcg_params;
#endif
#endif


Loading