From: "Arnd Bergmann" <arnd@arndb.de>
To: "Finn Thain" <fthain@linux-m68k.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Bart Van Assche" <bvanassche@acm.org>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"kernel test robot" <lkp@intel.com>,
oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
"Linux Memory Management List" <linux-mm@kvack.org>,
"James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
scsi <linux-scsi@vger.kernel.org>,
"Nilesh Javali" <njavali@marvell.com>,
GR-QLogic-Storage-Upstream@marvell.com
Subject: Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
Date: Wed, 25 Nov 2026 08:25:22 +0100 [thread overview]
Message-ID: <9ada54e5-d80a-4d3c-a491-87e7a99f2ac8@app.fastmail.com> (raw)
In-Reply-To: <9120b892-6a31-d161-381b-809191017bdc@linux-m68k.org>
On Wed, Nov 25, 2026, at 01:18, Finn Thain wrote:
> [Cc qla2xxx maintainers]
> On Tue, 24 Nov 2026, Arnd Bergmann wrote:
>> On Tue, Nov 24, 2026, at 04:31, Finn Thain wrote:
>> > On Mon, 23 Nov 2026, Bart Van Assche wrote:
>> > Adding a flex array to struct qla_tgt_sess_op can prevent new struct
>> > members being added in the wrong spot in that struct but can't prevent
>> > new struct members being added to struct atio7_fcp_cmnd. Neither does
>> > the assertion. So the "remove" alternative doesn't have all the
>> > disadvantages that you might expect.
>>
>> This is probably just a difference in perception: atio_from_isp and
>> everything inside is clearly marked as a hardware structure that is
>> meant to align exactly to the 64 byte cacheline, so it would not make
>> any sense to change its layout and add more members here.
>
> If this driver is for x86_64 only, as you seem to be implying, then the
> right fix for this build failure would seem to be Kconfig:
>
I did not say or imply that.
>> qla_tgt_sess_op on the other hand is clearly not a hardware structure
>> but an in-kernel one so it is quite unexpected that one of its members
>> extends past the end, especially when the other three instances of
>> atio_from_isp in data structures don't seem to do that.
>>
>> >> @@ -227,7 +224,7 @@ static void qlt_queue_unknown_atio(scsi_qla_host_t *vha,
>> >> add_cdb_len =
>> >> ((unsigned int) atio->u.isp24.fcp_cmnd.add_cdb_len) * 4;
>> >>
>> >> - u = kzalloc(sizeof(*u) + add_cdb_len, GFP_ATOMIC);
>> >> + u = kzalloc_flex(*u, extra_cdb, add_cdb_len, GFP_ATOMIC);
>> >> if (u == NULL)
>> >> goto out_term;
>>
>> While this does make the current implementation more correct by having
>> the correct length, I'm worried that it just ends up establishing
>> the complexity more in the sense that extra_cdb extends both into
>> the padding and beyond qla_tgt_sess_op.
>>
>> If the driver is still actively maintained, it would be nice to
>> reduce the complexity instead, in one of two ways:
>>
>> a) make atio_from_isp naturally aligned by dropping the bogus
>> __packed attribute,
>
> I don't think I follow. "Natural" alignment would be at integer multiples
> of the struct size, right? Moreover, the correct alignment for a hardware
> struct is a question for the hardware vendor, isn't it?
I should have been clearer here, I meant having it aligned to the
highest alignment of any of its members, in this case alignof(u64),
which would avoid both the warning and the slow byte-at-a-time
access.
>> so it is actually at the end of qla_tgt_sess_op
>> as the driver was written to expect.
>
> FWIW, I think __packed on a hardware struct is at least as desirable as
> portable drivers are.
I can certainly see an argument for marking the inner structures
"__packed __aligned(8)" or similar, to ensure that the members are
tightly packed but can still be accessed worth multi-byte load/store
instructures.
The way the __packed it written on the outer struct, it only causes
problems but does not actually enforce packing of the inner struct.
Arnd
next prev parent reply other threads:[~2026-11-25 7:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 2:49 kernel test robot
2026-11-21 4:10 ` Finn Thain
2026-11-23 9:48 ` Geert Uytterhoeven
2026-11-23 23:05 ` Finn Thain
2026-11-23 23:37 ` Bart Van Assche
2026-11-24 3:31 ` Finn Thain
2026-11-24 10:18 ` Arnd Bergmann
2026-11-25 0:18 ` Finn Thain
2026-11-25 7:25 ` Arnd Bergmann [this message]
2026-11-25 8:53 ` Finn Thain
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=9ada54e5-d80a-4d3c-a491-87e7a99f2ac8@app.fastmail.com \
--to=arnd@arndb.de \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=bvanassche@acm.org \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mkp@kernel.org \
--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
all inboxes | Powered by JetHome®