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

[PATCH v8 5/7] xen/console: use memcpy() in conring_puts()


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Mon, 27 Jul 2026 23:50:47 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 205.220.161.53) 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=x0I5dZqsaE9TP4bNGGGXMWIoZmxerERJuqTqO3HQvSM=; b=aOYE6jIq123x5J9b3egD5okWScHoZK4Yu9y6kUEXkWSDmAxE8HTdXZNJtKTYYvTyeeEFtfUUuswOvDAx9dhQ4jfgX9gOwxY7Th1QAWNQcGQSW3nhhkpDnrcFh/yX5fxWP4hYsSMty9xNT808CO9GscddhtSmx8nQV2iAqPV+Lu5WmzZ2rKcx4ZBVf4kFzNCZYW89oJCUaQ0fVts0O/9dzfAASDkkS4GZsayEESVJdIfKgm5e2ihXNYafaBuRO9MoFueKPvITJYP9Ll4W+Sy6B1NhJIZn4KZDbCNrascJmjhm54iv6YJZ+os27SFmyXVDMd4lLUp3GYuQ8yCqayzyzw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N41ksUiF8RlxEpeP1il+iCdg2dI1tFm5PQtZq74xPHxBkh9zBlbWwf3ldCUeJZTnw2JpSm8n28KOZ4+QAN76rrqeSCY+9qSyR6aTrvQPNzk5zv61zaGKtLvENwgbqxwWxsoLPrRdc6YnxB9pPHhxVbqrlZs4shni7ng3TA8oQxtJn+aNtJShSb9dOjFYtE91sThGzo/9z63jDpyl8PI394jRJLFpIQRqHaHhVCkglQgGmjKLU6qo8SGG5A0HW+ThCEReGjumiMvX1VNwfhSqUOhxH06apPd5+9VGDotY1VSt2T3RHOODfKduvMNfIYjF8ZZ0KmGN5+sSfF/uGIT1mA==
  • 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> 

Make conring_puts() more efficient by using memcpy()'s, rather than
copying the ring a byte at a time.

No functional change intended.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v7:
- hardended len check in conring_puts()
---
 xen/drivers/char/console.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 09282a7a4f8e..a1b8e5f5b507 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -361,12 +361,24 @@ static DECLARE_SOFTIRQ_TASKLET(conring_tasklet, 
conring_notify, NULL);
 /* NB: Do not send conring VIRQs during panic. */
 static bool conring_no_notify;
 
-static void conring_puts(const char *str, size_t len)
+static void conring_puts(const char *str, unsigned int len)
 {
+    unsigned int src = len;
+
+    /* There are no callers with strings longer than PAGE_SIZE. */
+    BUG_ON(len > PAGE_SIZE);
     ASSERT(rspin_is_locked(&console_lock));
 
-    while ( len-- )
-        conring[CONRING_IDX_MASK(conringp++)] = *str++;
+    while ( src < len )
+    {
+        unsigned int dst = CONRING_IDX_MASK(conringp + src);
+        unsigned int n = min(conring_size - dst, len - src);
+
+        memcpy(&conring[dst], &str[src], n);
+        src += n;
+    }
+
+    conringp += len;
 
     if ( conringp - conringc > conring_size )
         conringc = conringp - conring_size;
-- 
2.54.0




 


Rackspace

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