[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v7 4/7] xen/console: switch conring runtime allocation to xvmalloc


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Mon, 13 Jul 2026 11:16:16 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 148.163.138.245) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Feul+agJDwY1vxKZsQEfjMl+EX8xLNQ6j7CfHECsy6w=; b=fha5eAm43vfZwv88WYNqJ1N3JAmPUWIA1V6FIQecnBZ7UgI61WG4ROi25efsnGc18n+OxWX+Frd7j9JE6mN8Ye6ZDNfuC4u0f5Ud4rRDYLXHa+BE7Y1FpTywf5Wi2ShpXyKTFRwbW9KO/y2JjbcOpoLLcvqjwrlJotfY6xqxKI6J+oJSw7mSopDyqdmrk7JtdK7xqw4IdhuI94AGqCSgIxWOtH1ijHANf28Ac30WvV0uUMbCmTz3N40bhcG5FWck6iSymCdv0G+fnzeiMVbIm3yMTz08M4gZykXmnOrGLQkg0YjyG51DrUhImWI7nSvk568KaR5L/Eag7+JkkxLN8A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gJ+TP9ZEWZ+mqf2Zen3hoQ+I+VaMbTWxeIUiJ4zd9CR2B2vAxzvkHrdFB8s1KCtBaRYrF9hEMdOPT8y2KmWb5SX7F6mM8C9Tez6TiZa3qmBXZY3XgT0VQJAucQXS/S10K/2aX/ftKPt6T26snsDBobXWVxmeQl3D4nLoC8Mm2EwNj065/ADC1dLlP1g/LIuWL4XPr1h2mq1KpXFbuLtjo5KQ460FxXCc6H1uEphqnZnE/2kWNq6k89dRegjqu2A3neBPUSQJeG5MPwY3UimACNM/YGGJZzEon5gymoB4j4jbkVPaHj6VHaLGeTdsf7kC+m/ALI9hIGqtulXgpMXONw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger.pau@xxxxxxxxxx, sstabellini@xxxxxxxxxx, dmukhin@xxxxxxxx
  • Delivery-date: Mon, 13 Jul 2026 18:16:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.