[v2,2/2] debugobject: add unit test for static debug object

Message ID 20230303183147.934793-2-schspa@gmail.com
State New
Headers
Series [v2,1/2] debugobject: fix concurrency issues with is_static_object |

Commit Message

Schspa Shi March 3, 2023, 6:31 p.m. UTC
  Add test case to enusre that static debug object correctness.

Tested on little-endian arm64 qemu, result:

[    2.385735] KTAP version 1
[    2.385860] 1..1
[    2.386406]     KTAP version 1
[    2.386658]     # Subtest: static debugobject init
[    2.386726]     1..1
[    2.401777]     ok 1 static_debugobject_test
[    2.402455] ok 1 static debugobject init

Signed-off-by: Schspa Shi <schspa@gmail.com>
---
 MAINTAINERS                    |   5 ++
 lib/Kconfig.debug              |  14 ++++
 lib/Makefile                   |   2 +
 lib/test_static_debug_object.c | 125 +++++++++++++++++++++++++++++++++
 4 files changed, 146 insertions(+)
 create mode 100644 lib/test_static_debug_object.c
  

Comments

kernel test robot March 4, 2023, 6:30 a.m. UTC | #1
Hi Schspa,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2 next-20230303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Schspa-Shi/debugobject-add-unit-test-for-static-debug-object/20230304-024247
patch link:    https://lore.kernel.org/r/20230303183147.934793-2-schspa%40gmail.com
patch subject: [PATCH v2 2/2] debugobject: add unit test for static debug object
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230304/202303041412.ikI5GiS6-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/54cf5a36c1c89cb79463e38bdbd636a016a80c66
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Schspa-Shi/debugobject-add-unit-test-for-static-debug-object/20230304-024247
        git checkout 54cf5a36c1c89cb79463e38bdbd636a016a80c66
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303041412.ikI5GiS6-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kgdb.h:19,
                    from include/drm/drm_util.h:36,
                    from include/drm/drm_connector.h:32,
                    from include/drm/drm_modes.h:33,
                    from include/drm/drm_crtc.h:32,
                    from include/drm/drm_atomic_helper.h:31,
                    from drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c:8:
>> include/linux/kprobes.h:70:9: error: unknown type name 'kprobe_opcode_t'
      70 |         kprobe_opcode_t *addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:85:9: error: unknown type name 'kprobe_opcode_t'
      85 |         kprobe_opcode_t opcode;
         |         ^~~~~~~~~~~~~~~
>> include/linux/kprobes.h:88:35: error: field 'ainsn' has incomplete type
      88 |         struct arch_specific_insn ainsn;
         |                                   ^~~~~
   include/linux/kprobes.h:174:9: error: unknown type name 'kprobe_opcode_t'
     174 |         kprobe_opcode_t *ret_addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:298:33: error: unknown type name 'kprobe_opcode_t'
     298 | extern int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
         |                                 ^~~~~~~~~~~~~~~
   In file included from include/asm-generic/percpu.h:7,
                    from arch/alpha/include/asm/percpu.h:17,
                    from include/linux/irqflags.h:17,
                    from include/linux/spinlock.h:59,
                    from include/drm/drm_crtc.h:28:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/percpu-defs.h:219:59: error: invalid use of undefined type 'struct kprobe_ctlblk'
     219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
         |                                                           ^
   include/linux/percpu-defs.h:241:9: note: in expansion of macro '__verify_pcpu_ptr'
     241 |         __verify_pcpu_ptr(ptr);                                         \
         |         ^~~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:252:27: note: in expansion of macro 'raw_cpu_ptr'
     252 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
         |                           ^~~~~~~~~~~
   include/linux/kprobes.h:414:16: note: in expansion of macro 'this_cpu_ptr'
     414 |         return this_cpu_ptr(&kprobe_ctlblk);
         |                ^~~~~~~~~~~~
   include/linux/kprobes.h: At top level:
   include/linux/kprobes.h:417:1: error: unknown type name 'kprobe_opcode_t'
     417 | kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:418:1: error: unknown type name 'kprobe_opcode_t'
     418 | kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h: In function 'kprobe_page_fault':
