[PATCH v5 2/6] xen/console: make console buffer size configurable

dmukhin@xen.org posted 6 patches 2 days, 3 hours ago
[PATCH v5 2/6] xen/console: make console buffer size configurable
Posted by dmukhin@xen.org 2 days, 3 hours ago
From: Denis Mukhin <dmukhin@ford.com> 

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).

Resolves: https://gitlab.com/xen-project/xen/-/issues/185
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
---
Changes since v4:
- n/a
---
 docs/misc/xen-command-line.pandoc |  5 +++--
 xen/drivers/char/Kconfig          | 24 ++++++++++++++++++++++++
 xen/drivers/char/console.c        |  6 +++---
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index c1f2def9f99c..87392142e8e9 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -425,10 +425,11 @@ The following are examples of correct specifications:
 ### conring_size
 > `= <size>`
 
-> Default: `conring_size=16k`
-
 Specify the size of the console ring buffer.
 
+The default console ring buffer size is selected at build time via
+CONFIG_CONRING_SHIFT setting.
+
 ### console
 > `= List of [ vga | com1[H,L] | com2[H,L] | pv | dbgp | ehci | xhci | none ]`
 
diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index 8e49a52c735b..d083ba4c9cdf 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -95,6 +95,30 @@ config SERIAL_TX_BUFSIZE
 
 	  Default value is 32768 (32KiB).
 
+config CONRING_SHIFT
+	int "Console ring buffer size (power of 2)"
+	range 14 27
+	default 15
+	help
+	  Select the boot console ring buffer size as a power of 2.
+	  Run-time console ring buffer size is the same as the boot console ring
+	  buffer size, unless overridden via 'conring_size=' boot parameter.
+
+	    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 (default)
+	    14 =>  16 KiB
+
 config XHCI
 	bool "XHCI DbC UART driver"
 	depends on X86
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 86319600e0af..522b2f489a53 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -339,12 +339,12 @@ static void cf_check do_dec_thresh(unsigned char key, bool unused)
  * ********************************************************
  */
 
-/* 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       (1U << 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;
-- 
2.52.0
Re: [PATCH v5 2/6] xen/console: make console buffer size configurable
Posted by Jan Beulich 1 day, 20 hours ago
On 05.02.2026 02:36, dmukhin@xen.org wrote:
> --- a/xen/drivers/char/Kconfig
> +++ b/xen/drivers/char/Kconfig
> @@ -95,6 +95,30 @@ config SERIAL_TX_BUFSIZE
>  
>  	  Default value is 32768 (32KiB).
>  
> +config CONRING_SHIFT
> +	int "Console ring buffer size (power of 2)"
> +	range 14 27
> +	default 15
> +	help
> +	  Select the boot console ring buffer size as a power of 2.
> +	  Run-time console ring buffer size is the same as the boot console ring
> +	  buffer size, unless overridden via 'conring_size=' boot parameter.
> +
> +	    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 (default)
> +	    14 =>  16 KiB

As I think I had indicated before - imo an exhaustive table goes too far here.
E.g.

	    27 => 128 MiB
	    26 =>  64 MiB
	    ...
	    15 =>  32 KiB (default)
	    14 =>  16 KiB

would do (if such is needed / wanted at all).

Jan
Re: [PATCH v5 2/6] xen/console: make console buffer size configurable
Posted by dmukhin@ford.com 1 day, 3 hours ago
On Thu, Feb 05, 2026 at 09:43:31AM +0100, Jan Beulich wrote:
> On 05.02.2026 02:36, dmukhin@xen.org wrote:
> > --- a/xen/drivers/char/Kconfig
> > +++ b/xen/drivers/char/Kconfig
> > @@ -95,6 +95,30 @@ config SERIAL_TX_BUFSIZE
> >  
> >  	  Default value is 32768 (32KiB).
> >  
> > +config CONRING_SHIFT
> > +	int "Console ring buffer size (power of 2)"
> > +	range 14 27
> > +	default 15
> > +	help
> > +	  Select the boot console ring buffer size as a power of 2.
> > +	  Run-time console ring buffer size is the same as the boot console ring
> > +	  buffer size, unless overridden via 'conring_size=' boot parameter.
> > +
> > +	    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 (default)
> > +	    14 =>  16 KiB
> 
> As I think I had indicated before - imo an exhaustive table goes too far here.
> E.g.
> 
> 	    27 => 128 MiB
> 	    26 =>  64 MiB
> 	    ...
> 	    15 =>  32 KiB (default)
> 	    14 =>  16 KiB
> 
> would do (if such is needed / wanted at all).

OK, will adjust as suggested.
Thanks!

> 
> Jan