Re: undefined reference to `node_data'

From: Michal Hocko
Date: Wed Mar 23 2022 - 12:47:05 EST


Let me CC MIPS maintainers

On Wed 23-03-22 15:53:31, Michal Hocko wrote:
> On Wed 23-03-22 20:58:10, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 6b1f86f8e9c7f9de7ca1cb987b2cf25e99b1ae3a
> > commit: 09f49dca570a917a8c6bccd7e8c61f5141534e3a mm: handle uninitialized numa nodes gracefully
> > date: 14 hours ago
> > config: mips-buildonly-randconfig-r004-20220323 (https://download.01.org/0day-ci/archive/20220323/202203232042.AS9SV1zv-lkp@xxxxxxxxx/config)
> > compiler: mips64-linux-gcc (GCC) 11.2.0
> > 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/torvalds/linux.git/commit/?id=09f49dca570a917a8c6bccd7e8c61f5141534e3a
> > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > git fetch --no-tags linus master
> > git checkout 09f49dca570a917a8c6bccd7e8c61f5141534e3a
> > # save the config file to linux build tree
> > mkdir build_dir
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash
>
> Didn't work for me
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> >
> > All errors (new ones prefixed by >>):
> >
> > mips64-linux-ld: mm/page_alloc.o: in function `free_area_init':
> > >> (.init.text+0x1680): undefined reference to `node_data'
> > mips64-linux-ld: (.init.text+0x1690): undefined reference to `node_data'
>
> OK, I can see what is going here. The page allocator normally
> uses NODE_DATA but arch_refresh_nodedata refers to node_data directly.
> This is a problem with
> arch/mips/include/asm/mach-loongson64/mmzone.h:
> extern struct pglist_data *__node_data[];
>
> #define NODE_DATA(n) (__node_data[n])
>
> Unfortunately we cannot use NODE_DATA there because of header inclusion
> ordering. I will think about a solution.

Is there any reason why (some?) MIPS arches use __node_data rather than
node_data as most other architectures? Would it be acceptable to do the
renaming? It would help to cover the above compilation problem because
arch_refresh_nodedata could keep using node_data directly.

Thanks!
--
Michal Hocko
SUSE Labs