>> include/linux/kprobes.h:599:16: error: implicit declaration of function 'kprobe_fault_handler' [-Werror=implicit-function-declaration]
     599 |         return kprobe_fault_handler(regs, trap);
         |                ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from include/linux/kgdb.h:19,
                    from include/linux/fb.h:6,
                    from include/linux/vga_switcheroo.h:34,
                    from sound/pci/hda/hda_intel.c:52:
>> include/linux/kprobes.h:70:9: error: unknown type name 'kprobe_opcode_t'
      70 |         kprobe_opcode_t *addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:85:9: error: unknown type name 'kprobe_opcode_t'
      85 |         kprobe_opcode_t opcode;
         |         ^~~~~~~~~~~~~~~
>> include/linux/kprobes.h:88:35: error: field 'ainsn' has incomplete type
      88 |         struct arch_specific_insn ainsn;
         |                                   ^~~~~
   include/linux/kprobes.h:174:9: error: unknown type name 'kprobe_opcode_t'
     174 |         kprobe_opcode_t *ret_addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:298:33: error: unknown type name 'kprobe_opcode_t'
     298 | extern int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
         |                                 ^~~~~~~~~~~~~~~
   In file included from include/asm-generic/percpu.h:7,
                    from arch/alpha/include/asm/percpu.h:17,
                    from include/linux/irqflags.h:17,
                    from include/linux/rcupdate.h:26,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/delay.h:23,
                    from sound/pci/hda/hda_intel.c:23:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/percpu-defs.h:219:59: error: invalid use of undefined type 'struct kprobe_ctlblk'
     219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
         |                                                           ^
   include/linux/percpu-defs.h:241:9: note: in expansion of macro '__verify_pcpu_ptr'
     241 |         __verify_pcpu_ptr(ptr);                                         \
         |         ^~~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:252:27: note: in expansion of macro 'raw_cpu_ptr'
     252 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
         |                           ^~~~~~~~~~~
   include/linux/kprobes.h:414:16: note: in expansion of macro 'this_cpu_ptr'
     414 |         return this_cpu_ptr(&kprobe_ctlblk);
         |                ^~~~~~~~~~~~
   include/linux/kprobes.h: At top level:
   include/linux/kprobes.h:417:1: error: unknown type name 'kprobe_opcode_t'
     417 | kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:418:1: error: unknown type name 'kprobe_opcode_t'
     418 | kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h: In function 'kprobe_page_fault':
