Skip to contentSkip to conversation

mm/memcontrol.c:7467:6: error: redefinition of 'obj_cgroup_may_zswap'

PATCH kernel test robot 3 participants 3 messages May 11, 2022

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6107040c99d5dfc920721c198d45ed2d639b113a
commit: bf7930005b547c94d4cd312a2e0400cb8cf76d2a [10902/11094] zswap: memcg accounting
config: i386-randconfig-a001-20220509 (https://download.01.org/0day-ci/archive/20220512/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 18dd123c56754edf62c7042dcf23185c3727610f)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=bf7930005b547c94d4cd312a2e0400cb8cf76d2a
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout bf7930005b547c94d4cd312a2e0400cb8cf76d2a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> mm/memcontrol.c:7467:6: error: redefinition of 'obj_cgroup_may_zswap'
   bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
        ^
   include/linux/memcontrol.h:1816:20: note: previous definition is here
   static inline bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
                      ^
>> mm/memcontrol.c:7504:6: error: redefinition of 'obj_cgroup_charge_zswap'
   void obj_cgroup_charge_zswap(struct obj_cgroup *objcg, size_t size)
        ^
   include/linux/memcontrol.h:1820:20: note: previous definition is here
   static inline void obj_cgroup_charge_zswap(struct obj_cgroup *objcg,
                      ^
>> mm/memcontrol.c:7511:6: error: call to undeclared function 'obj_cgroup_charge'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           if (obj_cgroup_charge(objcg, GFP_KERNEL, size))
               ^
   mm/memcontrol.c:7511:6: note: did you mean 'mem_cgroup_charge'?
   include/linux/memcontrol.h:684:19: note: 'mem_cgroup_charge' declared here
   static inline int mem_cgroup_charge(struct folio *folio, struct mm_struct *mm,
                     ^
>> mm/memcontrol.c:7528:6: error: redefinition of 'obj_cgroup_uncharge_zswap'
   void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size)
        ^
   include/linux/memcontrol.h:1824:20: note: previous definition is here
   static inline void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg,
                      ^
>> mm/memcontrol.c:7532:2: error: call to undeclared function 'obj_cgroup_uncharge'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           obj_cgroup_uncharge(objcg, size);
           ^
   mm/memcontrol.c:7532:2: note: did you mean 'mem_cgroup_uncharge'?
   include/linux/memcontrol.h:704:20: note: 'mem_cgroup_uncharge' declared here
   static inline void mem_cgroup_uncharge(struct folio *folio)
                      ^

5 errors generated.

vim +/obj_cgroup_may_zswap +7467 mm/memcontrol.c

7453
7454 #ifdef CONFIG_ZSWAP
7455 /**
7456 * obj_cgroup_may_zswap - check if this cgroup can zswap
7457 * @objcg: the object cgroup
7458 *
7459 * Check if the hierarchical zswap limit has been reached.
7460 *
7461 * This doesn't check for specific headroom, and it is not atomic
7462 * either. But with zswap, the size of the allocation is only known
7463 * once compression has occured, and this optimistic pre-check avoids
7464 * spending cycles on compression when there is already no room left
7465 * or zswap is disabled altogether somewhere in the hierarchy.
7466 */

> 7467	bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
  7468	{
  7469		struct mem_cgroup *memcg, *original_memcg;
  7470		bool ret = true;
  7471	
  7472		original_memcg = get_mem_cgroup_from_objcg(objcg);
  7473		for (memcg = original_memcg; memcg != root_mem_cgroup;
  7474		     memcg = parent_mem_cgroup(memcg)) {
  7475			unsigned long max = READ_ONCE(memcg->zswap_max);
  7476			unsigned long pages;
  7477	
  7478			if (max == PAGE_COUNTER_MAX)
  7479				continue;
  7480			if (max == 0) {
  7481				ret = false;
  7482				break;
  7483			}
  7484	
  7485			cgroup_rstat_flush(memcg->css.cgroup);
  7486			pages = memcg_page_state(memcg, MEMCG_ZSWAP_B) / PAGE_SIZE;
  7487			if (pages < max)
  7488				continue;
  7489			ret = false;
  7490			break;
  7491		}
  7492		mem_cgroup_put(original_memcg);
  7493		return ret;
  7494	}
  7495	
  7496	/**
  7497	 * obj_cgroup_charge_zswap - charge compression backend memory
  7498	 * @objcg: the object cgroup
  7499	 * @size: size of compressed object
  7500	 *
  7501	 * This forces the charge after obj_cgroup_may_swap() allowed
  7502	 * compression and storage in zwap for this cgroup to go ahead.
  7503	 */
> 7504	void obj_cgroup_charge_zswap(struct obj_cgroup *objcg, size_t size)
  7505	{
  7506		struct mem_cgroup *memcg;
  7507	
  7508		VM_WARN_ON_ONCE(!(current->flags & PF_MEMALLOC));
  7509	
  7510		/* PF_MEMALLOC context, charging must succeed */
> 7511		if (obj_cgroup_charge(objcg, GFP_KERNEL, size))
  7512			VM_WARN_ON_ONCE(1);
  7513	
  7514		rcu_read_lock();
  7515		memcg = obj_cgroup_memcg(objcg);
  7516		mod_memcg_state(memcg, MEMCG_ZSWAP_B, size);
  7517		mod_memcg_state(memcg, MEMCG_ZSWAPPED, 1);
  7518		rcu_read_unlock();
  7519	}
  7520	
  7521	/**
  7522	 * obj_cgroup_uncharge_zswap - uncharge compression backend memory
  7523	 * @objcg: the object cgroup
  7524	 * @size: size of compressed object
  7525	 *
  7526	 * Uncharges zswap memory on page in.
  7527	 */
> 7528	void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size)
  7529	{
  7530		struct mem_cgroup *memcg;
  7531	
> 7532		obj_cgroup_uncharge(objcg, size);

7533
7534 rcu_read_lock();
7535 memcg = obj_cgroup_memcg(objcg);
7536 mod_memcg_state(memcg, MEMCG_ZSWAP_B, -size);
7537 mod_memcg_state(memcg, MEMCG_ZSWAPPED, -1);
7538 rcu_read_unlock();
7539 }
7540

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
maintainer
#1 lore raw
Quoted 19 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6107040c99d5dfc920721c198d45ed2d639b113a
commit: bf7930005b547c94d4cd312a2e0400cb8cf76d2a [10902/11094] zswap: memcg accounting
config: i386-randconfig-a001-20220509 (https://download.01.org/0day-ci/archive/20220512/202205120115.D6nVZNke-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 18dd123c56754edf62c7042dcf23185c3727610f)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=bf7930005b547c94d4cd312a2e0400cb8cf76d2a
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout bf7930005b547c94d4cd312a2e0400cb8cf76d2a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

Quoted 7 lines

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

mm/memcontrol.c:7467:6: error: redefinition of 'obj_cgroup_may_zswap'

bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)

        ^

include/linux/memcontrol.h:1816:20: note: previous definition is here static inline bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)

