Re: [rcu:rcu/next 59/91] tree.c:(.text+0x4248): multiple definition of `srcu_online_cpu'

From: Paul E. McKenney
Date: Sun Apr 23 2017 - 12:22:28 EST


On Sun, Apr 23, 2017 at 01:31:21PM +0800, kbuild test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git rcu/next
> head: 87c458e6304c6a1b37bf856e88c70fc37f08851f
> commit: da915ad5cf25b5f5d358dd3670c3378d8ae8c03e [59/91] srcu: Parallelize callback handling
> config: tile-allnoconfig (attached as .config)
> compiler: tilegx-linux-gcc (GCC) 4.6.2
> reproduce:
> wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout da915ad5cf25b5f5d358dd3670c3378d8ae8c03e
> # save the attached .config to linux build tree
> make.cross ARCH=tile
>
> All errors (new ones prefixed by >>):
>
> kernel/rcu/tree.o: In function `srcu_online_cpu':
> >> tree.c:(.text+0x4248): multiple definition of `srcu_online_cpu'
> kernel/rcu/srcutree.o:srcutree.c:(.text+0x2120): first defined here
> kernel/rcu/tree.o: In function `srcu_offline_cpu':
> >> tree.c:(.text+0x4250): multiple definition of `srcu_offline_cpu'
> kernel/rcu/srcutree.o:srcutree.c:(.text+0x2160): first defined here

(Adding Ingo on CC because he also saw this in -tip.)

Hmmm... The attached .config has CONFIG_TREE_SRCU=y but no sign
of CONFIG_SRCU, which would definitely result in what you are seeing.
Taking a look at tile's Kconfig files in current mainline finds me
only a "select SRCU", which should not be a problem.

OK, time to look at the SRCU code in init/Kconfig:

config TINY_SRCU
bool
default y if TINY_RCU && !CLASSIC_SRCU
help
This option selects the single-CPU non-preemptible version of SRCU.

config TREE_SRCU
bool
default y if !TINY_RCU && !CLASSIC_SRCU
help
This option selects the full-fledged version of SRCU.

And this says that if CONFIG_CLASSIC_SRCU is not selected, you get
exactly what the tile guys got. I didn't see this because I am
always running rcutorture, which always selects CONFIG_SRCU. Sigh!!!

Does the following patch help?

Thanx, Paul

------------------------------------------------------------------------

commit 78672b6811bde47aacb0f8bcb128c0107a088849
Author: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Date: Sun Apr 23 09:13:44 2017 -0700

srcu: Fix Kconfig botch when SRCU not selected

If the CONFIG_SRCU option is not selected, for example, when building
tile allnoconfig, the following build errors appear:

kernel/rcu/tree.o: In function `srcu_online_cpu':
tree.c:(.text+0x4248): multiple definition of `srcu_online_cpu'
kernel/rcu/srcutree.o:srcutree.c:(.text+0x2120): first defined here
kernel/rcu/tree.o: In function `srcu_offline_cpu':
tree.c:(.text+0x4250): multiple definition of `srcu_offline_cpu'
kernel/rcu/srcutree.o:srcutree.c:(.text+0x2160): first defined here

The corresponding .config file shows CONFIG_TREE_SRCU=y, but no sign
of CONFIG_SRCU, which fatally confuses SRCU's #ifdefs, resulting in
the above errors. The reason this occurs is the folowing line in
init/Kconfig's definition for TREE_SRCU:

default y if !TINY_RCU && !CLASSIC_SRCU

If CONFIG_CLASSIC_SRCU=n, as it will be in for allnoconfig, and if
CONFIG_SMP=y, then we will get CONFIG_TREE_SRCU=y but no CONFIG_SRCU,
as seen in the .config file, and which will result in the above errors.
This error did not show up during rcutorture testing because rcutorture
forces CONFIG_SRCU=y, as it must to prevent build errors in rcutorture.c.

This commit therefore conditions TREE_SRCU (and TINY_SRCU, while it is
at it) with SRCU, like this:

default y if SRCU && !TINY_RCU && !CLASSIC_SRCU

Reported-by: kbuild test robot <fengguang.wu@xxxxxxxxx>
Reported-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>

diff --git a/init/Kconfig b/init/Kconfig
index 4119a44e4157..fe72c12e06a5 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -545,13 +545,13 @@ config CLASSIC_SRCU

config TINY_SRCU
bool
- default y if TINY_RCU && !CLASSIC_SRCU
+ default y if SRCU && TINY_RCU && !CLASSIC_SRCU
help
This option selects the single-CPU non-preemptible version of SRCU.

config TREE_SRCU
bool
- default y if !TINY_RCU && !CLASSIC_SRCU
+ default y if SRCU && !TINY_RCU && !CLASSIC_SRCU
help
This option selects the full-fledged version of SRCU.