>> include/linux/kprobes.h:599:16: error: implicit declaration of function 'kprobe_fault_handler' [-Werror=implicit-function-declaration]
     599 |         return kprobe_fault_handler(regs, trap);
         |                ^~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/init.h:5,
                    from include/linux/printk.h:6,
                    from include/asm-generic/bug.h:22,
                    from arch/alpha/include/asm/bug.h:23,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:13,
                    from include/asm-generic/current.h:5,
                    from ./arch/alpha/include/generated/asm/current.h:1,
                    from include/linux/sched.h:12:
   sound/pci/hda/hda_intel.c: At top level:
   include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
      16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
         |                                                   ^
   include/linux/compiler.h:232:33: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     232 | #define __must_be_array(a)      BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
         |                                 ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:55:59: note: in expansion of macro '__must_be_array'
      55 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                                           ^~~~~~~~~~~~~~~
   include/linux/moduleparam.h:517:20: note: in expansion of macro 'ARRAY_SIZE'
     517 |         = { .max = ARRAY_SIZE(array), .num = nump,                      \
         |                    ^~~~~~~~~~
   include/linux/moduleparam.h:501:9: note: in expansion of macro 'module_param_array_named'
     501 |         module_param_array_named(name, name, type, nump, perm)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   sound/pci/hda/hda_intel.c:125:1: note: in expansion of macro 'module_param_array'
     125 | module_param_array(index, int, NULL, 0444);
         | ^~~~~~~~~~~~~~~~~~
   sound/pci/hda/hda_intel.c:104:12: warning: 'index' defined but not used [-Wunused-variable]
     104 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
         |            ^~~~~
   cc1: some warnings being treated as errors
--
   In file included from include/linux/kgdb.h:19,
                    from include/drm/drm_util.h:36,
                    from include/drm/drm_connector.h:32,
                    from include/drm/drm_modes.h:33,
                    from include/drm/drm_crtc.h:32,
                    from include/drm/drm_atomic.h:31,
                    from drivers/gpu/drm/arm/malidp_planes.c:12:
>> include/linux/kprobes.h:70:9: error: unknown type name 'kprobe_opcode_t'
      70 |         kprobe_opcode_t *addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:85:9: error: unknown type name 'kprobe_opcode_t'
      85 |         kprobe_opcode_t opcode;
         |         ^~~~~~~~~~~~~~~
>> include/linux/kprobes.h:88:35: error: field 'ainsn' has incomplete type
      88 |         struct arch_specific_insn ainsn;
         |                                   ^~~~~
   include/linux/kprobes.h:174:9: error: unknown type name 'kprobe_opcode_t'
     174 |         kprobe_opcode_t *ret_addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:298:33: error: unknown type name 'kprobe_opcode_t'
     298 | extern int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
         |                                 ^~~~~~~~~~~~~~~
   In file included from include/asm-generic/percpu.h:7,
                    from arch/alpha/include/asm/percpu.h:17,
                    from include/linux/irqflags.h:17,
                    from include/linux/spinlock.h:59,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:7,
                    from include/linux/mm.h:7,
                    from include/linux/scatterlist.h:8,
                    from include/linux/iommu.h:10,
                    from drivers/gpu/drm/arm/malidp_planes.c:9:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/percpu-defs.h:219:59: error: invalid use of undefined type 'struct kprobe_ctlblk'
     219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
         |                                                           ^
   include/linux/percpu-defs.h:241:9: note: in expansion of macro '__verify_pcpu_ptr'
     241 |         __verify_pcpu_ptr(ptr);                                         \
         |         ^~~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:252:27: note: in expansion of macro 'raw_cpu_ptr'
     252 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
         |                           ^~~~~~~~~~~
   include/linux/kprobes.h:414:16: note: in expansion of macro 'this_cpu_ptr'
     414 |         return this_cpu_ptr(&kprobe_ctlblk);
         |                ^~~~~~~~~~~~
   include/linux/kprobes.h: At top level:
   include/linux/kprobes.h:417:1: error: unknown type name 'kprobe_opcode_t'
     417 | kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:418:1: error: unknown type name 'kprobe_opcode_t'
     418 | kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h: In function 'kprobe_page_fault':
   include/linux/kprobes.h:599:16: error: implicit declaration of function 'kprobe_fault_handler'; did you mean 'iommu_set_fault_handler'? [-Werror=implicit-function-declaration]
     599 |         return kprobe_fault_handler(regs, trap);
         |                ^~~~~~~~~~~~~~~~~~~~
         |                iommu_set_fault_handler
   cc1: some warnings being treated as errors
--
   In file included from include/linux/kgdb.h:19,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:31,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
                    from drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26,
                    from drivers/gpu/drm/amd/amdgpu/amdgpu.h:64,
                    from drivers/gpu/drm/amd/amdgpu/si_dma.c:25:
>> include/linux/kprobes.h:70:9: error: unknown type name 'kprobe_opcode_t'
      70 |         kprobe_opcode_t *addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:85:9: error: unknown type name 'kprobe_opcode_t'
      85 |         kprobe_opcode_t opcode;
         |         ^~~~~~~~~~~~~~~
>> include/linux/kprobes.h:88:35: error: field 'ainsn' has incomplete type
      88 |         struct arch_specific_insn ainsn;
         |                                   ^~~~~
   include/linux/kprobes.h:174:9: error: unknown type name 'kprobe_opcode_t'
     174 |         kprobe_opcode_t *ret_addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:298:33: error: unknown type name 'kprobe_opcode_t'
     298 | extern int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
         |                                 ^~~~~~~~~~~~~~~
   In file included from include/asm-generic/percpu.h:7,
                    from arch/alpha/include/asm/percpu.h:17,
                    from include/linux/irqflags.h:17,
                    from include/linux/spinlock.h:59,
                    from include/linux/wait.h:9,
                    from include/linux/dma-fence.h:17,
                    from include/drm/gpu_scheduler.h:28,
                    from drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h:28,
                    from drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h:29,
                    from drivers/gpu/drm/amd/amdgpu/amdgpu.h:43:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/percpu-defs.h:219:59: error: invalid use of undefined type 'struct kprobe_ctlblk'
     219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
         |                                                           ^
   include/linux/percpu-defs.h:241:9: note: in expansion of macro '__verify_pcpu_ptr'
     241 |         __verify_pcpu_ptr(ptr);                                         \
         |         ^~~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:252:27: note: in expansion of macro 'raw_cpu_ptr'
     252 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
         |                           ^~~~~~~~~~~
   include/linux/kprobes.h:414:16: note: in expansion of macro 'this_cpu_ptr'
     414 |         return this_cpu_ptr(&kprobe_ctlblk);
         |                ^~~~~~~~~~~~
   include/linux/kprobes.h: At top level:
   include/linux/kprobes.h:417:1: error: unknown type name 'kprobe_opcode_t'
     417 | kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:418:1: error: unknown type name 'kprobe_opcode_t'
     418 | kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h: In function 'kprobe_page_fault':
>> include/linux/kprobes.h:599:16: error: implicit declaration of function 'kprobe_fault_handler' [-Werror=implicit-function-declaration]
     599 |         return kprobe_fault_handler(regs, trap);
         |                ^~~~~~~~~~~~~~~~~~~~
   In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dc_types.h:37,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:30:
   drivers/gpu/drm/amd/amdgpu/../display/dc/dc_hdmi_types.h: At top level:
   drivers/gpu/drm/amd/amdgpu/../display/dc/dc_hdmi_types.h:53:22: warning: 'dp_hdmi_dongle_signature_str' defined but not used [-Wunused-const-variable=]
      53 | static const uint8_t dp_hdmi_dongle_signature_str[] = "DP-HDMI ADAPTOR";
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from include/linux/kgdb.h:19,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:31,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services.h:35,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dce_opp.c:26:
>> include/linux/kprobes.h:70:9: error: unknown type name 'kprobe_opcode_t'
      70 |         kprobe_opcode_t *addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:85:9: error: unknown type name 'kprobe_opcode_t'
      85 |         kprobe_opcode_t opcode;
         |         ^~~~~~~~~~~~~~~
>> include/linux/kprobes.h:88:35: error: field 'ainsn' has incomplete type
      88 |         struct arch_specific_insn ainsn;
         |                                   ^~~~~
   include/linux/kprobes.h:174:9: error: unknown type name 'kprobe_opcode_t'
     174 |         kprobe_opcode_t *ret_addr;
         |         ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:298:33: error: unknown type name 'kprobe_opcode_t'
     298 | extern int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
         |                                 ^~~~~~~~~~~~~~~
   In file included from include/asm-generic/percpu.h:7,
                    from arch/alpha/include/asm/percpu.h:17,
                    from include/linux/irqflags.h:17,
                    from include/linux/spinlock.h:59,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:7,
                    from include/linux/slab.h:15,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:30:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/percpu-defs.h:219:59: error: invalid use of undefined type 'struct kprobe_ctlblk'
     219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
         |                                                           ^
   include/linux/percpu-defs.h:241:9: note: in expansion of macro '__verify_pcpu_ptr'
     241 |         __verify_pcpu_ptr(ptr);                                         \
         |         ^~~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:252:27: note: in expansion of macro 'raw_cpu_ptr'
     252 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
         |                           ^~~~~~~~~~~
   include/linux/kprobes.h:414:16: note: in expansion of macro 'this_cpu_ptr'
     414 |         return this_cpu_ptr(&kprobe_ctlblk);
         |                ^~~~~~~~~~~~
   include/linux/kprobes.h: At top level:
   include/linux/kprobes.h:417:1: error: unknown type name 'kprobe_opcode_t'
     417 | kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h:418:1: error: unknown type name 'kprobe_opcode_t'
     418 | kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry);
         | ^~~~~~~~~~~~~~~
   include/linux/kprobes.h: In function 'kprobe_page_fault':
