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

[PATCH v8 3/7] xen/console: switch conring runtime allocation to xvmalloc


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Mon, 27 Jul 2026 23:50:45 -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=A1Qxlu6N89ffhdYOUJ7rbtARn2NIA7nR+C8pqWl/79w=; b=ZHTzL2KM26NB6UPgAMBZD51jK8qISnVfTeTFti4RD+UrTEqvg2pCMmo+LLMtkG0VcSUoJlCDv38MkcXmswg9PgJmK8QdLSeWS0HRemE+1uMSgWpoLLXotRF/ajSglEyt59OJC3eL90uwKq6+zNJh7qUPnQis4yAQ9Unj+9xY7uyqf7c8+kqNHlU+YEgv2/ht2dxAQ6J8OX8GMNGpaLgDJNk7wHH4UnZbla/WkEutJvzQoaZbj0tkKA471SWl8JXWsw6oa/M5R2tEa+clWJGM+GpdXJXphT2HzgpmzNaDUu6t2wr5COOvsFQMYjLCtwQ7zuUy2vhcvcXDwZGbgganyQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AR6qkJXcGfRhvstwtxsE+7yDyQt/F1JBHTC6aS+1AYTOb0Kn6Fcperf2T2qh1OWZzp6o7hqTMDEoGOXhN6ZX+vyhvQV6jI3K1LL9q/07OLfKTRvUHxnrPCOWs/QmFoXKNdRpNWD2O7xmgcnE+qJT8a1QHRcW9a1NqU4Erm/cuRiEdmco9pp/XxXROouJJzsOUljfh0oswyAA9H+46XwbD1Q/pZqn+V6UHcVkwvXqy5KRCv84dY6Q4qR/DBChrkdT879deUSXkVgx4BYw5uYtRwl8t5LtRajTbCFt1QL67ANSwiAClhQUw6i6qRVjYrtXzfNCXiK7Gg/gnD8elzIYJA==
  • 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: Tue, 28 Jul 2026 06:51:38 +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
warning 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 v7:
- Jan's feedback from
  
https://lore.kernel.org/xen-devel/0fefa50c-46aa-4ede-a8e2-8c2c619bc2ab@xxxxxxxx/
---
 xen/drivers/char/console.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 40355c1d14d6..09282a7a4f8e 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>
@@ -464,20 +465,30 @@ void __init console_init_ring(void)
 {
     char *ring;
     unsigned int 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 )
+    if ( opt_conring_size < GB(2) )
     {
-        BUG_ON(order == 0);
-        order--;
+        unsigned int order = get_order_from_bytes(max(opt_conring_size,
+                                                      conring_size));
+
+        opt_conring_size = PAGE_SIZE << order;
+    }
+    else
+    {
+        printk(XENLOG_WARNING
+               "Limiting user-configured console ring size to 2 GiB\n");
+        opt_conring_size = GB(2);
+    }
+
+    while ( (ring = xvmalloc_array(char, opt_conring_size)) == NULL )
+    {
+        BUG_ON(opt_conring_size == 0);
+        opt_conring_size >>= 1;
     }
-    opt_conring_size = PAGE_SIZE << order;
 
     nrspin_lock_irqsave(&console_lock, flags);
 
@@ -498,7 +509,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®.