Re: [PATCH v2 3/3] hpsa: add an assert to prevent from __packed reintroduction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Sergei Trofimovich <slyfox@xxxxxxxxxx>
- Subject: Re: [PATCH v2 3/3] hpsa: add an assert to prevent from __packed reintroduction
- From: Arnd Bergmann <arnd@xxxxxxxxxx>
- Date: Tue, 30 Mar 2021 09:34:00 +0200
- Cc: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>, John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>, Don Brace <don.brace@xxxxxxxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx, storagedev@xxxxxxxxxxxxx, linux-scsi <linux-scsi@xxxxxxxxxxxxxxx>, jszczype@xxxxxxxxxx, Scott Benesh <scott.benesh@xxxxxxxxxxxxx>, Scott Teel <scott.teel@xxxxxxxxxxxxx>, thenzl@xxxxxxxxxx, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>
- In-reply-to: <20210330071958.3788214-3-slyfox@gentoo.org>
- References: <yq1wntpgxxr.fsf@ca-mkp.ca.oracle.com> <20210330071958.3788214-1-slyfox@gentoo.org> <20210330071958.3788214-3-slyfox@gentoo.org>
On Tue, Mar 30, 2021 at 9:23 AM Sergei Trofimovich <slyfox@xxxxxxxxxx> wrote:
> +/*
> + * Make sure our embedded atomic variable is aligned. Otherwise we break atomic
> + * operations on architectures that don't support unaligned atomics like IA64.
> + *
> + * The assert guards against reintroductin against unwanted __packed to
> + * the struct CommandList.
> + */
> +static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
> +
There are a few other members that need to be aligned: the work_struct
has another
atomic_t inside it, and there are a few pointers that might rely on
being written to
atomically.
While you could add a static_assert for each member, the easier solution is to
just not ask for the members to be misaligned in the first place.
Arnd
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]