From: "Jürgen Groß" <jgross@suse.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v7 2/3] xen/events: modify struct evtchn layout
Date: Tue, 24 Nov 2020 13:18:53 +0100 [thread overview]
Message-ID: <696314b9-18e3-e18d-10f2-a510e19438da@suse.com> (raw)
In-Reply-To: <440bced0-97ec-33c4-f6fa-01850777e5c2@suse.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 2351 bytes --]
On 24.11.20 12:42, Jan Beulich wrote:
> On 24.11.2020 08:01, Juergen Gross wrote:
>> In order to avoid latent races when updating an event channel put
>> xen_consumer and pending fields in different bytes.
>
> I think there's a little more to be said here as to what the
> actual risk is, as the two fields are - afaict - at present
> fine the way they're declared.
Okay.
>
>> @@ -94,9 +93,10 @@ struct evtchn
>> #define ECS_VIRQ 5 /* Channel is bound to a virtual IRQ line. */
>> #define ECS_IPI 6 /* Channel is bound to a virtual IPI line. */
>> u8 state; /* ECS_* */
>> - u8 xen_consumer:XEN_CONSUMER_BITS; /* Consumer in Xen if nonzero */
>
> I see no reason to use a full byte for this one; in fact I
> was considering whether it, state, and old_state couldn't
> share storage (the latest when we run into space issues with
> this struct). (In this context I'm also observing that
> old_state could get away with just 2 bits, i.e. all three
> fields would fit in a single byte.)
I think doing further compression now isn't really helping. It would
just add more padding bytes and result in larger code.
>
>> - u8 pending:1;
>> - u16 notify_vcpu_id; /* VCPU for local delivery notification */
>> +#ifndef NDEBUG
>> + u8 old_state; /* State when taking lock in write mode. */
>> +#endif
>> + u8 xen_consumer; /* Consumer in Xen if nonzero */
>> u32 port;
>> union {
>> struct {
>> @@ -113,11 +113,13 @@ struct evtchn
>> } pirq; /* state == ECS_PIRQ */
>> u16 virq; /* state == ECS_VIRQ */
>> } u;
>> - u8 priority;
>> -#ifndef NDEBUG
>> - u8 old_state; /* State when taking lock in write mode. */
>> -#endif
>> - u32 fifo_lastq; /* Data for fifo events identifying last queue. */
>> +
>> + /* FIFO event channels only. */
>> + u8 pending;
>> + u8 priority;
>> + u16 notify_vcpu_id; /* VCPU for local delivery notification */
>
> This field definitely isn't FIFO-only.
Oh, you are right.
> Also for all fields you touch anyway, may I ask that you switch to
> uint<N>_t or, in the case of "pending", bool?
Fine with me.
Would you object to switching the whole structure in this regard?
Juergen
[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2020-11-24 12:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 7:01 [PATCH v7 0/3] xen/events: further locking adjustments Juergen Gross
2020-11-24 7:01 ` [PATCH v7 1/3] xen/events: access last_priority and last_vcpu_id together Juergen Gross
2020-11-24 7:01 ` [PATCH v7 2/3] xen/events: modify struct evtchn layout Juergen Gross
2020-11-24 11:42 ` Jan Beulich
2020-11-24 12:18 ` Jürgen Groß [this message]
2020-11-24 12:37 ` Jan Beulich
2020-11-24 13:19 ` Jürgen Groß
2020-11-24 7:01 ` [PATCH v7 3/3] xen/events: rework fifo queue locking Juergen Gross
2020-11-24 14:02 ` Jan Beulich
2020-11-24 14:49 ` Jürgen Groß
2020-11-24 16:32 ` Jan Beulich
2020-11-25 5:23 ` Jürgen Groß
2020-11-25 7:42 ` Jan Beulich
2020-11-25 8:08 ` Jürgen Groß
2020-11-25 8:25 ` Jan Beulich
2020-11-25 8:29 ` Jürgen Groß
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=696314b9-18e3-e18d-10f2-a510e19438da@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).