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

Re: [PATCH v7 2/7] xen/console: use memcpy() in console_init_ring()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: dmukhin@xxxxxxxx
  • Date: Fri, 17 Jul 2026 19:28:23 -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=+4CsLIU1bRbY4ZxswuwrvqQ+Xbfa6tIGA2PJMJ67l64=; b=yGDLGh8GyCJjegcYBFAKT5ILW1TZjVByKrjqpVugVQppCgl7FwozN4HuCjiqpj0JsukPrp2wLDIvtTM7JRtjL5jJ+V+AkYVR7dsE0vqS6x+tkqMUtHNup5BPycxChgJx2bbbAyobzNlfH0WicB5LkkdPmIJRWU685AcErJDfe9XfuwPkykByUfOo2qsPiv1qfiFscMXrBu5v8RZF0vdweEGxJexUKfqI9CYqEGqxQluBttrLX9PwpaS8PpFUDjGI3erHFX+EIrvCxFkXTqvtXPrfNO8ZXU0/ptY81FMO4RXOJ1cwjo8aD1ecQHaf0p+rxS1LM/XdDGXkeBjz7AEmWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FKJphdYce3/8kJ9N6+D355QG+H7s0ujfRLNPJwza6NETH5w9w60mtOyWPkygP2xbud2U4cMiI/HY4PvVNxexMbg2o8pc8yqp0/aGy8GDNkBXXb1JHeCH/nz3WgBMhpHHJgDlXneXNPz6SlAzPWumrP8epwX2BBdMatxwxjiWce8ycTbpIweaIEyePaWYgdwlyp+CRS/u/PE4saa/p3VYZNu+SUw7vCeniKciLAfRfR5RZdYnpg/IUGjcFe5ABT1Mv2jcGW32XXG4vn2/0e0YARGYPMTCt4GoMT99LvpFqtGVuQ4JY3mLa7pXG2ahGJBLBvh+7/AhGs4SfChmdD7Ffw==
  • 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=fail header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.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=ppfserpocford 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"
  • Cc: dmukhin@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger.pau@xxxxxxxxxx, sstabellini@xxxxxxxxxx
  • Delivery-date: Sat, 18 Jul 2026 02:29:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

On Fri, Jul 17, 2026 at 11:01:27PM +0100, Andrew Cooper wrote:
> On 13/07/2026 7:16 pm, dmukhin@xxxxxxxx wrote:
> > From: Denis Mukhin <dmukhin@xxxxxxxx> 
> >
> > Make console_init_ring() more efficient by using memcpy()'s, rather than
> > copying the ring a byte at a time.
> >
> > No functional change intended.
> >
> > Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> > Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
> > Acked-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
> > ---
> > Changes since v6:
> > - addressed Roger's feedback
> > - added Roger's A-b
> > ---
> >  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 5ebbbf63c092..37ea84403180 100644
> > --- a/xen/drivers/char/console.c
> > +++ b/xen/drivers/char/console.c
> > @@ -463,7 +463,8 @@ static void cf_check conring_dump_keyhandler(unsigned 
> > char key)
> >  void __init console_init_ring(void)
> >  {
> >      char *ring;
> > -    unsigned int i, order, memflags;
> > +    XENCONS_RING_IDX done, size, n;
> > +    unsigned int order, memflags;
> >      unsigned long flags;
> >  
> >      if ( !opt_conring_size )
> > @@ -479,8 +480,19 @@ void __init console_init_ring(void)
> >      opt_conring_size = PAGE_SIZE << order;
> >  
> >      nrspin_lock_irqsave(&console_lock, flags);
> > -    for ( i = conringc ; i != conringp; i++ )
> > -        ring[i & (opt_conring_size - 1)] = conring[i & (conring_size - 1)];
> > +
> > +    size = conringp - conringc;
> > +    for ( done = 0; done < size; done += n )
> > +    {
> > +        XENCONS_RING_IDX src = (conringc + done) & (conring_size - 1);
> > +        XENCONS_RING_IDX dst = (conringc + done) & (opt_conring_size - 1);
> 
> I see this has been committed, but the use of XENCONS_RING_* is wrong
> here.  This ring is not a XENCONS ring, and that header is almost
> straight obfuscation.
> 
> The types obscure what's going on, including the fact that this logic is
> unsafe with a 4G ring.  And while that might be a legitimate
> implementation restriction, it needs to be obvious in the code.
> 
> These want to move back to being unsigned int.

Will update in the next iteration of the series.



 


Rackspace

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