>> include/linux/kprobes.h:599:16: error: implicit declaration of function 'kprobe_fault_handler' [-Werror=implicit-function-declaration]
     599 |         return kprobe_fault_handler(regs, trap);
         |                ^~~~~~~~~~~~~~~~~~~~
   In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:32,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dce_opp.h:30,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dce_opp.c:29:
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h: At top level:
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:143:22: warning: 'SYNAPTICS_DEVICE_ID' defined but not used [-Wunused-const-variable=]
     143 | static const uint8_t SYNAPTICS_DEVICE_ID[] = "SYNA";
         |                      ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:140:22: warning: 'DP_VGA_LVDS_CONVERTER_ID_3' defined but not used [-Wunused-const-variable=]
     140 | static const uint8_t DP_VGA_LVDS_CONVERTER_ID_3[] = "dnomlA";
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:138:22: warning: 'DP_VGA_LVDS_CONVERTER_ID_2' defined but not used [-Wunused-const-variable=]
     138 | static const uint8_t DP_VGA_LVDS_CONVERTER_ID_2[] = "sivarT";
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:135:17: warning: 'DP_SINK_BRANCH_DEV_NAME_7580' defined but not used [-Wunused-const-variable=]
     135 | static const u8 DP_SINK_BRANCH_DEV_NAME_7580[] = "7580\x80u";
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:133:22: warning: 'DP_SINK_DEVICE_STR_ID_2' defined but not used [-Wunused-const-variable=]
     133 | static const uint8_t DP_SINK_DEVICE_STR_ID_2[] = {7, 1, 8, 7, 5};
         |                      ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:132:22: warning: 'DP_SINK_DEVICE_STR_ID_1' defined but not used [-Wunused-const-variable=]
     132 | static const uint8_t DP_SINK_DEVICE_STR_ID_1[] = {7, 1, 8, 7, 3};
         |                      ^~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dc_types.h:37,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:30:
   drivers/gpu/drm/amd/amdgpu/../display/dc/dc_hdmi_types.h:53:22: warning: 'dp_hdmi_dongle_signature_str' defined but not used [-Wunused-const-variable=]
      53 | static const uint8_t dp_hdmi_dongle_signature_str[] = "DP-HDMI ADAPTOR";
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
..

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for KPROBES
   Depends on [n]: MODULES [=y] && HAVE_KPROBES [=n]
   Selected by [y]:
   - TEST_STATIC_DEBUGOBJECT [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]


