sched/fair: Use printk_deferred instead of printk in pick_eevdf()
PATCH 1/1 sched/fair: Use printk_deferred instead of printk in pick_eevdf()
When no eligible entity is found in pick_eevdf(), it has to pick the entity with smallest vruntime. This indicates a potential issue and scheduler will print this error.
However this printk could introduce possible circular locking issue because when the code path reaches here with the rq lock held, the printk could trigger further scheduling which loops back to the scheduler.
Use printk_deferred() to defer the console write from current context to the irq work in the next tick.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -973,7 +973,7 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)if (!se) {struct sched_entity *left =__pick_first_entity (cfs_rq);if (left) { -pr_err ("EEVDF scheduling fail, picking leftmost\n" ); +printk_deferred (KERN_ERR "EEVDF scheduling fail, picking leftmost\n" );return left; } }
Signature · 1 line
2.25.1
Peter Zijlstra
maintainerQuoted 11 lines · Chen Yu
When no eligible entity is found in
pick_eevdf(), it has to pick the entity with smallest vruntime. This indicates a potential issue and scheduler will print this error.However this printk could introduce possible circular locking issue because when the code path reaches here with the rq lock held, the printk could trigger further scheduling which loops back to the scheduler.
Use
printk_deferred()to defer the console write from current context to the irq work in the next tick.
No.. I detest printk_deferred with a passion. This is effectively a WARN and we don't do silly buggers for them either.
Quoted 5 lines · On Tue, Oct 10, 2023 at 09:59:28AM +0200 Peter Zijlstra wrote:
Quoted 4 lines · Chen Yu
When no eligible entity is found in
pick_eevdf(), it has to pick the entity with smallest vruntime. This indicates a potential issue and scheduler will print this error.
Quoted 7 lines
Quoted 7 lines
However this printk could introduce possible circular locking issue because when the code path reaches here with the rq lock held, the printk could trigger further scheduling which loops back to the scheduler.
Use
printk_deferred()to defer the console write from current context to the irq work in the next tick.
Chen: I was not actually suggesting you make this change, just answering your question about printk/rq lock. You don't need to put that line in there.
Quoted 4 lines
No.. I detest
printk_deferredwith a passion. This is effectively a WARN and we don't do silly buggers for them either.
Sure, printk_deferred is not ideal, but is getting this message in the right order worth locking up people's machines? Not sure you get the message at all when that happens. I have to dig the code location out of the crash dump to find which sched warning fired and took down the (usually virtual) machine.
Cheers,
Phil
Peter Zijlstra
maintainerQuoted 9 lines · Phil Auld
Quoted 3 lines
No.. I detest
printk_deferredwith a passion. This is effectively a WARN and we don't do silly buggers for them either.Sure,
printk_deferredis not ideal, but is getting this message in the right order worth locking up people's machines? Not sure you get the message at all when that happens. I have to dig the code location out of the crash dump to find which sched warning fired and took down the (usually virtual) machine.
Same thing with WARN(), we don't have a silly bugger version of that either. Just use a sane printk() / console or whatever.
Virt stuff has perfectly functional serial consoles that works just fine and don't lock up the machine -- mostly. Use my early_printk hacks if you want something reliable:
https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=debug/experimental
Boot with: "earlyprintk=serial,ttyS0,115200 force_early_printk". And all will be well.
The fact that crashdump is more reliable than printk is a *BIG* problem and the only solution is fixing printk() (people are sorta working on that). We should not try and work around this problem.
I fundamentally despise the delayed stuff, I've had countless insteances where delaying output means you have no output because the machine is dead.
Quoted 24 lines · Peter Zijlstra
Quoted 9 lines · Phil Auld
Quoted 3 lines
No.. I detest
printk_deferredwith a passion. This is effectively a WARN and we don't do silly buggers for them either.Sure,
printk_deferredis not ideal, but is getting this message in the right order worth locking up people's machines? Not sure you get the message at all when that happens. I have to dig the code location out of the crash dump to find which sched warning fired and took down the (usually virtual) machine.Same thing with
WARN(), we don't have a silly bugger version of that either. Just use a saneprintk()/ console or whatever.Virt stuff has perfectly functional serial consoles that works just fine and don't lock up the machine -- mostly. Use my
early_printkhacks if you want something reliable:https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=debug/experimental
Boot with: "earlyprintk=serial,ttyS0,115200
force_early_printk". And all will be well.
Quoted 7 lines
The fact that crashdump is more reliable than printk is a *BIG* problem and the only solution is fixing
printk()(people are sorta working on that). We should not try and work around this problem.I fundamentally despise the delayed stuff, I've had countless insteances where delaying output means you have no output because the machine is dead.
I see, thanks for this information.
thanks,
Chenyu
Quoted 11 lines · Phil Auld
Quoted 10 lines · On Tue, Oct 10, 2023 at 09:59:28AM +0200 Peter Zijlstra wrote:
Quoted 9 lines · Chen Yu
When no eligible entity is found in
pick_eevdf(), it has to pick the entity with smallest vruntime. This indicates a potential issue and scheduler will print this error.However this printk could introduce possible circular locking issue because when the code path reaches here with the rq lock held, the printk could trigger further scheduling which loops back to the scheduler.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Use
printk_deferred()to defer the console write from current context to the irq work in the next tick.Chen: I was not actually suggesting you make this change, just answering your question about printk/rq lock. You don't need to put that line in there.
Phil,
Sorry for misunderstanding that, and thanks again for your guidance.
thanks,
Chenyu