From: Denis Mukhin <[email protected]> 

Introduce CONFIG_CONRING_ALIGN_PAGE_SIZE to control rounding down of the
user-defined conring buffer size.

Also, update the logline reporting the final conring buffer size to report
bytes instead of kilobytes, since the user-defined size may not necessarily
be kilobyte-alined.

Suggested-by: Andrew Cooper <[email protected]>
Signed-off-by: Denis Mukhin <[email protected]>
---
Changes since v4:
- new patch
---
 xen/drivers/char/Kconfig   |  7 +++++++
 xen/drivers/char/console.c | 15 +++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index d083ba4c9cdf..1b96fbc3ed7c 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -95,6 +95,13 @@ config SERIAL_TX_BUFSIZE
 
          Default value is 32768 (32KiB).
 
+config CONRING_ALIGN_PAGE_SIZE
+       bool
+       default y
+       help
+         This selects the console ring buffer size alignment (rounding down)
+         to a multiple of PAGE_SIZE.
+
 config CONRING_SHIFT
        int "Console ring buffer size (power of 2)"
        range 14 27
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 9394ab2a89eb..c13818715a52 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -470,12 +470,15 @@ void __init console_init_ring(void)
         return;
 
     opt_conring_size = max(opt_conring_size, conring_size);
-    size = ROUNDDOWN(opt_conring_size, PAGE_SIZE);
-    if ( size != opt_conring_size )
+    if ( IS_ENABLED(CONFIG_CONRING_ALIGN_PAGE_SIZE) )
     {
-        opt_conring_size = size;
-        printk(XENLOG_WARNING "Rounding down console ring size to multiple of 
%lu KiB.\n",
-               PAGE_SIZE >> 10);
+        size = ROUNDDOWN(opt_conring_size, PAGE_SIZE);
+        if ( size != opt_conring_size )
+        {
+            opt_conring_size = size;
+            printk(XENLOG_WARNING "Rounding down console ring size to multiple 
of %lu KiB.\n",
+                   PAGE_SIZE >> 10);
+        }
     }
     if ( opt_conring_size >= GB(2) )
     {
@@ -512,7 +515,7 @@ void __init console_init_ring(void)
 
     nrspin_unlock_irqrestore(&console_lock, flags);
 
-    printk("Allocated console ring of %u KiB.\n", opt_conring_size >> 10);
+    printk("Allocated console ring of %u bytes.\n", opt_conring_size);
 }
 
 /*
-- 
2.52.0


Reply via email to