vim +/kprobe_opcode_t +70 include/linux/kprobes.h

d0aaff9796c331 Prasanna S Panchamukhi     2005-09-06  49  
^1da177e4c3f41 Linus Torvalds             2005-04-16  50  struct kprobe;
^1da177e4c3f41 Linus Torvalds             2005-04-16  51  struct pt_regs;
b94cce926b2b90 Hien Nguyen                2005-06-23  52  struct kretprobe;
b94cce926b2b90 Hien Nguyen                2005-06-23  53  struct kretprobe_instance;
^1da177e4c3f41 Linus Torvalds             2005-04-16  54  typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *);
^1da177e4c3f41 Linus Torvalds             2005-04-16  55  typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *,
^1da177e4c3f41 Linus Torvalds             2005-04-16  56  				       unsigned long flags);
b94cce926b2b90 Hien Nguyen                2005-06-23  57  typedef int (*kretprobe_handler_t) (struct kretprobe_instance *,
b94cce926b2b90 Hien Nguyen                2005-06-23  58  				    struct pt_regs *);
b94cce926b2b90 Hien Nguyen                2005-06-23  59  
^1da177e4c3f41 Linus Torvalds             2005-04-16  60  struct kprobe {
^1da177e4c3f41 Linus Torvalds             2005-04-16  61  	struct hlist_node hlist;
^1da177e4c3f41 Linus Torvalds             2005-04-16  62  
64f562c6df3cfc Ananth N Mavinakayanahalli 2005-05-05  63  	/* list of kprobes for multi-handler support */
64f562c6df3cfc Ananth N Mavinakayanahalli 2005-05-05  64  	struct list_head list;
64f562c6df3cfc Ananth N Mavinakayanahalli 2005-05-05  65  
ea32c65cc2d229 Prasanna S Panchamukhi     2005-06-23  66  	/*count the number of times this probe was temporarily disarmed */
ea32c65cc2d229 Prasanna S Panchamukhi     2005-06-23  67  	unsigned long nmissed;
ea32c65cc2d229 Prasanna S Panchamukhi     2005-06-23  68  
^1da177e4c3f41 Linus Torvalds             2005-04-16  69  	/* location of the probe point */
^1da177e4c3f41 Linus Torvalds             2005-04-16 @70  	kprobe_opcode_t *addr;
^1da177e4c3f41 Linus Torvalds             2005-04-16  71  
3a872d89baae82 Ananth N Mavinakayanahalli 2006-10-02  72  	/* Allow user to indicate symbol name of the probe point */
9b3af29bf33bfe Ananth N Mavinakayanahalli 2007-05-08  73  	const char *symbol_name;
3a872d89baae82 Ananth N Mavinakayanahalli 2006-10-02  74  
3a872d89baae82 Ananth N Mavinakayanahalli 2006-10-02  75  	/* Offset into the symbol */
3a872d89baae82 Ananth N Mavinakayanahalli 2006-10-02  76  	unsigned int offset;
3a872d89baae82 Ananth N Mavinakayanahalli 2006-10-02  77  
^1da177e4c3f41 Linus Torvalds             2005-04-16  78  	/* Called before addr is executed. */
^1da177e4c3f41 Linus Torvalds             2005-04-16  79  	kprobe_pre_handler_t pre_handler;
^1da177e4c3f41 Linus Torvalds             2005-04-16  80  
^1da177e4c3f41 Linus Torvalds             2005-04-16  81  	/* Called after addr is executed, unless... */
^1da177e4c3f41 Linus Torvalds             2005-04-16  82  	kprobe_post_handler_t post_handler;
^1da177e4c3f41 Linus Torvalds             2005-04-16  83  
^1da177e4c3f41 Linus Torvalds             2005-04-16  84  	/* Saved opcode (which has been replaced with breakpoint) */
^1da177e4c3f41 Linus Torvalds             2005-04-16  85  	kprobe_opcode_t opcode;
^1da177e4c3f41 Linus Torvalds             2005-04-16  86  
^1da177e4c3f41 Linus Torvalds             2005-04-16  87  	/* copy of the original instruction */
^1da177e4c3f41 Linus Torvalds             2005-04-16 @88  	struct arch_specific_insn ainsn;
e8386a0cb22f4a Masami Hiramatsu           2009-01-06  89  
de5bd88d5a5cce Masami Hiramatsu           2009-04-06  90  	/*
de5bd88d5a5cce Masami Hiramatsu           2009-04-06  91  	 * Indicates various status flags.
de5bd88d5a5cce Masami Hiramatsu           2009-04-06  92  	 * Protected by kprobe_mutex after this kprobe is registered.
de5bd88d5a5cce Masami Hiramatsu           2009-04-06  93  	 */
e8386a0cb22f4a Masami Hiramatsu           2009-01-06  94  	u32 flags;
^1da177e4c3f41 Linus Torvalds             2005-04-16  95  };
^1da177e4c3f41 Linus Torvalds             2005-04-16  96
  
