|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v6 4/4] 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.
Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v5:
- switched to xvmalloc_array()
- fixed conring size checks
- corrected diagnostic messages
---
xen/drivers/char/console.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 5cac87d052b9..29b9359468e7 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>
@@ -343,6 +344,7 @@ static void cf_check do_dec_thresh(unsigned char key, bool
unused)
static unsigned int __initdata opt_conring_size;
size_param("conring_size", opt_conring_size);
+#define CONRING_SIZE_MIN (1U << 14)
#define _CONRING_SIZE (1U << CONFIG_CONRING_SHIFT)
#define CONRING_IDX_MASK(i) ((i) & (conring_size - 1))
static char __initdata _conring[_CONRING_SIZE];
@@ -464,20 +466,33 @@ void __init console_init_ring(void)
{
char *ring;
XENCONS_RING_IDX i, size;
- unsigned int order, memflags;
+ unsigned int order;
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 )
+ size = PAGE_SIZE << order;
+ if ( size != opt_conring_size )
{
- BUG_ON(order == 0);
- order--;
+ opt_conring_size = size;
+ printk(XENLOG_WARNING "Normalizing console ring size.\n");
}
- opt_conring_size = PAGE_SIZE << order;
+ if ( opt_conring_size < CONRING_SIZE_MIN )
+ {
+ opt_conring_size = 0;
+ printk(XENLOG_WARNING "Ignoring too-small console ring size
override.\n");
+ return;
+ }
+ else if ( opt_conring_size > GB(2) )
+ {
+ opt_conring_size = GB(2);
+ printk(XENLOG_WARNING "Limiting user-configured console ring size to 2
GiB.\n");
+ }
+
+ ring = xvmalloc_array(char, opt_conring_size);
+ BUG_ON(ring == NULL);
nrspin_lock_irqsave(&console_lock, flags);
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |