include/linux/objpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Arnd Bergmann <arnd@arndb.de>
Members of objpool_slot get passed into try_cmpxchg_release(),
which does not work on most architectures unless they are
naturally aligned. Marking the structure as packed makes it
only byte-aligned, as shown by this (normally disabled) warning:
include/linux/objpool.h:156:56: warning: taking address of packed member of 'struct objpool_slot' may result in an unaligned pointer value [-Waddress-of-packed-member]
156 | if (try_cmpxchg_release(&slot->head, &head, head + 1))
| ~^~~~~~~~~~~~
As the struct members are all tightly packed on all architectures,
Just remove the '__packed annotation to give it the required
alignment of the native word size.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/objpool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/objpool.h b/include/linux/objpool.h
index b713a1fe7521..f678b35b20b1 100644
--- a/include/linux/objpool.h
+++ b/include/linux/objpool.h
@@ -56,7 +56,7 @@ struct objpool_slot {
uint32_t last;
uint32_t mask;
void *entries[];
-} __packed;
+};
struct objpool_head;
--
2.39.5
Hi Arnd,
Would you like me to route this with my branch? Please let me know if
anything needed on my side.
Thanks,
Yury
On Tue, Feb 10, 2026 at 11:35:24AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Members of objpool_slot get passed into try_cmpxchg_release(),
> which does not work on most architectures unless they are
> naturally aligned. Marking the structure as packed makes it
> only byte-aligned, as shown by this (normally disabled) warning:
>
> include/linux/objpool.h:156:56: warning: taking address of packed member of 'struct objpool_slot' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 156 | if (try_cmpxchg_release(&slot->head, &head, head + 1))
> | ~^~~~~~~~~~~~
>
> As the struct members are all tightly packed on all architectures,
> Just remove the '__packed annotation to give it the required
> alignment of the native word size.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> include/linux/objpool.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/objpool.h b/include/linux/objpool.h
> index b713a1fe7521..f678b35b20b1 100644
> --- a/include/linux/objpool.h
> +++ b/include/linux/objpool.h
> @@ -56,7 +56,7 @@ struct objpool_slot {
> uint32_t last;
> uint32_t mask;
> void *entries[];
> -} __packed;
> +};
>
> struct objpool_head;
>
> --
> 2.39.5
On 2026/2/10 18:35, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Members of objpool_slot get passed into try_cmpxchg_release(),
> which does not work on most architectures unless they are
> naturally aligned. Marking the structure as packed makes it
> only byte-aligned, as shown by this (normally disabled) warning:
>
> include/linux/objpool.h:156:56: warning: taking address of packed member of 'struct objpool_slot' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 156 | if (try_cmpxchg_release(&slot->head, &head, head + 1))
> | ~^~~~~~~~~~~~
>
> As the struct members are all tightly packed on all architectures,
> Just remove the '__packed annotation to give it the required
> alignment of the native word size.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> include/linux/objpool.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/objpool.h b/include/linux/objpool.h
> index b713a1fe7521..f678b35b20b1 100644
> --- a/include/linux/objpool.h
> +++ b/include/linux/objpool.h
> @@ -56,7 +56,7 @@ struct objpool_slot {
> uint32_t last;
> uint32_t mask;
> void *entries[];
> -} __packed;
> +};
>
> struct objpool_head;
>
Reviewed-by: wuqiang.matt <wuqiang.matt@bytedance.com>
Regards,
Matt Wu
On Tue, Feb 10, 2026 at 11:35:24AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Members of objpool_slot get passed into try_cmpxchg_release(),
> which does not work on most architectures unless they are
> naturally aligned. Marking the structure as packed makes it
> only byte-aligned, as shown by this (normally disabled) warning:
>
> include/linux/objpool.h:156:56: warning: taking address of packed member of 'struct objpool_slot' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 156 | if (try_cmpxchg_release(&slot->head, &head, head + 1))
> | ~^~~~~~~~~~~~
>
> As the struct members are all tightly packed on all architectures,
> Just remove the '__packed annotation to give it the required
> alignment of the native word size.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Yury Norov <ynorov@nvidia.com>
> ---
> include/linux/objpool.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/objpool.h b/include/linux/objpool.h
> index b713a1fe7521..f678b35b20b1 100644
> --- a/include/linux/objpool.h
> +++ b/include/linux/objpool.h
> @@ -56,7 +56,7 @@ struct objpool_slot {
> uint32_t last;
> uint32_t mask;
> void *entries[];
> -} __packed;
> +};
>
> struct objpool_head;
>
> --
> 2.39.5
© 2016 - 2026 Red Hat, Inc.