kernel test robot March 4, 2023, 10:16 a.m. UTC | #2
Hi Schspa,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2 next-20230303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Schspa-Shi/debugobject-add-unit-test-for-static-debug-object/20230304-024247
patch link:    https://lore.kernel.org/r/20230303183147.934793-2-schspa%40gmail.com
patch subject: [PATCH v2 2/2] debugobject: add unit test for static debug object
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230304/202303041802.KTXFKBzL-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/54cf5a36c1c89cb79463e38bdbd636a016a80c66
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Schspa-Shi/debugobject-add-unit-test-for-static-debug-object/20230304-024247
        git checkout 54cf5a36c1c89cb79463e38bdbd636a016a80c66
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303041802.KTXFKBzL-lkp@intel.com/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "regs_get_register" [lib/test_static_debug_object.ko] undefined!
ERROR: modpost: "devm_ioremap_resource" [drivers/dma/qcom/hdma.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/fsl-edma.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/idma64.ko] undefined!
ERROR: modpost: "iounmap" [drivers/tty/ipwireless/ipwireless.ko] undefined!
ERROR: modpost: "ioremap" [drivers/tty/ipwireless/ipwireless.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/char/xillybus/xillybus_of.ko] undefined!
ERROR: modpost: "devm_memremap" [drivers/misc/open-dice.ko] undefined!
ERROR: modpost: "devm_memunmap" [drivers/misc/open-dice.ko] undefined!
ERROR: modpost: "iounmap" [drivers/net/ethernet/8390/pcnet_cs.ko] undefined!
WARNING: modpost: suppressed 16 unresolved symbol warnings because there were too many)
  

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index b0db911207ba4..38187e2921691 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23202,6 +23202,11 @@  L:	linux-mm@kvack.org
 S:	Maintained
 F:	mm/zswap.c
 
