Skip to content

Commit 1dcb98b

Browse files
committed
sched_ext: Pass locked CPU parameter to scx_hardlockup() and add docs
With the buddy lockup detector, smp_processor_id() returns the detecting CPU, not the locked CPU, making scx_hardlockup()'s printouts confusing. Pass the locked CPU number from watchdog_hardlockup_check() as a parameter instead. Also add kerneldoc comments to handle_lockup(), scx_hardlockup(), and scx_rcu_cpu_stall() documenting their return value semantics. Suggested-by: Doug Anderson <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Acked-by: Andrea Righi <[email protected]> Reviewed-by: Emil Tsalapatis <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 67932f6 commit 1dcb98b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

include/linux/sched/ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ struct sched_ext_entity {
230230
void sched_ext_dead(struct task_struct *p);
231231
void print_scx_info(const char *log_lvl, struct task_struct *p);
232232
void scx_softlockup(u32 dur_s);
233-
bool scx_hardlockup(void);
233+
bool scx_hardlockup(int cpu);
234234
bool scx_rcu_cpu_stall(void);
235235

236236
#else /* !CONFIG_SCHED_CLASS_EXT */
237237

238238
static inline void sched_ext_dead(struct task_struct *p) {}
239239
static inline void print_scx_info(const char *log_lvl, struct task_struct *p) {}
240240
static inline void scx_softlockup(u32 dur_s) {}
241-
static inline bool scx_hardlockup(void) { return false; }
241+
static inline bool scx_hardlockup(int cpu) { return false; }
242242
static inline bool scx_rcu_cpu_stall(void) { return false; }
243243

244244
#endif /* CONFIG_SCHED_CLASS_EXT */

kernel/sched/ext.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,6 +3687,17 @@ bool scx_allow_ttwu_queue(const struct task_struct *p)
36873687
return false;
36883688
}
36893689

3690+
/**
3691+
* handle_lockup - sched_ext common lockup handler
3692+
* @fmt: format string
3693+
*
3694+
* Called on system stall or lockup condition and initiates abort of sched_ext
3695+
* if enabled, which may resolve the reported lockup.
3696+
*
3697+
* Returns %true if sched_ext is enabled and abort was initiated, which may
3698+
* resolve the lockup. %false if sched_ext is not enabled or abort was already
3699+
* initiated by someone else.
3700+
*/
36903701
static __printf(1, 2) bool handle_lockup(const char *fmt, ...)
36913702
{
36923703
struct scx_sched *sch;
@@ -3718,6 +3729,10 @@ static __printf(1, 2) bool handle_lockup(const char *fmt, ...)
37183729
* that may not be caused by the current BPF scheduler, try kicking out the
37193730
* current scheduler in an attempt to recover the system to a good state before
37203731
* issuing panics.
3732+
*
3733+
* Returns %true if sched_ext is enabled and abort was initiated, which may
3734+
* resolve the reported RCU stall. %false if sched_ext is not enabled or someone
3735+
* else already initiated abort.
37213736
*/
37223737
bool scx_rcu_cpu_stall(void)
37233738
{
@@ -3750,14 +3765,18 @@ void scx_softlockup(u32 dur_s)
37503765
* numerous affinitized tasks in a single queue and directing all CPUs at it.
37513766
* Try kicking out the current scheduler in an attempt to recover the system to
37523767
* a good state before taking more drastic actions.
3768+
*
3769+
* Returns %true if sched_ext is enabled and abort was initiated, which may
3770+
* resolve the reported hardlockdup. %false if sched_ext is not enabled or
3771+
* someone else already initiated abort.
37533772
*/
3754-
bool scx_hardlockup(void)
3773+
bool scx_hardlockup(int cpu)
37553774
{
3756-
if (!handle_lockup("hard lockup - CPU %d", smp_processor_id()))
3775+
if (!handle_lockup("hard lockup - CPU %d", cpu))
37573776
return false;
37583777

37593778
printk_deferred(KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n",
3760-
smp_processor_id());
3779+
cpu);
37613780
return true;
37623781
}
37633782

kernel/watchdog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
203203
* only once when sched_ext is enabled and will immediately
204204
* abort the BPF scheduler and print out a warning message.
205205
*/
206-
if (scx_hardlockup())
206+
if (scx_hardlockup(cpu))
207207
return;
208208

209209
/* Only print hardlockups once. */

0 commit comments

Comments
 (0)