All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.de>
To: David Sterba <DSterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: reorder struct btrfs_key for better alignment
Date: Wed, 19 Jun 2019 09:37:39 +0800	[thread overview]
Message-ID: <6ba5daa9-735b-1cdd-fdd7-9c1a60277d46@suse.de> (raw)
In-Reply-To: <20190618141514.17322-1-dsterba@suse.com>


[-- Attachment #1.1: Type: text/plain, Size: 1612 bytes --]



On 2019/6/18 下午10:15, David Sterba wrote:
> We don't use the plain key for any on-disk operations so there's no
> requirement for the member order. As the offset is a u64 that should be
> on an 8byte aligned address, this can generate ineffective code on
> strict alignment architectures and can potentially hurt even on others
> (cross-cacheline access).
> 
> The resulting asm code on x86_64 only differes in the offset, no significant
> change in size of the object size.
> 
> The alignment of the structure is unchanged.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  include/uapi/linux/btrfs_tree.h | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
> index aff1356c2bb8..9ca7adcf3b7f 100644
> --- a/include/uapi/linux/btrfs_tree.h
> +++ b/include/uapi/linux/btrfs_tree.h
> @@ -342,10 +342,17 @@ struct btrfs_disk_key {
>  	__le64 offset;
>  } __attribute__ ((__packed__));
>  
> +/*
> + * NOTE: this structure does not match the on-disk format of key and must be
> + * converted with the right helpers. The btrfs_key is for in-memory use and the
> + * members are reordered for better alignment. It's still packed as it's never
> + * used in arrays and the extra alignment would consume stack space in
> + * functions.
> + */
>  struct btrfs_key {
>  	__u64 objectid;
> -	__u8 type;
>  	__u64 offset;
> +	__u8 type;
>  } __attribute__ ((__packed__));

And why not remove the packed attribute?

Thanks,
Qu
>  
>  struct btrfs_dev_item {
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-06-19  1:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 14:15 [PATCH] btrfs: reorder struct btrfs_key for better alignment David Sterba
2019-06-18 14:20 ` Nikolay Borisov
2019-06-19  1:37 ` Qu Wenruo [this message]
2019-06-19 13:39   ` David Sterba
2019-06-19 13:50     ` Qu Wenruo
2019-06-19 14:14       ` David Sterba

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=6ba5daa9-735b-1cdd-fdd7-9c1a60277d46@suse.de \
    --to=wqu@suse.de \
    --cc=DSterba@suse.com \
    --cc=linux-btrfs@vger.kernel.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.