drivers/base/core.c | 1 - 1 file changed, 1 deletion(-)
Hello.
I tried to apply below patch, and hit lockdep warning during boot.
Can you break this dependency?
----------
From f7ff56455ae7813768c6ab85e8e3db374122f32b Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Mon, 23 Jan 2023 19:32:26 +0900
Subject: [PATCH] drivers/core: Remove lockdep_set_novalidate_class() usage
This patch experimentally removes lockdep_set_novalidate_class() call
from device_initialize() introduced by commit 1704f47b50b5 ("lockdep:
Add novalidate class for dev->mutex conversion"), for this commit made it
impossible to find real deadlocks unless timing dependent testings manage
to trigger hung task like [1] and [2]. Let's try if we can find remaining
drivers which need to use separate classes without causing too many crashes
to continue.
[1] https://syzkaller.appspot.com/bug?extid=2d6ac90723742279e101
[2] https://syzkaller.appspot.com/bug?extid=2e39bc6569d281acbcfb
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
drivers/base/core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a3e14143ec0c..68189722e343 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2941,7 +2941,6 @@ void device_initialize(struct device *dev)
kobject_init(&dev->kobj, &device_ktype);
INIT_LIST_HEAD(&dev->dma_pools);
mutex_init(&dev->mutex);
- lockdep_set_novalidate_class(&dev->mutex);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_pm_init(dev);
--
2.18.4
----------
----------
[ 2.241650][ T9] Trying to unpack rootfs image as initramfs...
[ 2.241630][ T1] software IO TLB: mapped [mem 0x00000000bbed0000-0x00000000bfed0000] (64MB)
[ 2.241670][ T1] workingset: timestamp_bits=46 max_order=21 bucket_order=0
[ 2.241670][ T1] SGI XFS with ACLs, security attributes, verbose warnings, quota, no debug enabled
[ 2.241670][ T1] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[ 2.798150][ T1]
[ 2.798660][ T1] ======================================================
[ 2.798660][ T1] WARNING: possible circular locking dependency detected
[ 2.798660][ T1] 6.2.0-rc5+ #9 Not tainted
[ 2.798660][ T1] ------------------------------------------------------
[ 2.798660][ T1] swapper/0/1 is trying to acquire lock:
[ 2.798660][ T1] ffffffffb002e888 (cpu_add_remove_lock){+.+.}-{3:3}, at: cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1]
[ 2.798660][ T1] but task is already holding lock:
[ 2.798660][ T1] ffff941940a161b8 (&dev->mutex){+.+.}-{3:3}, at: __device_driver_lock+0x28/0x40
[ 2.798660][ T1]
[ 2.798660][ T1] which lock already depends on the new lock.
[ 2.798660][ T1]
[ 2.798660][ T1]
[ 2.798660][ T1] the existing dependency chain (in reverse order) is:
[ 2.798660][ T1]
[ 2.798660][ T1] -> #3 (&dev->mutex){+.+.}-{3:3}:
[ 2.798660][ T1] lock_acquire+0xc7/0x2e0
[ 2.798660][ T1] __mutex_lock+0x99/0xf00
[ 2.798660][ T1] mutex_lock_nested+0x16/0x20
[ 2.798660][ T1] __device_attach+0x35/0x1a0
[ 2.798660][ T1] device_initial_probe+0xe/0x10
[ 2.798660][ T1] bus_probe_device+0x9b/0xb0
[ 2.798660][ T1] device_add+0x3e1/0x900
[ 2.798660][ T1] pmu_dev_alloc+0x98/0xf0
[ 2.798660][ T1] perf_event_sysfs_init+0x56/0x8f
[ 2.798660][ T1] do_one_initcall+0x58/0x300
[ 2.798660][ T1] kernel_init_freeable+0x181/0x1d2
[ 2.798660][ T1] kernel_init+0x15/0x120
[ 2.798660][ T1] ret_from_fork+0x1f/0x30
[ 2.798660][ T1]
[ 2.798660][ T1] -> #2 (pmus_lock){+.+.}-{3:3}:
[ 2.798660][ T1] lock_acquire+0xc7/0x2e0
[ 2.798660][ T1] __mutex_lock+0x99/0xf00
[ 2.798660][ T1] mutex_lock_nested+0x16/0x20
[ 2.798660][ T1] perf_event_init_cpu+0x4c/0x110
[ 2.798660][ T1] cpuhp_invoke_callback+0x17a/0x880
[ 2.798660][ T1] __cpuhp_invoke_callback_range+0x77/0xb0
[ 2.798660][ T1] _cpu_up+0xdc/0x240
[ 2.798660][ T1] cpu_up+0x8c/0xa0
[ 2.798660][ T1] bringup_nonboot_cpus+0x56/0x60
[ 2.798660][ T1] smp_init+0x25/0x5f
[ 2.798660][ T1] kernel_init_freeable+0xb4/0x1d2
[ 2.798660][ T1] kernel_init+0x15/0x120
[ 2.798660][ T1] ret_from_fork+0x1f/0x30
[ 2.798660][ T1]
[ 2.798660][ T1] -> #1 (cpu_hotplug_lock){++++}-{0:0}:
[ 2.798660][ T1] lock_acquire+0xc7/0x2e0
[ 2.798660][ T1] percpu_down_write+0x44/0x2c0
[ 2.798660][ T1] _cpu_up+0x35/0x240
[ 2.798660][ T1] cpu_up+0x8c/0xa0
[ 2.798660][ T1] bringup_nonboot_cpus+0x56/0x60
[ 2.798660][ T1] smp_init+0x25/0x5f
[ 2.798660][ T1] kernel_init_freeable+0xb4/0x1d2
[ 2.798660][ T1] kernel_init+0x15/0x120
[ 2.798660][ T1] ret_from_fork+0x1f/0x30
[ 2.798660][ T1]
[ 2.798660][ T1] -> #0 (cpu_add_remove_lock){+.+.}-{3:3}:
[ 2.798660][ T1] check_prevs_add+0x16a/0x1070
[ 2.798660][ T1] __lock_acquire+0x11bd/0x1670
[ 2.798660][ T1] lock_acquire+0xc7/0x2e0
[ 2.798660][ T1] __mutex_lock+0x99/0xf00
[ 2.798660][ T1] mutex_lock_nested+0x16/0x20
[ 2.798660][ T1] cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1] pci_device_probe+0x8c/0x150
[ 2.798660][ T1] really_probe+0xd9/0x340
[ 2.798660][ T1] __driver_probe_device+0x78/0x170
[ 2.798660][ T1] driver_probe_device+0x1f/0x90
[ 2.798660][ T1] __driver_attach+0xaa/0x160
[ 2.798660][ T1] bus_for_each_dev+0x75/0xb0
[ 2.798660][ T1] driver_attach+0x19/0x20
[ 2.798660][ T1] bus_add_driver+0x1be/0x210
[ 2.798660][ T1] driver_register+0x6b/0xc0
[ 2.798660][ T1] __pci_register_driver+0x7c/0x80
[ 2.798660][ T1] pcie_portdrv_init+0x3d/0x45
[ 2.798660][ T1] do_one_initcall+0x58/0x300
[ 2.798660][ T1] kernel_init_freeable+0x181/0x1d2
[ 2.798660][ T1] kernel_init+0x15/0x120
[ 2.798660][ T1] ret_from_fork+0x1f/0x30
[ 2.798660][ T1]
[ 2.798660][ T1] other info that might help us debug this:
[ 2.798660][ T1]
[ 2.798660][ T1] Chain exists of:
[ 2.798660][ T1] cpu_add_remove_lock --> pmus_lock --> &dev->mutex
[ 2.798660][ T1]
[ 2.798660][ T1] Possible unsafe locking scenario:
[ 2.798660][ T1]
[ 2.798660][ T1] CPU0 CPU1
[ 2.798660][ T1] ---- ----
[ 2.798660][ T1] lock(&dev->mutex);
[ 2.798660][ T1] lock(pmus_lock);
[ 2.798660][ T1] lock(&dev->mutex);
[ 2.798660][ T1] lock(cpu_add_remove_lock);
[ 2.798660][ T1]
[ 2.798660][ T1] *** DEADLOCK ***
[ 2.798660][ T1]
[ 2.798660][ T1] 1 lock held by swapper/0/1:
[ 2.798660][ T1] #0: ffff941940a161b8 (&dev->mutex){+.+.}-{3:3}, at: __device_driver_lock+0x28/0x40
[ 2.798660][ T1]
[ 2.798660][ T1] stack backtrace:
[ 2.798660][ T1] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc5+ #9
[ 2.798660][ T1] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020
[ 2.798660][ T1] Call Trace:
[ 2.798660][ T1] <TASK>
[ 2.798660][ T1] dump_stack_lvl+0x49/0x5e
[ 2.798660][ T1] dump_stack+0x10/0x12
[ 2.798660][ T1] print_circular_bug.isra.46.cold.66+0x13e/0x143
[ 2.798660][ T1] check_noncircular+0xfe/0x110
[ 2.798660][ T1] check_prevs_add+0x16a/0x1070
[ 2.798660][ T1] __lock_acquire+0x11bd/0x1670
[ 2.798660][ T1] lock_acquire+0xc7/0x2e0
[ 2.798660][ T1] ? cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1] __mutex_lock+0x99/0xf00
[ 2.798660][ T1] ? cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1] ? pci_match_device+0xd5/0x130
[ 2.798660][ T1] ? __this_cpu_preempt_check+0x13/0x20
[ 2.798660][ T1] ? cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1] ? kernfs_add_one+0xf1/0x130
[ 2.798660][ T1] mutex_lock_nested+0x16/0x20
[ 2.798660][ T1] ? mutex_lock_nested+0x16/0x20
[ 2.798660][ T1] cpu_hotplug_disable+0x12/0x30
[ 2.798660][ T1] pci_device_probe+0x8c/0x150
[ 2.798660][ T1] really_probe+0xd9/0x340
[ 2.798660][ T1] ? pm_runtime_barrier+0x52/0xb0
[ 2.798660][ T1] __driver_probe_device+0x78/0x170
[ 2.798660][ T1] driver_probe_device+0x1f/0x90
[ 2.798660][ T1] __driver_attach+0xaa/0x160
[ 2.798660][ T1] ? __device_attach_driver+0x100/0x100
[ 2.798660][ T1] bus_for_each_dev+0x75/0xb0
[ 2.798660][ T1] driver_attach+0x19/0x20
[ 2.798660][ T1] bus_add_driver+0x1be/0x210
[ 2.798660][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f
[ 2.798660][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f
[ 2.798660][ T1] ? rdinit_setup+0x27/0x27
[ 2.798660][ T1] driver_register+0x6b/0xc0
[ 2.798660][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f
[ 2.798660][ T1] __pci_register_driver+0x7c/0x80
[ 2.798660][ T1] pcie_portdrv_init+0x3d/0x45
[ 2.798660][ T1] do_one_initcall+0x58/0x300
[ 2.798660][ T1] ? rdinit_setup+0x27/0x27
[ 2.798660][ T1] ? rcu_read_lock_sched_held+0x4a/0x70
[ 2.798660][ T1] kernel_init_freeable+0x181/0x1d2
[ 2.798660][ T1] ? rest_init+0x190/0x190
[ 2.798660][ T1] kernel_init+0x15/0x120
[ 2.798660][ T1] ret_from_fork+0x1f/0x30
[ 2.798660][ T1] </TASK>
[ 3.991673][ T92] tsc: Refined TSC clocksource calibration: 2611.210 MHz
[ 3.991673][ T92] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x25a399d04c4, max_idle_ns: 440795206293 ns
[ 4.992946][ T92] clocksource: Switched to clocksource tsc
----------
On Mon, Jan 23, 2023 at 07:39:24PM +0900, Tetsuo Handa wrote: > Hello. > > I tried to apply below patch, and hit lockdep warning during boot. > Can you break this dependency? cpu_add_remove_lock cpu_hotplug_lock pmus_lock dev->mutex (pmu_dev_alloc) vs dev->mutex cpu_add_remove_lock (pci_device_probe) Possibly something like this might do -- I'm not entirely sure it's fully correct, needs a bit of auditing. --- diff --git a/kernel/events/core.c b/kernel/events/core.c index eacc3702654d..d6b2265a9982 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -13570,9 +13570,9 @@ static void perf_event_exit_cpu_context(int cpu) { struct perf_cpu_context *cpuctx; struct perf_event_context *ctx; + int idx = srcu_read_lock(&pmus_srcu); // XXX simplify cpuctx->online - mutex_lock(&pmus_lock); cpuctx = per_cpu_ptr(&perf_cpu_context, cpu); ctx = &cpuctx->ctx; @@ -13581,7 +13581,7 @@ static void perf_event_exit_cpu_context(int cpu) cpuctx->online = 0; mutex_unlock(&ctx->mutex); cpumask_clear_cpu(cpu, perf_online_mask); - mutex_unlock(&pmus_lock); + srcu_read_unlock(&pmus_srcu, idx); } #else @@ -13593,10 +13594,11 @@ int perf_event_init_cpu(unsigned int cpu) { struct perf_cpu_context *cpuctx; struct perf_event_context *ctx; + int idx; perf_swevent_init_cpu(cpu); - mutex_lock(&pmus_lock); + idx = srcu_read_lock(&pmus_srcu); cpumask_set_cpu(cpu, perf_online_mask); cpuctx = per_cpu_ptr(&perf_cpu_context, cpu); ctx = &cpuctx->ctx; @@ -13604,7 +13606,7 @@ int perf_event_init_cpu(unsigned int cpu) mutex_lock(&ctx->mutex); cpuctx->online = 1; mutex_unlock(&ctx->mutex); - mutex_unlock(&pmus_lock); + srcu_read_unlock(&pmus_srcu, idx); return 0; }
On 2023/01/23 20:41, Peter Zijlstra wrote: > On Mon, Jan 23, 2023 at 07:39:24PM +0900, Tetsuo Handa wrote: >> Hello. >> >> I tried to apply below patch, and hit lockdep warning during boot. >> Can you break this dependency? > > cpu_add_remove_lock > cpu_hotplug_lock > pmus_lock > dev->mutex (pmu_dev_alloc) > > vs > > dev->mutex > cpu_add_remove_lock (pci_device_probe) > > > Possibly something like this might do -- I'm not entirely sure it's > fully correct, needs a bit of auditing. > After applying your diff, lockdep message changed like below. Is this the reason commit 1704f47b50b5 ("lockdep: Add novalidate class for dev->mutex conversion") was applied? ---------- [ 2.276394][ T9] Trying to unpack rootfs image as initramfs... [ 2.276394][ T1] software IO TLB: mapped [mem 0x00000000bbed0000-0x00000000bfed0000] (64MB) [ 2.276394][ T1] workingset: timestamp_bits=46 max_order=21 bucket_order=0 [ 2.276394][ T1] SGI XFS with ACLs, security attributes, verbose warnings, quota, no debug enabled [ 2.276394][ T1] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 2.837244][ T1] [ 2.837244][ T1] ============================================ [ 2.837244][ T1] WARNING: possible recursive locking detected [ 2.837244][ T1] 6.2.0-rc5+ #10 Not tainted [ 2.837244][ T1] -------------------------------------------- [ 2.837244][ T1] swapper/0/1 is trying to acquire lock: [ 2.837244][ T1] ffff984dc3d50108 (&dev->mutex){+.+.}-{3:3}, at: __device_attach+0x35/0x1a0 [ 2.837244][ T1] [ 2.837244][ T1] but task is already holding lock: [ 2.837244][ T1] ffff984dc1b5e1b8 (&dev->mutex){+.+.}-{3:3}, at: __device_driver_lock+0x28/0x40 [ 2.837244][ T1] [ 2.837244][ T1] other info that might help us debug this: [ 2.837244][ T1] Possible unsafe locking scenario: [ 2.837244][ T1] [ 2.837244][ T1] CPU0 [ 2.837244][ T1] ---- [ 2.837244][ T1] lock(&dev->mutex); [ 2.837244][ T1] lock(&dev->mutex); [ 2.837244][ T1] [ 2.837244][ T1] *** DEADLOCK *** [ 2.837244][ T1] [ 2.837244][ T1] May be due to missing lock nesting notation [ 2.837244][ T1] [ 2.837244][ T1] 1 lock held by swapper/0/1: [ 2.837244][ T1] #0: ffff984dc1b5e1b8 (&dev->mutex){+.+.}-{3:3}, at: __device_driver_lock+0x28/0x40 [ 2.837244][ T1] [ 2.837244][ T1] stack backtrace: [ 2.837244][ T1] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc5+ #10 [ 2.837244][ T1] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020 [ 2.837244][ T1] Call Trace: [ 2.837244][ T1] <TASK> [ 2.837244][ T1] dump_stack_lvl+0x49/0x5e [ 2.837244][ T1] dump_stack+0x10/0x12 [ 2.837244][ T1] __lock_acquire.cold.73+0x12e/0x2c7 [ 2.837244][ T1] lock_acquire+0xc7/0x2e0 [ 2.837244][ T1] ? __device_attach+0x35/0x1a0 [ 2.837244][ T1] __mutex_lock+0x99/0xf00 [ 2.837244][ T1] ? __device_attach+0x35/0x1a0 [ 2.837244][ T1] ? __this_cpu_preempt_check+0x13/0x20 [ 2.837244][ T1] ? __device_attach+0x35/0x1a0 [ 2.837244][ T1] ? kobject_uevent_env+0x12f/0x770 [ 2.837244][ T1] mutex_lock_nested+0x16/0x20 [ 2.837244][ T1] ? mutex_lock_nested+0x16/0x20 [ 2.837244][ T1] __device_attach+0x35/0x1a0 [ 2.837244][ T1] device_initial_probe+0xe/0x10 [ 2.837244][ T1] bus_probe_device+0x9b/0xb0 [ 2.837244][ T1] device_add+0x3e1/0x900 [ 2.837244][ T1] ? __init_waitqueue_head+0x4a/0x70 [ 2.837244][ T1] device_register+0x15/0x20 [ 2.837244][ T1] pcie_portdrv_probe+0x3e3/0x670 [ 2.837244][ T1] ? trace_hardirqs_on+0x3b/0x100 [ 2.837244][ T1] pci_device_probe+0xa8/0x150 [ 2.837244][ T1] really_probe+0xd9/0x340 [ 2.837244][ T1] ? pm_runtime_barrier+0x52/0xb0 [ 2.837244][ T1] __driver_probe_device+0x78/0x170 [ 2.837244][ T1] driver_probe_device+0x1f/0x90 [ 2.837244][ T1] __driver_attach+0xaa/0x160 [ 2.837244][ T1] ? __device_attach_driver+0x100/0x100 [ 2.837244][ T1] bus_for_each_dev+0x75/0xb0 [ 2.837244][ T1] driver_attach+0x19/0x20 [ 2.837244][ T1] bus_add_driver+0x1be/0x210 [ 2.837244][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f [ 2.837244][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f [ 2.837244][ T1] ? rdinit_setup+0x27/0x27 [ 2.837244][ T1] driver_register+0x6b/0xc0 [ 2.837244][ T1] ? dmi_pcie_pme_disable_msi+0x1f/0x1f [ 2.837244][ T1] __pci_register_driver+0x7c/0x80 [ 2.837244][ T1] pcie_portdrv_init+0x3d/0x45 [ 2.837244][ T1] do_one_initcall+0x58/0x300 [ 2.837244][ T1] ? rdinit_setup+0x27/0x27 [ 2.837244][ T1] ? rcu_read_lock_sched_held+0x4a/0x70 [ 2.837244][ T1] kernel_init_freeable+0x181/0x1d2 [ 2.837244][ T1] ? rest_init+0x190/0x190 [ 2.837244][ T1] kernel_init+0x15/0x120 [ 2.837244][ T1] ret_from_fork+0x1f/0x30 [ 2.837244][ T1] </TASK> [ 4.126397][ T1] pcieport 0000:00:15.0: PME: Signaling with IRQ 24 [ 4.126397][ T1] pcieport 0000:00:15.0: pciehp: Slot #160 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ IbPresDis- LLActRep+ [ 4.126397][ T1] pcieport 0000:00:15.1: PME: Signaling with IRQ 25 ---------- # ./scripts/faddr2line --list vmlinux __device_attach+0x35/0x1a0 __device_driver_lock+0x28/0x40 __device_attach+0x35/0x1a0: __device_attach at drivers/base/dd.c:984 979 { 980 int ret = 0; 981 bool async = false; 982 983 device_lock(dev); >984< if (dev->p->dead) { 985 goto out_unlock; 986 } else if (dev->driver) { 987 if (device_is_bound(dev)) { 988 ret = 1; 989 goto out_unlock; __device_driver_lock+0x28/0x40: __device_driver_lock at drivers/base/dd.c:1074 1069 static void __device_driver_lock(struct device *dev, struct device *parent) 1070 { 1071 if (parent && dev->bus->need_parent_lock) 1072 device_lock(parent); 1073 device_lock(dev); >1074< } 1075 1076 /* 1077 * __device_driver_unlock - release locks needed to manipulate dev->drv 1078 * @dev: Device we will update driver info for 1079 * @parent: Parent device. Needed if the bus requires parent lock # ./scripts/faddr2line vmlinux __device_attach+0x35/0x1a0 device_initial_probe+0xe/0x10 bus_probe_device+0x9b/0xb0 device_add+0x3e1/0x900 device_register+0x15/0x20 pcie_portdrv_probe+0x3e3/0x670 pci_device_probe+0xa8/0x150 really_probe+0xd9/0x340 __driver_probe_device+0x78/0x170 driver_probe_device+0x1f/0x90 __driver_attach+0xaa/0x160 bus_for_each_dev+0x75/0xb0 driver_attach+0x19/0x20 bus_add_driver+0x1be/0x210 driver_register+0x6b/0xc0 __device_attach+0x35/0x1a0: __device_attach at drivers/base/dd.c:984 device_initial_probe+0xe/0x10: device_initial_probe at drivers/base/dd.c:1058 bus_probe_device+0x9b/0xb0: bus_probe_device at drivers/base/bus.c:487 device_add+0x3e1/0x900: device_add at drivers/base/core.c:3485 device_register+0x15/0x20: device_register at drivers/base/core.c:3560 pcie_portdrv_probe+0x3e3/0x670: pcie_device_init at drivers/pci/pcie/portdrv.c:310 (inlined by) pcie_port_device_register at drivers/pci/pcie/portdrv.c:363 (inlined by) pcie_portdrv_probe at drivers/pci/pcie/portdrv.c:696 pci_device_probe+0xa8/0x150: local_pci_probe at drivers/pci/pci-driver.c:324 (inlined by) pci_call_probe at drivers/pci/pci-driver.c:392 (inlined by) __pci_device_probe at drivers/pci/pci-driver.c:417 (inlined by) pci_device_probe at drivers/pci/pci-driver.c:460 really_probe+0xd9/0x340: call_driver_probe at drivers/base/dd.c:560 (inlined by) really_probe at drivers/base/dd.c:639 __driver_probe_device+0x78/0x170: __driver_probe_device at drivers/base/dd.c:778 driver_probe_device+0x1f/0x90: driver_probe_device at drivers/base/dd.c:808 __driver_attach+0xaa/0x160: __driver_attach at drivers/base/dd.c:1195 bus_for_each_dev+0x75/0xb0: bus_for_each_dev at drivers/base/bus.c:300 driver_attach+0x19/0x20: driver_attach at drivers/base/dd.c:1212 bus_add_driver+0x1be/0x210: bus_add_driver at drivers/base/bus.c:619 driver_register+0x6b/0xc0: driver_register at drivers/base/driver.c:246
On Mon, Jan 23, 2023 at 11:10:57PM +0900, Tetsuo Handa wrote: > On 2023/01/23 20:41, Peter Zijlstra wrote: > > On Mon, Jan 23, 2023 at 07:39:24PM +0900, Tetsuo Handa wrote: > >> Hello. > >> > >> I tried to apply below patch, and hit lockdep warning during boot. > >> Can you break this dependency? > > > > cpu_add_remove_lock > > cpu_hotplug_lock > > pmus_lock > > dev->mutex (pmu_dev_alloc) > > > > vs > > > > dev->mutex > > cpu_add_remove_lock (pci_device_probe) > > > > > > Possibly something like this might do -- I'm not entirely sure it's > > fully correct, needs a bit of auditing. > > > > After applying your diff, lockdep message changed like below. Is this > the reason commit 1704f47b50b5 ("lockdep: Add novalidate class for > dev->mutex conversion") was applied? *sigh*, clearly I should have actually read the slat and not assumed it was another perf splat. Yes, something along these lines is why it was done. I think it was this thread, but there might have been more: https://lore.kernel.org/all/Pine.LNX.4.44L0.0804171117450.18040-100000@iolanthe.rowland.org/
On Mon, Jan 23, 2023 at 11:10:57PM +0900, Tetsuo Handa wrote: > After applying your diff, lockdep message changed like below. Is this > the reason commit 1704f47b50b5 ("lockdep: Add novalidate class for > dev->mutex conversion") was applied? No, reason was device probing itself. There should be a thread about that with Alan Stern some 15 years ago or so. I'll try and have a look at the new splat later today.
© 2016 - 2025 Red Hat, Inc.