Re: [rcu:rcu/next 94/101] mm/slab_common.c:555: undefined reference to `kmem_cache_last_alloc'

From: Paul E. McKenney
Date: Fri Dec 04 2020 - 14:23:14 EST


On Fri, Dec 04, 2020 at 12:53:56PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git rcu/next
> head: 413d9f332cbd16d951c22a41f2e5f53c1a75ae1c
> commit: f7c3fb4fc476a8a7a3cfc78cffbf1de13c1899b7 [94/101] mm: Add kmem_last_alloc() to return last allocation for memory block
> config: i386-randconfig-p001-20201204 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce (this is a W=1 build):
> # https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=f7c3fb4fc476a8a7a3cfc78cffbf1de13c1899b7
> git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
> git fetch --no-tags rcu rcu/next
> git checkout f7c3fb4fc476a8a7a3cfc78cffbf1de13c1899b7
> # save the attached .config to linux build tree
> make W=1 ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All errors (new ones prefixed by >>):
>
> ld: mm/slab_common.o: in function `kmem_last_alloc':
> >> mm/slab_common.c:555: undefined reference to `kmem_cache_last_alloc'
>
> vim +555 mm/slab_common.c

Good catch! I had no idea that the slab definition of the
kmem_cache_last_alloc() function was under CONFIG_NUMA...

Will fold a fix in with attribution.

Thanx, Paul

> 538
> 539 /*
> 540 * If the pointer references a slab-allocated object and if sufficient
> 541 * debugging is enabled, return the returrn address for the corresponding
> 542 * allocation. Otherwise, return NULL. Note that passing random pointers
> 543 * to this function (including addresses of on-stack variables) is likely
> 544 * to result in panics.
> 545 */
> 546 void *kmem_last_alloc(void *object)
> 547 {
> 548 struct page *page;
> 549
> 550 if (!virt_addr_valid(object))
> 551 return NULL;
> 552 page = virt_to_head_page(object);
> 553 if (!PageSlab(page))
> 554 return NULL;
> > 555 return kmem_cache_last_alloc(page->slab_cache, object);
> 556 }
> 557 EXPORT_SYMBOL_GPL(kmem_last_alloc);
> 558
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx