Message ID | 20211203024640.1180745-3-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: add preliminary netdev refcount tracking | expand |
Hi Eric, I love your patch! Yet something to improve: [auto build test ERROR on net-next/master] url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git fc993be36f9ea7fc286d84d8471a1a20e871aad4 config: nios2-allyesconfig (https://download.01.org/0day-ci/archive/20211205/202112050729.hISLa0oF-lkp@intel.com/config) compiler: nios2-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://github.com/0day-ci/linux/commit/98ad7e89138f4176a549203b6e23c2dc1cb9581d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 git checkout 98ad7e89138f4176a549203b6e23c2dc1cb9581d # 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=nios2 SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): lib/ref_tracker.c: In function 'ref_tracker_alloc': >> lib/ref_tracker.c:80:22: error: implicit declaration of function 'stack_trace_save'; did you mean 'stack_depot_save'? [-Werror=implicit-function-declaration] 80 | nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1); | ^~~~~~~~~~~~~~~~ | stack_depot_save >> lib/ref_tracker.c:81:22: error: implicit declaration of function 'filter_irq_stacks' [-Werror=implicit-function-declaration] 81 | nr_entries = filter_irq_stacks(entries, nr_entries); | ^~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for REF_TRACKER Depends on STACKTRACE_SUPPORT Selected by - TEST_REF_TRACKER && RUNTIME_TESTING_MENU && DEBUG_KERNEL vim +80 lib/ref_tracker.c fc2d884275133c Eric Dumazet 2021-12-02 64 fc2d884275133c Eric Dumazet 2021-12-02 65 int ref_tracker_alloc(struct ref_tracker_dir *dir, fc2d884275133c Eric Dumazet 2021-12-02 66 struct ref_tracker **trackerp, fc2d884275133c Eric Dumazet 2021-12-02 67 gfp_t gfp) fc2d884275133c Eric Dumazet 2021-12-02 68 { fc2d884275133c Eric Dumazet 2021-12-02 69 unsigned long entries[REF_TRACKER_STACK_ENTRIES]; fc2d884275133c Eric Dumazet 2021-12-02 70 struct ref_tracker *tracker; fc2d884275133c Eric Dumazet 2021-12-02 71 unsigned int nr_entries; fc2d884275133c Eric Dumazet 2021-12-02 72 unsigned long flags; fc2d884275133c Eric Dumazet 2021-12-02 73 fc2d884275133c Eric Dumazet 2021-12-02 74 *trackerp = tracker = kzalloc(sizeof(*tracker), gfp | __GFP_NOFAIL); fc2d884275133c Eric Dumazet 2021-12-02 75 if (unlikely(!tracker)) { fc2d884275133c Eric Dumazet 2021-12-02 76 pr_err_once("memory allocation failure, unreliable refcount tracker.\n"); fc2d884275133c Eric Dumazet 2021-12-02 77 refcount_inc(&dir->untracked); fc2d884275133c Eric Dumazet 2021-12-02 78 return -ENOMEM; fc2d884275133c Eric Dumazet 2021-12-02 79 } fc2d884275133c Eric Dumazet 2021-12-02 @80 nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1); fc2d884275133c Eric Dumazet 2021-12-02 @81 nr_entries = filter_irq_stacks(entries, nr_entries); fc2d884275133c Eric Dumazet 2021-12-02 82 tracker->alloc_stack_handle = stack_depot_save(entries, nr_entries, gfp); fc2d884275133c Eric Dumazet 2021-12-02 83 fc2d884275133c Eric Dumazet 2021-12-02 84 spin_lock_irqsave(&dir->lock, flags); fc2d884275133c Eric Dumazet 2021-12-02 85 list_add(&tracker->head, &dir->list); fc2d884275133c Eric Dumazet 2021-12-02 86 spin_unlock_irqrestore(&dir->lock, flags); fc2d884275133c Eric Dumazet 2021-12-02 87 return 0; fc2d884275133c Eric Dumazet 2021-12-02 88 } fc2d884275133c Eric Dumazet 2021-12-02 89 EXPORT_SYMBOL_GPL(ref_tracker_alloc); fc2d884275133c Eric Dumazet 2021-12-02 90 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Sat, Dec 4, 2021 at 3:40 PM kernel test robot <lkp@intel.com> wrote: > > Hi Eric, > > I love your patch! Yet something to improve: > > [auto build test ERROR on net-next/master] > > url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 > base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git fc993be36f9ea7fc286d84d8471a1a20e871aad4 > config: nios2-allyesconfig (https://download.01.org/0day-ci/archive/20211205/202112050729.hISLa0oF-lkp@intel.com/config) > compiler: nios2-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://github.com/0day-ci/linux/commit/98ad7e89138f4176a549203b6e23c2dc1cb9581d > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 > git checkout 98ad7e89138f4176a549203b6e23c2dc1cb9581d > # 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=nios2 SHELL=/bin/bash > I tried following these instructions, but this failed on my laptop. > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > > All errors (new ones prefixed by >>): > > lib/ref_tracker.c: In function 'ref_tracker_alloc': > >> lib/ref_tracker.c:80:22: error: implicit declaration of function 'stack_trace_save'; did you mean 'stack_depot_save'? [-Werror=implicit-function-declaration] > 80 | nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1); > | ^~~~~~~~~~~~~~~~ > | stack_depot_save > >> lib/ref_tracker.c:81:22: error: implicit declaration of function 'filter_irq_stacks' [-Werror=implicit-function-declaration] > 81 | nr_entries = filter_irq_stacks(entries, nr_entries); > | ^~~~~~~~~~~~~~~~~ > cc1: some warnings being treated as errors > > Kconfig warnings: (for reference only) > WARNING: unmet direct dependencies detected for REF_TRACKER > Depends on STACKTRACE_SUPPORT > Selected by > - TEST_REF_TRACKER && RUNTIME_TESTING_MENU && DEBUG_KERNEL > This seems to be a bug unrelated to this patch series.
On Sat, Dec 4, 2021 at 4:45 PM Eric Dumazet <edumazet@google.com> wrote: > > On Sat, Dec 4, 2021 at 3:40 PM kernel test robot <lkp@intel.com> wrote: > > > > Hi Eric, > > > > I love your patch! Yet something to improve: > > > > [auto build test ERROR on net-next/master] > > > > url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git fc993be36f9ea7fc286d84d8471a1a20e871aad4 > > config: nios2-allyesconfig (https://download.01.org/0day-ci/archive/20211205/202112050729.hISLa0oF-lkp@intel.com/config) > > compiler: nios2-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://github.com/0day-ci/linux/commit/98ad7e89138f4176a549203b6e23c2dc1cb9581d > > git remote add linux-review https://github.com/0day-ci/linux > > git fetch --no-tags linux-review Eric-Dumazet/net-add-preliminary-netdev-refcount-tracking/20211203-104930 > > git checkout 98ad7e89138f4176a549203b6e23c2dc1cb9581d > > # 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=nios2 SHELL=/bin/bash > > > > I tried following these instructions, but this failed on my laptop. > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot <lkp@intel.com> > > > > All errors (new ones prefixed by >>): > > > > lib/ref_tracker.c: In function 'ref_tracker_alloc': > > >> lib/ref_tracker.c:80:22: error: implicit declaration of function 'stack_trace_save'; did you mean 'stack_depot_save'? [-Werror=implicit-function-declaration] > > 80 | nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1); > > | ^~~~~~~~~~~~~~~~ > > | stack_depot_save > > >> lib/ref_tracker.c:81:22: error: implicit declaration of function 'filter_irq_stacks' [-Werror=implicit-function-declaration] > > 81 | nr_entries = filter_irq_stacks(entries, nr_entries); > > | ^~~~~~~~~~~~~~~~~ > > cc1: some warnings being treated as errors > > > > Kconfig warnings: (for reference only) > > WARNING: unmet direct dependencies detected for REF_TRACKER > > Depends on STACKTRACE_SUPPORT > > Selected by > > - TEST_REF_TRACKER && RUNTIME_TESTING_MENU && DEBUG_KERNEL > > > > This seems to be a bug unrelated to this patch series. Ah... maybe I got the Kconfig thing wrong. This is hard to believe we will have to duplicate " depends on STACKTRACE_SUPPORT" for all trackers will intend to have (I have a series for netns refcount tracking) diff --git a/net/Kconfig b/net/Kconfig index 0b665e60b53490f44eeda1e5506d4e125ef4c53a..b54e233b8dd38ea153ac3500df1e8a2557097ba6 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -255,6 +255,7 @@ config PCPU_DEV_REFCNT config NET_DEV_REFCNT_TRACKER bool "Enable tracking in dev_put_track() and dev_hold_track()" + depends on STACKTRACE_SUPPORT select REF_TRACKER default n help I thought that having the dependency centralized in REF_TRACKER would be enough really ? config REF_TRACKER bool depends on STACKTRACE_SUPPORT select STACKDEPOT
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 5c12bde10996cf97b5f075d318089b1be73f71d7..d005f555872147e15d3e0a65d2a03e1a5c44f5f0 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2106,6 +2106,16 @@ config BACKTRACE_SELF_TEST Say N if you are unsure. +config TEST_REF_TRACKER + tristate "Self test for reference tracker" + depends on DEBUG_KERNEL + select REF_TRACKER + help + This option provides a kernel module performing tests + using reference tracker infrastructure. + + Say N if you are unsure. + config RBTREE_TEST tristate "Red-Black tree test" depends on DEBUG_KERNEL diff --git a/lib/Makefile b/lib/Makefile index c1fd9243ddb9cc1ac5252d7eb8009f9290782c4a..b213a7bbf3fda2eb9f234fb7473b8f1b617bed6b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -101,7 +101,7 @@ obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o obj-$(CONFIG_TEST_HMM) += test_hmm.o obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o - +obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o # # CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS diff --git a/lib/test_ref_tracker.c b/lib/test_ref_tracker.c new file mode 100644 index 0000000000000000000000000000000000000000..19d7dec70cc62f0a7b274cd5ec8bf8cec62b0af3 --- /dev/null +++ b/lib/test_ref_tracker.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Referrence tracker self test. + * + * Copyright (c) 2021 Eric Dumazet <edumazet@google.com> + */ +#include <linux/init.h> +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/ref_tracker.h> +#include <linux/slab.h> +#include <linux/timer.h> + +static struct ref_tracker_dir ref_dir; +static struct ref_tracker *tracker[20]; + +#define TRT_ALLOC(X) static noinline void \ + alloctest_ref_tracker_alloc##X(struct ref_tracker_dir *dir, \ + struct ref_tracker **trackerp) \ + { \ + ref_tracker_alloc(dir, trackerp, GFP_KERNEL); \ + } + +TRT_ALLOC(1) +TRT_ALLOC(2) +TRT_ALLOC(3) +TRT_ALLOC(4) +TRT_ALLOC(5) +TRT_ALLOC(6) +TRT_ALLOC(7) +TRT_ALLOC(8) +TRT_ALLOC(9) +TRT_ALLOC(10) +TRT_ALLOC(11) +TRT_ALLOC(12) +TRT_ALLOC(13) +TRT_ALLOC(14) +TRT_ALLOC(15) +TRT_ALLOC(16) +TRT_ALLOC(17) +TRT_ALLOC(18) +TRT_ALLOC(19) + +#undef TRT_ALLOC + +static noinline void +alloctest_ref_tracker_free(struct ref_tracker_dir *dir, + struct ref_tracker **trackerp) +{ + ref_tracker_free(dir, trackerp); +} + + +static struct timer_list test_ref_tracker_timer; +static atomic_t test_ref_timer_done = ATOMIC_INIT(0); + +static void test_ref_tracker_timer_func(struct timer_list *t) +{ + ref_tracker_alloc(&ref_dir, &tracker[0], GFP_ATOMIC); + atomic_set(&test_ref_timer_done, 1); +} + +static int __init test_ref_tracker_init(void) +{ + int i; + + ref_tracker_dir_init(&ref_dir, 100); + + timer_setup(&test_ref_tracker_timer, test_ref_tracker_timer_func, 0); + mod_timer(&test_ref_tracker_timer, jiffies + 1); + + alloctest_ref_tracker_alloc1(&ref_dir, &tracker[1]); + alloctest_ref_tracker_alloc2(&ref_dir, &tracker[2]); + alloctest_ref_tracker_alloc3(&ref_dir, &tracker[3]); + alloctest_ref_tracker_alloc4(&ref_dir, &tracker[4]); + alloctest_ref_tracker_alloc5(&ref_dir, &tracker[5]); + alloctest_ref_tracker_alloc6(&ref_dir, &tracker[6]); + alloctest_ref_tracker_alloc7(&ref_dir, &tracker[7]); + alloctest_ref_tracker_alloc8(&ref_dir, &tracker[8]); + alloctest_ref_tracker_alloc9(&ref_dir, &tracker[9]); + alloctest_ref_tracker_alloc10(&ref_dir, &tracker[10]); + alloctest_ref_tracker_alloc11(&ref_dir, &tracker[11]); + alloctest_ref_tracker_alloc12(&ref_dir, &tracker[12]); + alloctest_ref_tracker_alloc13(&ref_dir, &tracker[13]); + alloctest_ref_tracker_alloc14(&ref_dir, &tracker[14]); + alloctest_ref_tracker_alloc15(&ref_dir, &tracker[15]); + alloctest_ref_tracker_alloc16(&ref_dir, &tracker[16]); + alloctest_ref_tracker_alloc17(&ref_dir, &tracker[17]); + alloctest_ref_tracker_alloc18(&ref_dir, &tracker[18]); + alloctest_ref_tracker_alloc19(&ref_dir, &tracker[19]); + + /* free all trackers but first 0 and 1. */ + for (i = 2; i < ARRAY_SIZE(tracker); i++) + alloctest_ref_tracker_free(&ref_dir, &tracker[i]); + + /* Attempt to free an already freed tracker. */ + alloctest_ref_tracker_free(&ref_dir, &tracker[2]); + + while (!atomic_read(&test_ref_timer_done)) + msleep(1); + + /* This should warn about tracker[0] & tracker[1] being not freed. */ + ref_tracker_dir_exit(&ref_dir); + + return 0; +} + +static void __exit test_ref_tracker_exit(void) +{ +} + +module_init(test_ref_tracker_init); +module_exit(test_ref_tracker_exit); + +MODULE_LICENSE("GPL v2");