linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Finn Thain" <fthain@linux-m68k.org>,
	"Nilesh Javali" <njavali@marvell.com>
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: Tue, 03 Mar 2026 16:29:45 +0100	[thread overview]
Message-ID: <81916ff0-9296-4de2-bbf9-40ef0eb4c60f@app.fastmail.com> (raw)
In-Reply-To: <6bc11e2f-393d-16a2-9664-a20e2f1d3767@linux-m68k.org>

On Tue, Mar 3, 2026, at 07:48, Finn Thain wrote:
>
> --- a/pahole.out
> +++ b/pahole.out
> @@ -1,16 +1,18 @@
>  struct qla_tgt_sess_op {
>          struct scsi_qla_host *     vha;                  /*     0     
> 4 */
>          uint32_t                   chip_reset;           /*     4     
> 4 */
> -        struct work_struct         work;                 /*     8    
> 16 */
> +        struct work_struct         work 
> __attribute__((__aligned__(4))); /*     8    16 */
>          struct list_head           cmd_list;             /*    24     
> 8 */
>          bool                       aborted;              /*    32     
> 1 */
> 
>          /* XXX 1 byte hole, try to pack */
> 
>          struct rsp_que *           rsp;                  /*    34     4 */
>          struct atio_from_isp       atio;                 /*    38    64 */
> 
> -        /* size: 102, cachelines: 2, members: 7 */
> +        /* size: 104, cachelines: 2, members: 7 */
>          /* sum members: 101, holes: 1, sum holes: 1 */
> -        /* last cacheline: 38 bytes */
> -};
> +        /* padding: 2 */
> +        /* forced alignments: 1 */
> +        /* last cacheline: 40 bytes */
> +} __attribute__((__aligned__(4)));
>
>
> The BUILD_BUG_ON assertion checks the size of the struct, which doesn't 
> seem right, because any padding at the end of the struct does not 
> interfere with the subsequent kzalloc() and memcpy() in 
> qlt_queue_unknown_atio().

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.

> 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 */
 };

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.

      Arnd


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

Thread overview: 3+ 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 [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=81916ff0-9296-4de2-bbf9-40ef0eb4c60f@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=fthain@linux-m68k.org \
    --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