Skip to contentSkip to conversation

xen/console: make console buffer size configurable

PATCH Superseded [email protected] 2 participants 3 messages Mar 5, 2025 – Mar 6, 2025

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/console: make console buffer size configurable

Add new CONRING_SHIFT Kconfig parameter to specify the boot console buffer size as a power of 2.

The supported range is [14..27] -> [16KiB..128MiB].

Set default to 15 (32 KiB).

---
Changes v1->v2:
- Switched to using powers of 2 in new Kconfig knob

---
 docs/misc/xen-command-line.pandoc |  5 ++++-
 xen/drivers/char/Kconfig          | 27 +++++++++++++++++++++++++++
 xen/drivers/char/console.c        |  6 +++---
 3 files changed, 34 insertions(+), 4 deletions(-)
docs/misc/xen-command-line.pandoc +4 -1
index 0c6225391d..1e12d2c6b5 100644
@@ -425,10 +425,13 @@ The following are examples of correct specifications:
 ### conring_size
 > `= <size>`
 
-> Default: `conring_size=16k`
+> Default: `conring_size=32k`
 
 Specify the size of the console ring buffer.
 
+The console ring buffer size can be selected at build time via
+CONFIG_CONRING_SHIFT.
+
 ### console
 > `= List of [ vga | com1[H,L] | com2[H,L] | pv | dbgp | ehci | xhci | none ]`
 
xen/drivers/char/Kconfig +27 -0
index e6e12bb413..d3ddb7d87a 100644
@@ -96,6 +96,33 @@ config SERIAL_TX_BUFSIZE
 
 	  Default value is 32768 (32KiB).
 
+config CONRING_SHIFT
+	int "Console buffer size (power of 2)"
+	range 14 27
+	default 15
+	help
+	  Select the boot console buffer size as a power of 2.
+	  Run-time console buffer size is the same as the boot console size,
+	  unless overridden via 'conring_size=' boot parameter.
+
+	  Default value is 15 (32KiB).
+
+	  Examples:
+	    27 => 128 MiB
+	    26 =>  64 MiB
+	    25 =>  32 MiB
+	    24 =>  16 MiB
+	    23 =>   8 MiB
+	    22 =>   4 MiB
+	    21 =>   2 MiB
+	    20 =>   1 MiB
+	    19 => 512 KiB
+	    18 => 256 KiB
+	    17 => 128 KiB
+	    16 =>  64 KiB
+	    15 =>  32 KiB
+	    14 =>  16 KiB
+
 config XHCI
 	bool "XHCI DbC UART driver"
 	depends on X86
xen/drivers/char/console.c +3 -3
index a84932e384..65468109ba 100644
@@ -101,12 +101,12 @@ static int cf_check parse_console_timestamps(const char *s);
 custom_runtime_param("console_timestamps", parse_console_timestamps,
                      con_timestamp_mode_upd);
 
-/* conring_size: allows a large console ring than default (16kB). */
+/* conring_size: override build-time CONFIG_CONRING_SHIFT setting. */
 static uint32_t __initdata opt_conring_size;
 size_param("conring_size", opt_conring_size);
 
-#define _CONRING_SIZE 16384
-#define CONRING_IDX_MASK(i) ((i)&(conring_size-1))
+#define _CONRING_SIZE       (1UL << CONFIG_CONRING_SHIFT)
+#define CONRING_IDX_MASK(i) ((i) & (conring_size - 1))
 static char __initdata _conring[_CONRING_SIZE];
 static char *__read_mostly conring = _conring;
 static uint32_t __read_mostly conring_size = _CONRING_SIZE;
Signature · 1 line
2.34.1
#1 lore raw

docs/misc/xen-command-line.pandoc The following are examples of correct specifications: · line 433

Quoted 13 lines · On 05.03.2025 02:12, [email protected] wrote:
docs/misc/xen-command-line.pandoc +3 -1
@@ -425,10 +425,13 @@ The following are examples of correct specifications:
 ### conring_size
 > `= <size>`
 
-> Default: `conring_size=16k`
+> Default: `conring_size=32k`
 
 Specify the size of the console ring buffer.
 
+The console ring buffer size can be selected at build time via
+CONFIG_CONRING_SHIFT.

And hence, if a value other than 32 is used there, the default above is going to be wrong. IOW it is only the compile time default which is 32k. The run-time default (which is what matters in Default: above) is itself configurable, and hence wants documenting that way.

xen/drivers/char/Kconfig config SERIAL_TX_BUFSIZE · line 100

Quoted 8 lines
xen/drivers/char/Kconfig +2 -0
@@ -96,6 +96,33 @@ config SERIAL_TX_BUFSIZE
 
 	  Default value is 32768 (32KiB).
 
+config CONRING_SHIFT
+	int "Console buffer size (power of 2)"

Would you mind adding the word "ring" here?

Quoted 14 lines
xen/drivers/char/Kconfig +14 -0
+	range 14 27
+	default 15
+	help
+	  Select the boot console buffer size as a power of 2.
+	  Run-time console buffer size is the same as the boot console size,
+	  unless overridden via 'conring_size=' boot parameter.
+
+	  Default value is 15 (32KiB).
+
+	  Examples:
+	    27 => 128 MiB
+	    26 =>  64 MiB
+	    25 =>  32 MiB
+	    24 =>  16 MiB

xen/drivers/char/Kconfig config SERIAL_TX_BUFSIZE · line 124

