Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'locking-urgent-2025-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull misc locking fixes and updates from Ingo Molnar:

- Fix a locking self-test FAIL on PREEMPT_RT kernels

- Fix nr_unused_locks accounting bug

- Simplify the split-lock debugging feature's fast-path

* tag 'locking-urgent-2025-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class()
lockdep: Fix wait context check on softirq for PREEMPT_RT
x86/split_lock: Simplify reenabling

+45 -11
+24 -11
arch/x86/kernel/cpu/bus_lock.c
··· 201 201 static DEFINE_PER_CPU(struct delayed_work, sl_reenable); 202 202 203 203 /* 204 + * Per-CPU delayed_work can't be statically initialized properly because 205 + * the struct address is unknown. Thus per-CPU delayed_work structures 206 + * have to be initialized during kernel initialization and after calling 207 + * setup_per_cpu_areas(). 208 + */ 209 + static int __init setup_split_lock_delayed_work(void) 210 + { 211 + unsigned int cpu; 212 + 213 + for_each_possible_cpu(cpu) { 214 + struct delayed_work *work = per_cpu_ptr(&sl_reenable, cpu); 215 + 216 + INIT_DELAYED_WORK(work, __split_lock_reenable); 217 + } 218 + 219 + return 0; 220 + } 221 + pure_initcall(setup_split_lock_delayed_work); 222 + 223 + /* 204 224 * If a CPU goes offline with pending delayed work to re-enable split lock 205 225 * detection then the delayed work will be executed on some other CPU. That 206 226 * handles releasing the buslock_sem, but because it executes on a ··· 239 219 240 220 static void split_lock_warn(unsigned long ip) 241 221 { 242 - struct delayed_work *work = NULL; 222 + struct delayed_work *work; 243 223 int cpu; 224 + unsigned int saved_sld_mitigate = READ_ONCE(sysctl_sld_mitigate); 244 225 245 226 if (!current->reported_split_lock) 246 227 pr_warn_ratelimited("#AC: %s/%d took a split_lock trap at address: 0x%lx\n", 247 228 current->comm, current->pid, ip); 248 229 current->reported_split_lock = 1; 249 230 250 - if (sysctl_sld_mitigate) { 231 + if (saved_sld_mitigate) { 251 232 /* 252 233 * misery factor #1: 253 234 * sleep 10ms before trying to execute split lock. ··· 261 240 */ 262 241 if (down_interruptible(&buslock_sem) == -EINTR) 263 242 return; 264 - work = &sl_reenable_unlock; 265 243 } 266 244 267 245 cpu = get_cpu(); 268 - 269 - if (!work) { 270 - work = this_cpu_ptr(&sl_reenable); 271 - /* Deferred initialization of per-CPU struct */ 272 - if (!work->work.func) 273 - INIT_DELAYED_WORK(work, __split_lock_reenable); 274 - } 275 - 246 + work = saved_sld_mitigate ? &sl_reenable_unlock : per_cpu_ptr(&sl_reenable, cpu); 276 247 schedule_delayed_work_on(cpu, work, 2); 277 248 278 249 /* Disable split lock detection on this CPU to make progress */
+3
kernel/locking/lockdep.c
··· 6264 6264 hlist_del_rcu(&class->hash_entry); 6265 6265 WRITE_ONCE(class->key, NULL); 6266 6266 WRITE_ONCE(class->name, NULL); 6267 + /* Class allocated but not used, -1 in nr_unused_locks */ 6268 + if (class->usage_mask == 0) 6269 + debug_atomic_dec(nr_unused_locks); 6267 6270 nr_lock_classes--; 6268 6271 __clear_bit(class - lock_classes, lock_classes_in_use); 6269 6272 if (class - lock_classes == max_lock_class_idx)
+18
kernel/softirq.c
··· 126 126 .lock = INIT_LOCAL_LOCK(softirq_ctrl.lock), 127 127 }; 128 128 129 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 130 + static struct lock_class_key bh_lock_key; 131 + struct lockdep_map bh_lock_map = { 132 + .name = "local_bh", 133 + .key = &bh_lock_key, 134 + .wait_type_outer = LD_WAIT_FREE, 135 + .wait_type_inner = LD_WAIT_CONFIG, /* PREEMPT_RT makes BH preemptible. */ 136 + .lock_type = LD_LOCK_PERCPU, 137 + }; 138 + EXPORT_SYMBOL_GPL(bh_lock_map); 139 + #endif 140 + 129 141 /** 130 142 * local_bh_blocked() - Check for idle whether BH processing is blocked 131 143 * ··· 159 147 int newcnt; 160 148 161 149 WARN_ON_ONCE(in_hardirq()); 150 + 151 + lock_map_acquire_read(&bh_lock_map); 162 152 163 153 /* First entry of a task into a BH disabled section? */ 164 154 if (!current->softirq_disable_cnt) { ··· 225 211 WARN_ON_ONCE(in_hardirq()); 226 212 lockdep_assert_irqs_enabled(); 227 213 214 + lock_map_release(&bh_lock_map); 215 + 228 216 local_irq_save(flags); 229 217 curcnt = __this_cpu_read(softirq_ctrl.cnt); 230 218 ··· 277 261 /* Counterpart to ksoftirqd_run_begin() */ 278 262 static inline void ksoftirqd_run_end(void) 279 263 { 264 + /* pairs with the lock_map_acquire_read() in ksoftirqd_run_begin() */ 265 + lock_map_release(&bh_lock_map); 280 266 __local_bh_enable(SOFTIRQ_OFFSET, true); 281 267 WARN_ON_ONCE(in_interrupt()); 282 268 local_irq_enable();