vgacon: remember scrollback buffer on console switch
Subsystems (2)
PATCH RESEND 1/1 vgacon: remember scrollback buffer on console switch
Add support for persistent console history, surviving console switches. It allocates new scrollback buffer only when user switches console for the first time.
--- drivers/video/console/Kconfig | 11 ++++++ drivers/video/console/vgacon.c | 75 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 4 deletions(-)
drivers/video/console/Kconfig +11 -0
@@ -43,6 +43,17 @@ config VGACON_SOFT_SCROLLBACK_SIZE buffer. Each 64KB will give you approximately 16 80x25 screenfuls of scrollback buffer +config VGACON_REMEMBER_SCROLLBACK + bool "Remember scrollback buffer on console switch" + depends on VGACON_SOFT_SCROLLBACK + default y + help + Say 'Y' here if you want the scrollback buffer to be remembered + on console switch and restored when you switch back. + + Note: every VGA console will use its own buffer, but it will be + allocated only when you switch to this console for the first time. + config MDA_CONSOLE depends on !M68K && !PARISC && ISA tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
drivers/video/console/vgacon.c +71 -4
108 lines not on this page · raw message
Signature · 1 line
1.5.6.4
Quoted 22 lines · On Sat, 25 Oct 2008 21:58:19 +0200 Marcin Slusarz <[email protected]>…
Add support for persistent console history, surviving console switches. It allocates new scrollback buffer only when user switches console for the first time.
Signed-off-by Marcin Slusarz <[email protected]>Cc Antonino Daplas <[email protected]>Cc Krzysztof Helt <[email protected]>Cc Andrew Morton <[email protected]>--- drivers/video/console/Kconfig | 11 ++++++ drivers/video/console/vgacon.c | 75 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 4 deletions(-)drivers/video/console/Kconfig +0
-0@@ -43,6 +43,17 @@ config VGACON_SOFT_SCROLLBACK_SIZE buffer. Each 64KB will give you approximately 16 80x25 screenfuls of scrollback buffer
drivers/video/console/Kconfig config VGACON_SOFT_SCROLLBACK_SIZE · line 55
Quoted 10 lines
drivers/video/console/Kconfig +10
-0+config VGACON_REMEMBER_SCROLLBACK + bool "Remember scrollback buffer on console switch" + depends on VGACON_SOFT_SCROLLBACK + default y + help + Say 'Y' here if you want the scrollback buffer to be remembered + on console switch and restored when you switch back. + + Note: every VGA console will use its own buffer, but it will be + allocated only when you switch to this console for the first time.
I'd question the value in adding the config option. Why not make the feature unconditionally present?
Quoted 4 lines
drivers/video/console/Kconfig +2
-0+#define SCROLLBACK_SIZE (CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024) +
drivers/video/console/Kconfig config VGACON_SOFT_SCROLLBACK_SIZE
Quoted 10 lines
drivers/video/console/Kconfig +9
-0+#ifdef CONFIG_VGACON_REMEMBER_SCROLLBACK +static struct vgacon_scrollback_info { + void *data; + int cnt; + int tail; + int cur; + int rows; + int size; +} vgacon_scrollbacks[MAX_NR_CONSOLES];
Perhaps you were concerned about memory consumption?
If so, it would be much much better to make this feature switchable at runtime (module parameter/boot option or a /proc or /sys knob).
Quoted 1 line
+static int
vgacon_last_vc_num;
We have lots of global state here with no apparent locking protecting it. Possibly there's some higher-level lock which provides seralisation? If so, the addition of a comment explaining all this would be good.
Quoted 43 lines · Andrew Morton
Quoted 22 lines · On Sat, 25 Oct 2008 21:58:19 +0200 Marcin Slusarz <[email protected]>…
Add support for persistent console history, surviving console switches. It allocates new scrollback buffer only when user switches console for the first time.
Signed-off-by Marcin Slusarz <[email protected]>Cc Antonino Daplas <[email protected]>Cc Krzysztof Helt <[email protected]>Cc Andrew Morton <[email protected]>--- drivers/video/console/Kconfig | 11 ++++++ drivers/video/console/vgacon.c | 75 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 4 deletions(-)drivers/video/console/Kconfig +0
-0@@ -43,6 +43,17 @@ config VGACON_SOFT_SCROLLBACK_SIZE buffer. Each 64KB will give you approximately 16 80x25 screenfuls of scrollback bufferdrivers/video/console/Kconfig config VGACON_SOFT_SCROLLBACK_SIZE · line 55
Quoted 10 lines
drivers/video/console/Kconfig +10
-0+config VGACON_REMEMBER_SCROLLBACK + bool "Remember scrollback buffer on console switch" + depends on VGACON_SOFT_SCROLLBACK + default y + help + Say 'Y' here if you want the scrollback buffer to be remembered + on console switch and restored when you switch back. + + Note: every VGA console will use its own buffer, but it will be + allocated only when you switch to this console for the first time.I'd question the value in adding the config option. Why not make the feature unconditionally present?
Quoted 5 lines
drivers/video/console/Kconfig +2
-0+#define SCROLLBACK_SIZE (CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024) +
Quoted 11 lines
drivers/video/console/Kconfig
Quoted 9 lines
drivers/video/console/Kconfig +9
-0+#ifdef CONFIG_VGACON_REMEMBER_SCROLLBACK +static struct vgacon_scrollback_info { + void *data; + int cnt; + int tail; + int cur; + int rows; + int size; +} vgacon_scrollbacks[MAX_NR_CONSOLES];Perhaps you were concerned about memory consumption?
Yes. I could imagine scenario where this memory would be considered "wasted".
Quoted 2 lines
If so, it would be much much better to make this feature switchable at runtime (module parameter/boot option or a /proc or /sys knob).
/sys knob seems to be the most flexible option.
/sys/class/vtconsole/vtconX/persistent_history? 0/1
Quoted 6 lines
Quoted 1 line
+static int
vgacon_last_vc_num;We have lots of global state here with no apparent locking protecting it. Possibly there's some higher-level lock which provides seralisation? If so, the addition of a comment explaining all this would be good.
I checked it and this code is called under console_sem.
vgacon_switch_scrollback <- vgacon_switch <- con_switch <- redraw_screen <- switch_screen <- complete_change_console <-
1) vt_ioctl (calls acquire_console_sem before complete_change_console)
2) change_console <- console_callback (calls acquire_console_sem before change_console)
Thanks for a review!
PS: why DECLARE_MUTEX _defines_ _semaphore_? there are only 8 uses of this macro so it's not a big problem to rename it to e.g. DEFINE_SEMAPHORE (I can provide a patch)
Marcin
Quoted 1 line · On Sun, 26 Oct 2008 00:43:01 +0200 Marcin Slusarz <[email protected]>…
PS: why
DECLARE_MUTEX_defines_ _semaphore_?
The kernel gets definition-vs-declaration confused in several places.
Quoted 3 lines
there are only 8 uses of this
macro so it's not a big problem to rename it to e.g.DEFINE_SEMAPHORE(I can provide a patch)
I'd say that s/declare/define/ at such a late stage in the semaphore's lifetime would be of dubious value. But getting "MUTEX" out of that macro's name would be a very good thing - it's a bad overlap with struct mutex. Send patch :)
Hi!
Quoted 6 lines
Quoted 2 lines
If so, it would be much much better to make this feature switchable at runtime (module parameter/boot option or a /proc or /sys knob).
/sys knob seems to be the most flexible option.
/sys/class/vtconsole/vtconX/persistent_history? 0/1
0/number-of-lines-to-remember?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html