All of lore.kernel.org
 help / color / mirror / Atom feed
From: dmkhn@proton.me
To: Jan Beulich <jbeulich@suse.com>
Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech,
	julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com,
	sstabellini@kernel.org, dmukhin@ford.com,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v6] xen/console: introduce domain_console struct
Date: Fri, 11 Jul 2025 01:07:49 +0000	[thread overview]
Message-ID: <aHBj4IZdD50LWSgF@kraken> (raw)
In-Reply-To: <6e3600ad-f53c-4e9a-9713-4301b5bd0a6a@suse.com>

On Thu, Jul 10, 2025 at 01:16:24PM +0200, Jan Beulich wrote:
> On 10.07.2025 03:35, dmkhn@proton.me wrote:
> > @@ -877,6 +873,16 @@ struct domain *domain_create(domid_t domid,
> >
> >      /* All error paths can depend on the above setup. */
> >
> > +    BUILD_BUG_ON(DOMAIN_CONSOLE_BUF_SIZE <= 0);
> 
> While the "equals 0" case can in principle happen, the "less than" part
> is dead code (and hence this needs checking differently): The type of
> DOMAIN_CONSOLE_BUF_SIZE is an unsigned one, so wrapping through 0 will
> yield huge positive values.
> 
> > +    err = -ENOMEM;
> > +    d->console = xzalloc_bytes(DOMAIN_CONSOLE_SIZE);
> 
> As previously indicated, new code ought to use the xv*alloc family of
> functions, which deliberately doesn't include any ..._bytes() forms.
> Note how instead there is xvzalloc_flex_struct() for situations like
> the one here.

Looks like xvzalloc_flex_struct() is not used anywhere in the code base...

> 
> > @@ -371,6 +373,26 @@ struct evtchn_port_ops;
> >
> >  #define MAX_NR_IOREQ_SERVERS 8
> >
> > +/*
> > + * Domain console settings is the dynamically-allocated data structure.
> > + * Using an even multiple of a cache line size may help to optimize the
> > + * allocation overhead.
> > + */
> > +#define DOMAIN_CONSOLE_SIZE     ROUNDUP(256, SMP_CACHE_BYTES)
> > +#define DOMAIN_CONSOLE_BUF_SIZE (DOMAIN_CONSOLE_SIZE - \
> > +                                 sizeof(struct domain_console))
> 
> But you're aware that there's allocation overhead, which consumes part of
> a cacheline? I simply don't understand why this struct is so different
> from others that such cleverness needs building in. Yet if it's relevant,
> it really needs doing correctly.
> 
> > +/* Domain console settings. */
> > +struct domain_console {
> > +    /* Permission to take ownership of the physical console input. */
> > +    bool input_allowed;
> > +
> > +    /* hvm_print_line() and guest_console_write() logging. */
> > +    unsigned int idx;
> > +    spinlock_t lock;
> > +    char buf[0];
> 
> Iirc recent gcc warns about the use of this historic gcc extension, since
> there has been the better form using just [] for quite a long time.
> 
> Jan



  reply	other threads:[~2025-07-11  1:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10  1:35 [PATCH v6] xen/console: introduce domain_console struct dmkhn
2025-07-10 11:16 ` Jan Beulich
2025-07-11  1:07   ` dmkhn [this message]
2025-07-11  5:59     ` Jan Beulich
2025-07-11  7:25       ` dmkhn
2025-07-11 10:12         ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aHBj4IZdD50LWSgF@kraken \
    --to=dmkhn@proton.me \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.