public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: virtualization@lists.linux-foundation.org
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Subject: Re: [PATCH] virtio_ring: make structure defines packed
Date: Sat, 9 Feb 2008 09:56:34 +0100	[thread overview]
Message-ID: <200802090956.35422.arnd@arndb.de> (raw)
In-Reply-To: <200802081401.21194.borntraeger@de.ibm.com>

On Friday 08 February 2008, Christian Borntraeger wrote:

> Currently the virtio_ring structure are not declared packed, but they 
> describe an hardware like interface. We should not allow compilers to make 
> alignments and optimizations that can be different between the guest and 
> host compiler.
> 
> I propose to declare all structures that are in shared memory as packed.
> 
> Does anybody see a problem with packed?

Packed structures can lead to unoptimized object code when the compiler
cannot assume natural alingment and does all accesses in single bytes.
It may even produce incorrect code if the host interface requires
larger-than-byte accesses.

I'm not aware of any version of gcc that introduces padding when all
struct members are naturally aligned as they are in the structures
you propose to change, so I'd think we're better off not having them
declared as packed.

Also, if someone does find a compelling reason to make them packed
indeed, the way to express that now should be '__packed', not 
'__attribute__((packed))'.

	Arnd <><

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  reply	other threads:[~2008-02-09  8:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08 13:01 [PATCH] virtio_ring: make structure defines packed Christian Borntraeger
2008-02-09  8:56 ` Arnd Bergmann [this message]
2008-02-10  0:51 ` Anthony Liguori
2008-02-10  2:18   ` Arnd Bergmann
2008-02-10  6:32 ` ron minnich
2008-02-11 12:55   ` Christian Borntraeger

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=200802090956.35422.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=borntraeger@de.ibm.com \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=virtualization@lists.linux-foundation.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