Re: [RFC PATCH v2 4/4] sched+mm: Use hazard pointers to track lazy active mm existence

From: Mathieu Desnoyers
Date: Mon Oct 07 2024 - 11:09:32 EST


On 2024-10-07 16:50, kernel test robot wrote:


Hello,

kernel test robot noticed "BUG:using_smp_processor_id()in_preemptible" on:

commit: efef4da3b19cadf4beb45079a05643a77821de79 ("[RFC PATCH v2 4/4] sched+mm: Use hazard pointers to track lazy active mm existence")
url: https://github.com/intel-lab-lkp/linux/commits/Mathieu-Desnoyers/compiler-h-Introduce-ptr_eq-to-preserve-address-dependency/20241005-023027
base: https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/all/20241004182734.1761555-5-mathieu.desnoyers@xxxxxxxxxxxx/
patch subject: [RFC PATCH v2 4/4] sched+mm: Use hazard pointers to track lazy active mm existence


This should do the trick:

- WRITE_ONCE(this_cpu_ptr(hp_domain_sched_lazy_mm.percpu_slots)->addr, NULL);
+ this_cpu_write(hp_domain_sched_lazy_mm.percpu_slots->addr, NULL);

I'll update the patch for the next round.

Thanks,

Mathieu


in testcase: boot

compiler: gcc-12
test machine: qemu-system-i386 -enable-kvm -cpu SandyBridge -smp 2 -m 4G

(please refer to attached dmesg/kmsg for entire log/backtrace)


+--------------------------------------------+------------+------------+
| | 75b478bf10 | efef4da3b1 |
+--------------------------------------------+------------+------------+
| BUG:using_smp_processor_id()in_preemptible | 0 | 12 |
+--------------------------------------------+------------+------------+


If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-lkp/202410072229.18756716-oliver.sang@xxxxxxxxx


[ 6.336856][ T48] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u10:1/48
[ 6.338102][ T48] caller is debug_smp_processor_id (lib/smp_processor_id.c:61)
[ 6.338809][ T48] CPU: 0 UID: 0 PID: 48 Comm: kworker/u10:1 Not tainted 6.12.0-rc1-00004-gefef4da3b19c #5
[ 6.339929][ T48] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[ 6.341119][ T48] Call Trace:
[ 6.341504][ T48] dump_stack_lvl (lib/dump_stack.c:123)
[ 6.342057][ T48] dump_stack (lib/dump_stack.c:130)
[ 6.342065][ T48] check_preemption_disabled (arch/x86/include/asm/preempt.h:84 lib/smp_processor_id.c:53)
[ 6.342065][ T48] debug_smp_processor_id (lib/smp_processor_id.c:61)
[ 6.342065][ T48] exec_mmap (include/linux/sched/mm.h:91 fs/exec.c:1017)
[ 6.342065][ T48] ? would_dump (fs/exec.c:1409)
[ 6.342065][ T48] begin_new_exec (fs/exec.c:1280)
[ 6.342065][ T48] ? load_elf_phdrs (fs/binfmt_elf.c:534)
[ 6.342065][ T48] load_elf_binary (fs/binfmt_elf.c:996)
[ 6.342065][ T48] ? get_lock_stats (kernel/locking/lockdep.c:339)
[ 6.342065][ T48] ? search_binary_handler (fs/exec.c:1752)
[ 6.342065][ T48] search_binary_handler (fs/exec.c:1752)
[ 6.342065][ T48] exec_binprm (fs/exec.c:1795)
[ 6.342065][ T48] bprm_execve (fs/exec.c:1846 fs/exec.c:1821)
[ 6.342065][ T48] kernel_execve (fs/exec.c:2012)
[ 6.342065][ T48] call_usermodehelper_exec_async (kernel/umh.c:110)
[ 6.342065][ T48] ? umh_complete (kernel/umh.c:65)
[ 6.342065][ T48] ret_from_fork (arch/x86/kernel/process.c:153)
[ 6.342065][ T48] ? umh_complete (kernel/umh.c:65)
[ 6.342065][ T48] ret_from_fork_asm (arch/x86/entry/entry_32.S:737)
[ 6.342065][ T48] entry_INT80_32 (arch/x86/entry/entry_32.S:944)
[ 6.352140][ T1] ppdev: user-space parallel port driver
[ 6.353841][ T1] HSI/SSI char device loaded
[ 6.354238][ T1] e1000: Intel(R) PRO/1000 Network Driver
[ 6.354673][ T1] e1000: Copyright (c) 1999-2006 Intel Corporation.
[ 6.650009][ T1] ACPI: _SB_.LNKC: Enabled at IRQ 11
[ 6.968868][ T1] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[ 6.969500][ T1] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[ 6.970506][ T49] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u10:1/49
[ 6.971191][ T49] caller is debug_smp_processor_id (lib/smp_processor_id.c:61)
[ 6.971650][ T49] CPU: 0 UID: 0 PID: 49 Comm: kworker/u10:1 Not tainted 6.12.0-rc1-00004-gefef4da3b19c #5
[ 6.972365][ T49] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[ 6.973115][ T49] Call Trace:
[ 6.973356][ T49] dump_stack_lvl (lib/dump_stack.c:123)
[ 6.973686][ T49] dump_stack (lib/dump_stack.c:130)
[ 6.973983][ T49] check_preemption_disabled (arch/x86/include/asm/preempt.h:84 lib/smp_processor_id.c:53)
[ 6.974328][ T49] debug_smp_processor_id (lib/smp_processor_id.c:61)
[ 6.974328][ T49] exec_mmap (include/linux/sched/mm.h:91 fs/exec.c:1017)
[ 6.974328][ T49] ? would_dump (fs/exec.c:1409)
[ 6.974328][ T49] begin_new_exec (fs/exec.c:1280)
[ 6.974328][ T49] ? load_elf_phdrs (fs/binfmt_elf.c:534)
[ 6.974328][ T49] load_elf_binary (fs/binfmt_elf.c:996)
[ 6.974328][ T49] ? get_lock_stats (kernel/locking/lockdep.c:339)
[ 6.974328][ T49] ? search_binary_handler (fs/exec.c:1752)
[ 6.974328][ T49] search_binary_handler (fs/exec.c:1752)
[ 6.974328][ T49] exec_binprm (fs/exec.c:1795)
[ 6.974328][ T49] bprm_execve (fs/exec.c:1846 fs/exec.c:1821)
[ 6.974328][ T49] kernel_execve (fs/exec.c:2012)
[ 6.974328][ T49] call_usermodehelper_exec_async (kernel/umh.c:110)
[ 6.974328][ T49] ? umh_complete (kernel/umh.c:65)
[ 6.974328][ T49] ret_from_fork (arch/x86/kernel/process.c:153)
[ 6.974328][ T49] ? umh_complete (kernel/umh.c:65)
[ 6.974328][ T49] ret_from_fork_asm (arch/x86/entry/entry_32.S:737)
[ 6.974328][ T49] entry_INT80_32 (arch/x86/entry/entry_32.S:944)



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20241007/202410072229.18756716-oliver.sang@xxxxxxxxx




--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com