+STATIC DEBUGOBJECT TEST
+M:	Schspa Shi <schspa@gmail.com>
+S:	Maintained
+F:	lib/test_static_debug_object.c
+
 THE REST
 M:	Linus Torvalds <torvalds@linux-foundation.org>
 L:	linux-kernel@vger.kernel.org
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c8b379e2e9adc..9d5ee631d4380 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2801,6 +2801,20 @@  config TEST_CLOCKSOURCE_WATCHDOG
 
 	  If unsure, say N.
 
+config TEST_STATIC_DEBUGOBJECT
+	tristate "KUnit test for static debugobject"
+	depends on KUNIT
+	select KPROBES
+	select DEBUG_OBJECTS
+	select DEBUG_OBJECTS_TIMERS
+	help
+	  This builds the static debugobject unit test, which runs on boot.
+	  Tests the static debug object correctness.
+	  For more information on KUnit and unit tests in general please refer
+	  to the KUnit documentation in Documentation/dev-tools/kunit/.
+
+	  If unsure, say N.
+
 endif # RUNTIME_TESTING_MENU
 
 config ARCH_USE_MEMTEST
diff --git a/lib/Makefile b/lib/Makefile
index baf2821f7a00f..f663686beabd9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -427,3 +427,5 @@  $(obj)/$(TEST_FORTIFY_LOG): $(addprefix $(obj)/, $(TEST_FORTIFY_LOGS)) FORCE
 ifeq ($(CONFIG_FORTIFY_SOURCE),y)
 $(obj)/string.o: $(obj)/$(TEST_FORTIFY_LOG)
 endif
