Skip to content

Commit 8e9bf8b

Browse files
Sebastian Andrzej Siewiorhdeller
authored andcommitted
printk, vt, fbcon: Remove console_conditional_schedule()
do_con_write(), fbcon_redraw.*() invoke console_conditional_schedule() which is a conditional scheduling point based on printk's internal variables console_may_schedule. It may only be used if the console lock is acquired for instance via console_lock() or console_trylock(). Prinkt sets the internal variable to 1 (and allows to schedule) if the console lock has been acquired via console_lock(). The trylock does not allow it. The console_conditional_schedule() invocation in do_con_write() is invoked shortly before console_unlock(). The console_conditional_schedule() invocation in fbcon_redraw.*() original from fbcon_scroll() / vt's con_scroll() which originate from a line feed. In console_unlock() the variable is set to 0 (forbids to schedule) and it tries to schedule while making progress printing. This is brand new compared to when console_conditional_schedule() was added in v2.4.9.11. In v2.6.38-rc3, console_unlock() (started its existence) iterated over all consoles and flushed them with disabled interrupts. A scheduling attempt here was not possible, it relied that a long print scheduled before console_unlock(). Since commit 8d91f8b ("printk: do cond_resched() between lines while outputting to consoles"), which appeared in v4.5-rc1, console_unlock() attempts to schedule if it was allowed to schedule while during console_lock(). Each record is idealy one line so after every line feed. This console_conditional_schedule() is also only relevant on PREEMPT_NONE and PREEMPT_VOLUNTARY builds. In other configurations cond_resched() becomes a nop and has no impact. I'm bringing this all up just proof that it is not required anymore. It becomes a problem on a PREEMPT_RT build with debug code enabled because that might_sleep() in cond_resched() remains and triggers a warnings. This is due to legacy_kthread_func-> console_flush_one_record -> vt_console_print-> lf -> con_scroll -> fbcon_scroll and vt_console_print() acquires a spinlock_t which does not allow a voluntary schedule. There is no need to fb_scroll() to schedule since console_flush_one_record() attempts to schedule after each line. !PREEMPT_RT is not affected because the legacy printing thread is only enabled on PREEMPT_RT builds. Therefore I suggest to remove console_conditional_schedule(). Cc: Simona Vetter <simona@ffwll.ch> Cc: Helge Deller <deller@gmx.de> Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Fixes: 5f53ca3 ("printk: Implement legacy printer kthread for PREEMPT_RT") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Petr Mladek <pmladek@suse.com> # from printk() POV Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 4a16b38 commit 8e9bf8b

4 files changed

Lines changed: 0 additions & 24 deletions

File tree

drivers/tty/vt/vt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,6 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count)
32303230
goto rescan_last_byte;
32313231
}
32323232
con_flush(vc, &draw);
3233-
console_conditional_schedule();
32343233
notify_update(vc);
32353234

32363235
return n;

drivers/video/fbdev/core/fbcon.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,12 +1608,10 @@ static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p,
16081608
start = s;
16091609
}
16101610
}
1611-
console_conditional_schedule();
16121611
s++;
16131612
} while (s < le);
16141613
if (s > start)
16151614
fbcon_putcs(vc, start, s - start, dy, x);
1616-
console_conditional_schedule();
16171615
dy++;
16181616
}
16191617
}
@@ -1649,14 +1647,12 @@ static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
16491647
}
16501648

16511649
scr_writew(c, d);
1652-
console_conditional_schedule();
16531650
s++;
16541651
d++;
16551652
} while (s < le);
16561653
if (s > start)
16571654
par->bitops->bmove(vc, info, line + ycount, x, line, x, 1,
16581655
s - start);
1659-
console_conditional_schedule();
16601656
if (ycount > 0)
16611657
line++;
16621658
else {
@@ -1704,13 +1700,11 @@ static void fbcon_redraw(struct vc_data *vc, int line, int count, int offset)
17041700
}
17051701
}
17061702
scr_writew(c, d);
1707-
console_conditional_schedule();
17081703
s++;
17091704
d++;
17101705
} while (s < le);
17111706
if (s > start)
17121707
fbcon_putcs(vc, start, s - start, line, x);
1713-
console_conditional_schedule();
17141708
if (offset > 0)
17151709
line++;
17161710
else {

include/linux/console.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ extern int unregister_console(struct console *);
697697
extern void console_lock(void);
698698
extern int console_trylock(void);
699699
extern void console_unlock(void);
700-
extern void console_conditional_schedule(void);
701700
extern void console_unblank(void);
702701
extern void console_flush_on_panic(enum con_flush_mode mode);
703702
extern struct tty_driver *console_device(int *);

kernel/printk/printk.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,22 +3416,6 @@ void console_unlock(void)
34163416
}
34173417
EXPORT_SYMBOL(console_unlock);
34183418

3419-
/**
3420-
* console_conditional_schedule - yield the CPU if required
3421-
*
3422-
* If the console code is currently allowed to sleep, and
3423-
* if this CPU should yield the CPU to another task, do
3424-
* so here.
3425-
*
3426-
* Must be called within console_lock();.
3427-
*/
3428-
void __sched console_conditional_schedule(void)
3429-
{
3430-
if (console_may_schedule)
3431-
cond_resched();
3432-
}
3433-
EXPORT_SYMBOL(console_conditional_schedule);
3434-
34353419
void console_unblank(void)
34363420
{
34373421
bool found_unblank = false;

0 commit comments

Comments
 (0)