Quoted 10 lines
xen/drivers/char/Kconfig +10 -0
+	    23 =>   8 MiB
+	    22 =>   4 MiB
+	    21 =>   2 MiB
+	    20 =>   1 MiB
+	    19 => 512 KiB
+	    18 => 256 KiB
+	    17 => 128 KiB
+	    16 =>  64 KiB
+	    15 =>  32 KiB
+	    14 =>  16 KiB

I don't think an exhaustive list is necessary here. This way it's not really a set of examples, but an enumeration of all possible values.

Quoted 4 lines
xen/drivers/char/console.c +0 -0
@@ -101,12 +101,12 @@ static int cf_check parse_console_timestamps(const char *s);
 custom_runtime_param("console_timestamps", parse_console_timestamps,

xen/drivers/char/console.c static int cf_check parse_console_timestamps(const char *s); · line 108

Quoted 10 lines
xen/drivers/char/console.c +2 -3
                      con_timestamp_mode_upd);
 
-/* conring_size: allows a large console ring than default (16kB). */
+/* conring_size: override build-time CONFIG_CONRING_SHIFT setting. */
 static uint32_t __initdata opt_conring_size;
 size_param("conring_size", opt_conring_size);
 
-#define _CONRING_SIZE 16384
-#define CONRING_IDX_MASK(i) ((i)&(conring_size-1))
+#define _CONRING_SIZE       (1UL << CONFIG_CONRING_SHIFT)

Imo this ought to be 1U only, seeing ...

xen/drivers/char/console.c static int cf_check parse_console_timestamps(const char *s); · line 112

Quoted 4 lines
xen/drivers/char/console.c +1 -0
+#define CONRING_IDX_MASK(i) ((i) & (conring_size - 1))
 static char __initdata _conring[_CONRING_SIZE];
 static char *__read_mostly conring = _conring;
 static uint32_t __read_mostly conring_size = _CONRING_SIZE;

... this use of the constant.

Jan

#2 lore raw
Quoted 57 lines · Jan Beulich
Quoted 12 lines · On 05.03.2025 02:12, [email protected] wrote:
docs/misc/xen-command-line.pandoc +0 -0
@@ -425,10 +425,13 @@ The following are examples of correct specifications:
 ### conring_size
 
Quoted 1 line

= <size>

-> Default: conring_size=16k
+> Default: conring_size=32k

Specify the size of the console ring buffer.

docs/misc/xen-command-line.pandoc The following are examples of correct specifications: · line 433

Quoted 2 lines
docs/misc/xen-command-line.pandoc +2 -0
+The console ring buffer size can be selected at build time via
+CONFIG_CONRING_SHIFT.

And hence, if a value other than 32 is used there, the default above is going to be wrong. IOW it is only the compile time default which is 32k. The run-time default (which is what matters in Default: above) is itself configurable, and hence wants documenting that way.

Quoted 8 lines
xen/drivers/char/Kconfig +0 -0
@@ -96,6 +96,33 @@ config SERIAL_TX_BUFSIZE
 

Default value is 32768 (32KiB).

+config CONRING_SHIFT
+ int "Console buffer size (power of 2)"

Would you mind adding the word "ring" here?

Quoted 20 lines

+ range 14 27
+ default 15
+ help
+ Select the boot console buffer size as a power of 2.
+ Run-time console buffer size is the same as the boot console size,
+ unless overridden via 'conring_size=' boot parameter.

xen/drivers/char/Kconfig +14 -0
+
+ Default value is 15 (32KiB).
+
+ Examples:
+ 27 => 128 MiB
+ 26 => 64 MiB
+ 25 => 32 MiB
+ 24 => 16 MiB
+ 23 => 8 MiB
+ 22 => 4 MiB
+ 21 => 2 MiB
+ 20 => 1 MiB
+ 19 => 512 KiB
+ 18 => 256 KiB
Quoted 8 lines
Quoted 4 lines

+ 17 => 128 KiB
+ 16 => 64 KiB
+ 15 => 32 KiB
+ 14 => 16 KiB

I don't think an exhaustive list is necessary here. This way it's not really a set of examples, but an enumeration of all possible values.

I decided to keep the exhaustive list so it is a bit easier to do setting selection.

Quoted 28 lines
Quoted 5 lines
xen/drivers/char/console.c +0 -0
@@ -101,12 +101,12 @@ static int cf_check parse_console_timestamps(const char *s);
 custom_runtime_param("console_timestamps", parse_console_timestamps,

xen/drivers/char/console.c static int cf_check parse_console_timestamps(const char *s); · line 108

Quoted 10 lines
xen/drivers/char/console.c +2 -3
 con_timestamp_mode_upd);
 
-/* conring_size: allows a large console ring than default (16kB). /
+/ conring_size: override build-time CONFIG_CONRING_SHIFT setting. */
 static uint32_t __initdata opt_conring_size;
 size_param("conring_size", opt_conring_size);
 
-#define _CONRING_SIZE 16384
-#define CONRING_IDX_MASK(i) ((i)&(conring_size-1))
+#define _CONRING_SIZE (1UL << CONFIG_CONRING_SHIFT)

Imo this ought to be 1U only, seeing ...

xen/drivers/char/console.c static int cf_check parse_console_timestamps(const char *s); · line 112

Quoted 4 lines
xen/drivers/char/console.c +1 -0
+#define CONRING_IDX_MASK(i) ((i) & (conring_size - 1))
 static char __initdata _conring[_CONRING_SIZE];
 static char *__read_mostly conring = _conring;
 static uint32_t __read_mostly conring_size = _CONRING_SIZE;

... this use of the constant.

Jan