This is a slob configuration! I'll probably NOT test this routinely in the future ;) But there is opportunity to simplify the underlying complication that caused this, which is CONFIG_MEMCG_KMEM. I need to dust off that patch and send it...

For now, this delta fix addresses the problem.

Runtime tested with slob and slub.

---

Quoted 1 line

From f6029bc8676d990b3915b815dd6d15759ce6b1b1 Mon Sep 17 00:00:00 2001

From: Johannes Weiner <[email protected]>
Date: Wed, 11 May 2022 14:26:59 -0400
Subject: [PATCH] zswap: memcg accounting fix

Fix for CONFIG_SLOB builds:

Quoted 1 line
Quoted 1 line

mm/memcontrol.c:7467:6: error: redefinition of 'obj_cgroup_may_zswap'

bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)

	^

include/linux/memcontrol.h:1816:20: note: previous definition is here static inline bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)

The header file uses CONFIG_MEMCG_KMEM && CONFIG_ZSWAP to decide on implementation vs dummies; the .c file uses CONFIG_ZSWAP. SLOB builds don't have CONFIG_MEMCG_KMEM (for historical reasons).

Gate everything in the code file on CONFIG_MEMCG_KMEM as well for now. Eventually, CONFIG_MEMCG_KMEM should be removed and folded into CONFIG_MEMCG.

---
 include/linux/memcontrol.h |  2 +-
 mm/memcontrol.c            | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/memcontrol.h +1 -1
