|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 4/7] xen/console: switch conring runtime allocation to xvmalloc
From: Denis Mukhin <dmukhin@xxxxxxxx>
The console ring only needs to be virtually contiguous; it does not need
a naturally aligned or physically contiguous allocation. Replace the
runtime xenheap allocation in console_init_ring() with an xvmalloc-backed
buffer.
Also clamp the user-configured ring size to the supported range and emit
warnings when the requested size is adjusted.
Drop full stops in all diagnostic messages in console_init_ring() to align
code with the common code pattern.
Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v6:
- simplified size checks
---
xen/drivers/char/console.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 2da5005011d5..dc779439cb69 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -33,6 +33,7 @@
#include <asm/setup.h>
#include <xen/sections.h>
#include <xen/consoled.h>
+#include <xen/xvmalloc.h>
#ifdef CONFIG_X86
#include <asm/guest.h>
@@ -474,20 +475,26 @@ void __init console_init_ring(void)
{
char *ring;
XENCONS_RING_IDX done, size, n;
- unsigned int order, memflags;
unsigned long flags;
if ( !opt_conring_size )
return;
-
- order = get_order_from_bytes(max(opt_conring_size, conring_size));
- memflags = MEMF_bits(crashinfo_maxaddr_bits);
- while ( (ring = alloc_xenheap_pages(order, memflags)) == NULL )
+ else if ( opt_conring_size > GB(2) )
{
- BUG_ON(order == 0);
- order--;
+ printk(XENLOG_WARNING "Limiting user-configured console ring size to 2
GiB\n");
+ opt_conring_size = GB(2);
}
- opt_conring_size = PAGE_SIZE << order;
+ else
+ {
+ unsigned int order = get_order_from_bytes(max(opt_conring_size,
+ conring_size));
+ opt_conring_size = PAGE_SIZE << order;
+ }
+
+ ring = xvmalloc_array(char, opt_conring_size);
+ if ( !ring )
+ panic("Unable to allocate console ring of %u KiB\n",
+ opt_conring_size >> 10);
nrspin_lock_irqsave(&console_lock, flags);
@@ -508,7 +515,7 @@ void __init console_init_ring(void)
conring_size = opt_conring_size;
nrspin_unlock_irqrestore(&console_lock, flags);
- printk("Allocated console ring of %u KiB.\n", opt_conring_size >> 10);
+ printk("Allocated console ring of %u KiB\n", opt_conring_size >> 10);
}
/*
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |