mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
- SMP-call fixes when CSD lock debugging is enabled (Chuyi Zhou)
Signed-off-by: Ingo Molnar <mingo@kernel.org> -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmpl0OURHG1pbmdvQGtl cm5lbC5vcmcACgkQEnMQ0APhK1jnng/9HrimCemEFDFpbyfbqf5ucrV8FyrbIWIX HgxpXYKpOAobz2d0DYA0dn7y+HGVJr9rU7tLxeLpH+NSsT+nm/wva+2D0X4h8Lod VKNFXI1EeQ6GJ0bmRY/DBv2GKPrYfnb1gzn/HO6KE/GITWO79Uq48K/4GTE+mbR6 l++YilPqJfujYA6IlnxdexSJNZUkNbL8lDHsxBm0xM+TyG5JP+xpdHZLpU6Tf5fd l+DcTg6KriS1T+PqAWa+2BXhMhJg2BTEZmH3mU3uvqv8EDMyTUpP4X/f0JLVU/qi 24aFDCrd5zwDey58CXnOhybzpgH7Em8/1GMN5t+6eJBtPt4Hd48h7XVgJeGZje8t yxxtruQ/c5NiKYCoHPro0uMPYu6SWaz8k/h8U2dHqtg6nswVTv89V7jSno8UGsW0 W+vJcDpO3KlfHDRXLQg2E+/WRpQzD5bUeaV9/d0x/4BzokmSDNlafMNZ/bL0RUT+ I0ij4TI16RQNSMxUMTLRC9SP4n1YyH0VMGRn9goTEns2DBdl8Y+xHH+Cnk4RedwX 9MmTLvHyuKHh5VeytWlvNbQD7+L13neec/Hlhw7/sLH7+LMUJfeMM6y4roWQvDuG /5lIT/7P/ketFzgQSGVMtaUi3ZCgfT4ZCS6X6KyaSe3F654Jt0ZpdyUQ9t1Xc42U Z+QM5jJ/4gY= =6nVN -----END PGP SIGNATURE----- Merge tag 'smp-urgent-2026-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull SMP debug fixes from Ingo Molnar: - SMP-call fixes when CSD lock debugging is enabled (Chuyi Zhou) * tag 'smp-urgent-2026-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: smp: Make CSD lock acquisition atomic for debug mode smp: Avoid invalid per-CPU CSD lookup with CSD lock debug
This commit is contained in:
commit
a6671109d6
30
kernel/smp.c
30
kernel/smp.c
|
|
@ -137,10 +137,10 @@ csd_do_func(smp_call_func_t func, void *info, call_single_data_t *csd)
|
|||
trace_csd_function_exit(func, csd);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG
|
||||
|
||||
static DEFINE_STATIC_KEY_MAYBE(CONFIG_CSD_LOCK_WAIT_DEBUG_DEFAULT, csdlock_debug_enabled);
|
||||
|
||||
#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG
|
||||
|
||||
/*
|
||||
* Parse the csdlock_debug= kernel boot parameter.
|
||||
*
|
||||
|
|
@ -342,6 +342,10 @@ static __always_inline void csd_lock_wait(call_single_data_t *csd)
|
|||
smp_cond_load_acquire(&csd->node.u_flags, !(VAL & CSD_FLAG_LOCK));
|
||||
}
|
||||
#else
|
||||
static __always_inline void __csd_lock_wait(call_single_data_t *csd)
|
||||
{
|
||||
}
|
||||
|
||||
static void csd_lock_record(call_single_data_t *csd)
|
||||
{
|
||||
}
|
||||
|
|
@ -354,8 +358,23 @@ static __always_inline void csd_lock_wait(call_single_data_t *csd)
|
|||
|
||||
static __always_inline void csd_lock(call_single_data_t *csd)
|
||||
{
|
||||
csd_lock_wait(csd);
|
||||
csd->node.u_flags |= CSD_FLAG_LOCK;
|
||||
if (IS_ENABLED(CONFIG_CSD_LOCK_WAIT_DEBUG) &&
|
||||
static_branch_unlikely(&csdlock_debug_enabled)) {
|
||||
|
||||
for (;;) {
|
||||
unsigned int flags;
|
||||
|
||||
__csd_lock_wait(csd);
|
||||
flags = READ_ONCE(csd->node.u_flags);
|
||||
|
||||
if (!(flags & CSD_FLAG_LOCK) &&
|
||||
try_cmpxchg_acquire(&csd->node.u_flags, &flags, flags | CSD_FLAG_LOCK))
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
csd_lock_wait(csd);
|
||||
csd->node.u_flags |= CSD_FLAG_LOCK;
|
||||
}
|
||||
|
||||
/*
|
||||
* prevent CPU from reordering the above assignment
|
||||
|
|
@ -380,7 +399,8 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data);
|
|||
#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG
|
||||
static call_single_data_t *get_single_csd_data(int cpu)
|
||||
{
|
||||
if (static_branch_unlikely(&csdlock_debug_enabled))
|
||||
if (static_branch_unlikely(&csdlock_debug_enabled) &&
|
||||
(unsigned int)cpu < nr_cpu_ids)
|
||||
return per_cpu_ptr(&csd_data, cpu);
|
||||
return this_cpu_ptr(&csd_data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user