index 3385ce81ecf3..b0685d01570f 100644
@@ -254,7 +254,7 @@ struct mem_cgroup {
 	/* Range enforcement for interrupt charges */
 	struct work_struct high_work;
 
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	unsigned long zswap_max;
 #endif
 
mm/memcontrol.c +6 -6
index cbb9b43bdb80..350012b93a95 100644
@@ -1398,7 +1398,7 @@ static const struct memory_stat memory_stats[] = {
 	{ "sock",			MEMCG_SOCK			},
 	{ "vmalloc",			MEMCG_VMALLOC			},
 	{ "shmem",			NR_SHMEM			},
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	{ "zswap",			MEMCG_ZSWAP_B			},
 	{ "zswapped",			MEMCG_ZSWAPPED			},
 #endif
@@ -1517,7 +1517,7 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
 	seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGLAZYFREED),
 		       memcg_events(memcg, PGLAZYFREED));
 
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	seq_buf_printf(&s, "%s %lu\n", vm_event_name(ZSWPIN),
 		       memcg_events(memcg, ZSWPIN));
 	seq_buf_printf(&s, "%s %lu\n", vm_event_name(ZSWPOUT),
@@ -5184,7 +5184,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
 
 	page_counter_set_high(&memcg->memory, PAGE_COUNTER_MAX);
 	memcg->soft_limit = PAGE_COUNTER_MAX;
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	memcg->zswap_max = PAGE_COUNTER_MAX;
 #endif
 	page_counter_set_high(&memcg->swap, PAGE_COUNTER_MAX);
@@ -7451,7 +7451,7 @@ static struct cftype memsw_files[] = {
 	{ },	/* terminate */
 };
 
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 /**
  * obj_cgroup_may_zswap - check if this cgroup can zswap
  * @objcg: the object cgroup
@@ -7582,7 +7582,7 @@ static struct cftype zswap_files[] = {
 	},
 	{ }	/* terminate */
 };
-#endif /* CONFIG_ZSWAP */
+#endif /* CONFIG_MEMCG_KMEM && CONFIG_ZSWAP */
 
 /*
  * If mem_cgroup_swap_init() is implemented as a subsys_initcall()
@@ -7602,7 +7602,7 @@ static int __init mem_cgroup_swap_init(void)
 
 	WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files));
 	WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, memsw_files));
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, zswap_files));
 #endif
 	return 0;
Signature · 1 line
2.35.3
maintainer
#2 lore raw
In reply to kernel test robot
Quoted 16 lines · On Thu, 12 May 2022 01:49:04 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6107040c99d5dfc920721c198d45ed2d639b113a
commit: bf7930005b547c94d4cd312a2e0400cb8cf76d2a [10902/11094] zswap: memcg accounting
config: i386-randconfig-a001-20220509 (https://download.01.org/0day-ci/archive/20220512/202205120115.D6nVZNke-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 18dd123c56754edf62c7042dcf23185c3727610f)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=bf7930005b547c94d4cd312a2e0400cb8cf76d2a
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout bf7930005b547c94d4cd312a2e0400cb8cf76d2a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

Quoted 8 lines

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

mm/memcontrol.c:7467:6: error: redefinition of 'obj_cgroup_may_zswap'

bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)

        ^

Thanks, this still occurs when the two Kconfig cleanups from that patchset are included, so I did this:

mm/memcontrol.c renamed from mm/memcontrol.c~zswap-memcg-accounting-fix +3 -3
@@ -7451,7 +7451,7 @@ static struct cftype memsw_files[] = {
 	{ },	/* terminate */
 };
 
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 /**
  * obj_cgroup_may_zswap - check if this cgroup can zswap
  * @objcg: the object cgroup
@@ -7582,7 +7582,7 @@ static struct cftype zswap_files[] = {
 	},
 	{ }	/* terminate */
 };
-#endif /* CONFIG_ZSWAP */
+#endif /* CONFIG_MEMCG_KMEM && CONFIG_ZSWAP */
 
 /*
  * If mem_cgroup_swap_init() is implemented as a subsys_initcall()
@@ -7602,7 +7602,7 @@ static int __init mem_cgroup_swap_init(v
 
 	WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files));
 	WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, memsw_files));
-#ifdef CONFIG_ZSWAP
+#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
 	WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, zswap_files));
 #endif
 	return 0;

_