linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: Nilesh Javali <njavali@marvell.com>, Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	oe-kbuild-all@lists.linux.dev,  kernel test robot <lkp@intel.com>
Subject: Re: include/linux/compiler_types.h:631:38: error: call to '__compiletime_assert_431' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
Date: Wed, 4 Mar 2026 09:16:21 +1100 (AEDT)	[thread overview]
Message-ID: <a081b068-d14e-943c-54eb-3c263077c8bb@linux-m68k.org> (raw)
In-Reply-To: <81916ff0-9296-4de2-bbf9-40ef0eb4c60f@app.fastmail.com>


On Tue, 3 Mar 2026, Arnd Bergmann wrote:

> 
> As far as I can tell, the assertion is always true on all architectures 
> other than m68k because "struct rsp_que *rsp" is word-aligned and 
> "struct atio_from_isp atio" is either 64 bytes long. The intention of 
> the assertion is to ensure that nothing got added after atio, though the 
> way it is written does not take misaligned atio into account.
> 

Hardly an m68k issue. The same thing could happen on any 32-bit 
architecture under slightly different circumstances. (Nevermind 
Linux/CRIS, would would be affected in the same way as m68k is.)

No, the real problem is the assertion itself, which is a failed attempt to 
state that no struct element follows 'atio'. It isn't about alignment or 
padding and yet the assertion is written in terms of sizeof(). Go figure.

It is about the non-existance of an non-entity. That is, something with no 
name. I don't know how to express that in C. It may require the help of a 
fancy compiler.

> > I suppose the assertion could be motivated by some code elsewhere but 
> > I haven't yet found it. So perhaps the assertion can simply be 
> > removed. An alternative solution could be to increase the 1 byte hole 
> > to 3 bytes, and prevent tail padding that way.
> 
> The simplest way would be to force atio itself to be aligned regardless 
> of the architecture, either by removing the __packed attribute on the 
> struct nack_from_isp definition, or by adding alignment on the variable:
> 
> --- a/drivers/scsi/qla2xxx/qla_target.h
> +++ b/drivers/scsi/qla2xxx/qla_target.h
> @@ -844,7 +844,7 @@ struct qla_tgt_sess_op {
>         bool aborted;
>         struct rsp_que *rsp;
>  
> -       struct atio_from_isp atio;
> +       struct atio_from_isp atio __aligned(8);
>         /* DO NOT ADD ANYTHING ELSE HERE - atio must be last member */
>  };
> 

I'm fine with that, but I'd add a comment like the one I pointed to in my 
previous message, which explains some gratuitous struct padding added to 
satisfy a BUILD_BUG_ON assertion.

> In general, the use of __packed attributes in this file seems a bit 
> inconsistent, with outer structures being packed but containing aligned 
> inner structures like atio_from_isp and nack_to_isp. It may be best to 
> review all of them and remove as much as possible, but that's not 
> necessary as a bug fix here.
> 

I'm fine with that suggestion too. Thanks for your assistance, Arnd.

Nilesh, let me know if you'd prefer a patch to change the struct padding 
or packing, or something else.


      reply	other threads:[~2026-03-03 22:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 23:58 kernel test robot
2026-03-03  6:48 ` Finn Thain
2026-03-03 15:29   ` Arnd Bergmann
2026-03-03 22:16     ` Finn Thain [this message]

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=a081b068-d14e-943c-54eb-3c263077c8bb@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=njavali@marvell.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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