+
+obj-$(CONFIG_TEST_STATIC_DEBUGOBJECT) += test_static_debug_object.o
diff --git a/lib/test_static_debug_object.c b/lib/test_static_debug_object.c
new file mode 100644
index 0000000000000..8a0d6ab5c24b5
--- /dev/null
+++ b/lib/test_static_debug_object.c
@@ -0,0 +1,125 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * THis module tests the static debugobject via a static timer instance. This
+ * test use kretprobe to inject some delay to make the problem easier to
+ * reproduce.
+ *
+ * Copyright (c) 2023, Schspa Shi <schspa@gmail.com>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/delay.h>
+#include <linux/kprobes.h>
+#include <linux/workqueue.h>
+#include <linux/cpu.h>
+#include <kunit/test.h>
+
+static void ktest_timer_func(struct timer_list *);
+
+static DEFINE_TIMER(ktest_timer, ktest_timer_func);
+static int timer_stop;
+DEFINE_SPINLOCK(tlock);
+
+static DEFINE_PER_CPU(struct work_struct, timer_debugobject_test_work);
+
+static void timer_debugobject_workfn(struct work_struct *work)
+{
+	mod_timer(&ktest_timer, jiffies + (5 * HZ));
+}
+
+/*
+ * Reaper for links from keyrings to dead keys.
+ */
+static void ktest_timer_func(struct timer_list *t)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&tlock, flags);
+	if (!timer_stop)
+		mod_timer(&ktest_timer, jiffies + (1 * HZ));
+	spin_unlock_irqrestore(&tlock, flags);
+}
+
+
+static int static_object_check_handler(
+	struct kretprobe_instance *ri, struct pt_regs *regs)
+{
+	void *address;
+
+	address = (void *)regs_get_register(regs, 0);
+
+	if (address == &ktest_timer) {
+		int this_cpu = raw_smp_processor_id();
+		/*
+		 * This hook point adds an extra delay to make the problem
+		 * easier to reproduce. We need different delay for
+		 * differenct processor.
+		 */
+		mdelay(this_cpu * 100);
+	}
+
+	return 0;
+}
+
+
+static struct kretprobe is_static_kretprobes = {
+	.entry_handler = static_object_check_handler,
+	.data_size = 0,
+	/* Probe up to 512 instances concurrently. */
+	.maxactive = 512,
+	.kp = {
+		.symbol_name = "timer_is_static_object",
+	}
+};
+
+
+static void static_debugobject_test(struct kunit *test)
+{
+	unsigned long flags;
+	int cpu;
+	int ret;
+
+	ret = register_kretprobe(&is_static_kretprobes);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	/* Do test */
+	cpus_read_lock();
+	for_each_online_cpu(cpu) {
+		struct work_struct *work =
+			&per_cpu(timer_debugobject_test_work, cpu);
+		INIT_WORK(work, timer_debugobject_workfn);
+		schedule_work_on(cpu, work);
+	}
+
+	for_each_online_cpu(cpu) {
+		struct work_struct *work =
+			&per_cpu(timer_debugobject_test_work, cpu);
+		flush_work(work);
+	}
+	cpus_read_unlock();
+
+	spin_lock_irqsave(&tlock, flags);
+	timer_stop = 0;
+	spin_unlock_irqrestore(&tlock, flags);
+
+	del_timer_sync(&ktest_timer);
+
+	unregister_kretprobe(&is_static_kretprobes);
+}
+
+static struct kunit_case static_debugobject_init_cases[] = {
+	KUNIT_CASE(static_debugobject_test),
+	{}
+};
+
+static struct kunit_suite static_debugobject_suite = {
+	.name = "static debugobject init",
+	.test_cases = static_debugobject_init_cases,
+};
+
+kunit_test_suite(static_debugobject_suite);
+MODULE_AUTHOR("Schspa <schspa@gmail.com>");
+MODULE_LICENSE("GPL");