Re: [rcu:dev.2020.12.08a 96/97] mm/slab_common.c:583: undefined reference to `kmem_struct_debug_provenance'

From: Paul E. McKenney
Date: Tue Dec 08 2020 - 19:00:23 EST


On Wed, Dec 09, 2020 at 07:46:24AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2020.12.08a
> head: c5c1f436c5434ca260106aa0713ec8e4de3cba22
> commit: f1bf0344f92961c0691b3baeaa1c2f23bb076bc8 [96/97] mm: Add kmalloc_debug_print_provenance() to print source of memory block
> config: i386-randconfig-s002-20201208 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.3-179-ga00755aa-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=f1bf0344f92961c0691b3baeaa1c2f23bb076bc8
> git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
> git fetch --no-tags rcu dev.2020.12.08a
> git checkout f1bf0344f92961c0691b3baeaa1c2f23bb076bc8
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>

Good catch, but this commit has been obsoleted by fc2cf07ea677 ("mm:
Add mem_dump_obj() to print source of memory block") which in your
defense I just now pushed out.

This and many other bugs have since been fixed, but Murphy insists
that there are plenty more to be found. ;-)

Thanx, Paul

> All errors (new ones prefixed by >>):
>
> ld: mm/slab_common.o: in function `kmalloc_debug_print_provenance':
> >> mm/slab_common.c:583: undefined reference to `kmem_struct_debug_provenance'
>
> vim +583 mm/slab_common.c
>
> 557
> 558 /**
> 559 * kmalloc_debug_print_provenance - Print available provenance information
> 560 * @object: object for which to find provenance information.
> 561 *
> 562 * This function uses pr_cont(), so that the caller is expected to have
> 563 * printed out whatever preamble is appropriate. The provenance information
> 564 * depends on the type of object and on how much debugging is enabled.
> 565 * For a slab-cache object, the slab name is printed, and, if available,
> 566 * the return address and stack trace from the allocation of that object.
> 567 */
> 568 void kmalloc_debug_print_provenance(void *object)
> 569 {
> 570 int i;
> 571 struct page *page;
> 572 struct kmem_provenance kp;
> 573
> 574 if (!virt_addr_valid(object)) {
> 575 pr_cont(" non-paged (local) memory.\n");
> 576 return;
> 577 }
> 578 page = virt_to_head_page(object);
> 579 kp.kp_ptr = object;
> 580 kp.kp_page = page;
> 581 kp.kp_nstack = KS_ADDRS_COUNT;
> 582 if (PageSlab(page)) {
> > 583 kmem_struct_debug_provenance(&kp);
> 584 if (page->slab_cache)
> 585 pr_cont(" slab %s", page->slab_cache->name);
> 586 if (kp.kp_ret)
> 587 pr_cont(" allocated at %pS\n", kp.kp_ret);
> 588 if (kp.kp_stack[0]) {
> 589 for (i = 0; i < ARRAY_SIZE(kp.kp_stack); i++) {
> 590 if (!kp.kp_stack[i])
> 591 break;
> 592 pr_info(" %pS\n", kp.kp_stack[i]);
> 593 }
> 594 }
> 595 return;
> 596 }
> 597 pr_cont(" non-slab memory.\n");
> 598 }
> 599 EXPORT_SYMBOL_GPL(kmalloc_debug_print_provenance);
> 600
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx