All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma@vger.kernel.org,
	Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Subject: Re: [PATCH 3/5] RDMA/srp: Apply the __packed attribute to members instead of structures
Date: Thu, 20 May 2021 11:48:56 -0300	[thread overview]
Message-ID: <20210520144856.GA2720258@nvidia.com> (raw)
In-Reply-To: <20210512032752.16611-4-bvanassche@acm.org>

On Tue, May 11, 2021 at 08:27:50PM -0700, Bart Van Assche wrote:
> @@ -107,10 +107,10 @@ struct srp_direct_buf {
>   * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
>   */
>  struct srp_indirect_buf {
> -	struct srp_direct_buf	table_desc;
> +	struct srp_direct_buf	table_desc __packed;
>  	__be32			len;
> -	struct srp_direct_buf	desc_list[];
> -} __attribute__((packed));
> +	struct srp_direct_buf	desc_list[] __packed;
> +};
>  
>  /* Immediate data buffer descriptor as defined in SRP2. */
>  struct srp_imm_buf {
> @@ -175,13 +175,13 @@ struct srp_login_rsp {
>  	u8	opcode;
>  	u8	reserved1[3];
>  	__be32	req_lim_delta;
> -	u64	tag;
> +	u64	tag __packed;

What you really want is just something like this:

typedef u64 __attribute__((aligned(4))) compat_u64;

And then use that every place you have the u64 and forget about packed
entirely.

Except for a couple exceptions IBA mads are always aligned to 4 bytes,
only the 64 bit quantities are unaligned.

But really this whole thing should be replaced with the IBA_FIELD
macros like include/rdma/ibta_vol1_c12.h demos.

Then it would be sparse safe and obviously endian correct as well.

I suppose you are respinning this due to the other comments?

Jason

  reply	other threads:[~2021-05-20 14:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  3:27 [PATCH 0/5] SRP kernel patches for kernel v5.14 Bart Van Assche
2021-05-12  3:27 ` [PATCH 1/5] RDMA/ib_hdrs.h: Remove a superfluous cast Bart Van Assche
2021-05-19  9:00   ` Leon Romanovsky
2021-05-24  3:12     ` Bart Van Assche
2021-05-12  3:27 ` [PATCH 2/5] RDMA/srp: Add more structure size checks Bart Van Assche
2021-05-19  9:01   ` Leon Romanovsky
2021-05-12  3:27 ` [PATCH 3/5] RDMA/srp: Apply the __packed attribute to members instead of structures Bart Van Assche
2021-05-20 14:48   ` Jason Gunthorpe [this message]
2021-05-24  3:41     ` Bart Van Assche
2021-05-24 23:00       ` Jason Gunthorpe
2021-05-12  3:27 ` [PATCH 4/5] RDMA/srp: Fix a recently introduced memory leak Bart Van Assche
2021-05-12  8:15   ` Max Gurtovoy
2021-05-12 16:14     ` Bart Van Assche
2021-05-12  3:27 ` [PATCH 5/5] RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent Bart Van Assche
2021-05-19  9:09   ` Leon Romanovsky
2021-05-19 15:13     ` Bart Van Assche
2021-05-19 15:32       ` Leon Romanovsky

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=20210520144856.GA2720258@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=nmoreychaisemartin@suse.com \
    /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.