Skip to content

Commit ac9d455

Browse files
paulmckrcuNeeraj Upadhyay
authored andcommitted
locking/csd_lock: Provide an indication of ongoing CSD-lock stall
If a CSD-lock stall goes on long enough, it will cause an RCU CPU stall warning. This additional warning provides much additional console-log traffic and little additional information. Therefore, provide a new csd_lock_is_stuck() function that returns true if there is an ongoing CSD-lock stall. This function will be used by the RCU CPU stall warnings to provide a one-line indication of the stall when this function returns true. [ neeraj.upadhyay: Apply Rik van Riel feedback. ] [ neeraj.upadhyay: Apply kernel test robot feedback. ] Signed-off-by: Paul E. McKenney <[email protected]> Cc: Imran Khan <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Leonardo Bras <[email protected]> Cc: "Peter Zijlstra (Intel)" <[email protected]> Cc: Rik van Riel <[email protected]> Signed-off-by: Neeraj Upadhyay <[email protected]>
1 parent c1972c8 commit ac9d455

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

include/linux/smp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,10 @@ int smpcfd_prepare_cpu(unsigned int cpu);
294294
int smpcfd_dead_cpu(unsigned int cpu);
295295
int smpcfd_dying_cpu(unsigned int cpu);
296296

297+
#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG
298+
bool csd_lock_is_stuck(void);
299+
#else
300+
static inline bool csd_lock_is_stuck(void) { return false; }
301+
#endif
302+
297303
#endif /* __LINUX_SMP_H */

kernel/smp.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ static int csd_lock_wait_getcpu(call_single_data_t *csd)
208208
return -1;
209209
}
210210

211+
static atomic_t n_csd_lock_stuck;
212+
213+
/**
214+
* csd_lock_is_stuck - Has a CSD-lock acquisition been stuck too long?
215+
*
216+
* Returns @true if a CSD-lock acquisition is stuck and has been stuck
217+
* long enough for a "non-responsive CSD lock" message to be printed.
218+
*/
219+
bool csd_lock_is_stuck(void)
220+
{
221+
return !!atomic_read(&n_csd_lock_stuck);
222+
}
223+
211224
/*
212225
* Complain if too much time spent waiting. Note that only
213226
* the CSD_TYPE_SYNC/ASYNC types provide the destination CPU,
@@ -229,6 +242,7 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
229242
cpu = csd_lock_wait_getcpu(csd);
230243
pr_alert("csd: CSD lock (#%d) got unstuck on CPU#%02d, CPU#%02d released the lock.\n",
231244
*bug_id, raw_smp_processor_id(), cpu);
245+
atomic_dec(&n_csd_lock_stuck);
232246
return true;
233247
}
234248

@@ -252,6 +266,8 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
252266
pr_alert("csd: %s non-responsive CSD lock (#%d) on CPU#%d, waiting %lld ns for CPU#%02d %pS(%ps).\n",
253267
firsttime ? "Detected" : "Continued", *bug_id, raw_smp_processor_id(), (s64)ts_delta,
254268
cpu, csd->func, csd->info);
269+
if (firsttime)
270+
atomic_inc(&n_csd_lock_stuck);
255271
/*
256272
* If the CSD lock is still stuck after 5 minutes, it is unlikely
257273
* to become unstuck. Use a signed comparison to avoid triggering

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ config SCF_TORTURE_TEST
16141614
config CSD_LOCK_WAIT_DEBUG
16151615
bool "Debugging for csd_lock_wait(), called from smp_call_function*()"
16161616
depends on DEBUG_KERNEL
1617+
depends on SMP
16171618
depends on 64BIT
16181619
default n
16191620
help

0 commit comments

Comments
 (0)