From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Keir Fraser <keir@xen.org>, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 2/5] xen/common: Cleanup use of __attribute__((packed))
Date: Thu, 13 Mar 2014 10:42:25 +0000 [thread overview]
Message-ID: <53218B91.8070609@citrix.com> (raw)
In-Reply-To: <53219915020000780012399E@nat28.tlf.novell.com>
On 13/03/14 10:40, Jan Beulich wrote:
>>>> On 13.03.14 at 11:22, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> On 13/03/14 08:15, Jan Beulich wrote:
>>>>>> On 12.03.14 at 20:08, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>>>> --- a/xen/common/trace.c
>>>> +++ b/xen/common/trace.c
>>>> @@ -641,11 +641,11 @@ static inline void insert_wrap_record(struct t_buf
>>>> *buf,
>>>>
>>>> static inline void insert_lost_records(struct t_buf *buf)
>>>> {
>>>> - struct {
>>>> + struct __packed {
>>>> u32 lost_records;
>>>> u32 did:16, vid:16;
>>>> u64 first_tsc;
>>>> - } __attribute__((packed)) ed;
>>>> + } ed;
>>> So why did you not strip this one in the previous patch?
>> My reading of a recent C spec draft would indicate that the compiler is
>> perfectly at liberty to expand these :16 bitfields up 32 bits each, if
>> it feels like doing so.
> Which would then be better addressed by changing them both
> to u16, dropping the bit fields altogether.
>
> But I don't think the liberty given to a compiler is that wide: "An
> implementation may allocate any addressable storage unit large
> enough to hold a bitfield. If enough space remains, a bit-field
> that immediately follows another bit-field in a structure shall be
> packed into adjacent bits of the same unit."
>
> I.e. the compiler has basically two choices: Use a 2-byte storage
> unit for each of them, or use a 4-byte storage unit and put them
> both in there. The end result is the same. What you're concerned
> about can only happen when crossing storage unit boundaries.
>
> Jan
>
Ok - I will switch them to u16 and drop the __packed.
~Andrew
next prev parent reply other threads:[~2014-03-13 10:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 19:08 [PATCH 0/5] Improvements with __attribute__((packed)) Andrew Cooper
2014-03-12 19:08 ` [PATCH 1/5] xen: Remove redundant __attribute__((packed)) statements Andrew Cooper
2014-03-13 8:06 ` Jan Beulich
2014-03-13 10:38 ` Andrew Cooper
2014-03-13 10:49 ` George Dunlap
2014-03-12 19:08 ` [PATCH 2/5] xen/common: Cleanup use of __attribute__((packed)) Andrew Cooper
2014-03-13 8:15 ` Jan Beulich
2014-03-13 10:22 ` Andrew Cooper
2014-03-13 10:40 ` Jan Beulich
2014-03-13 10:42 ` Andrew Cooper [this message]
2014-03-12 19:08 ` [PATCH 3/5] xen/x86: " Andrew Cooper
2014-03-13 8:32 ` Jan Beulich
2014-03-13 11:00 ` Andrew Cooper
2014-03-13 11:13 ` Jan Beulich
2014-03-13 11:36 ` Keir Fraser
2014-03-12 19:08 ` [PATCH 4/5] xen/arm: " Andrew Cooper
2014-03-13 8:34 ` Jan Beulich
2014-03-13 9:55 ` Ian Campbell
2014-03-13 9:59 ` Tim Deegan
2014-03-13 10:01 ` Ian Campbell
2014-03-13 10:02 ` Jan Beulich
2014-03-12 19:08 ` [PATCH 5/5] DO NOT APPLY: for verification purposes only Andrew Cooper
2014-03-13 6:31 ` [PATCH 0/5] Improvements with __attribute__((packed)) Keir Fraser
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=53218B91.8070609@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.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).