lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJF2gTRH0bBO4cmoorSwPj5CqcfGp5kGj-QPxoS_AkfhjeACAA@mail.gmail.com>
Date: Tue, 16 Dec 2025 15:04:38 +0800
From: Guo Ren <guoren@...nel.org>
To: Finn Thain <fthain@...ux-m68k.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Will Deacon <will@...nel.org>, 
	Andrew Morton <akpm@...ux-foundation.org>, Arnd Bergmann <arnd@...db.de>, 
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
	Mark Rutland <mark.rutland@....com>, linux-arch@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-m68k@...ts.linux-m68k.org, 
	linux-csky@...r.kernel.org, Geert Uytterhoeven <geert@...ux-m68k.org>, 
	Dinh Nguyen <dinguyen@...nel.org>, Jonas Bonn <jonas@...thpole.se>, 
	Stefan Kristiansson <stefan.kristiansson@...nalahti.fi>, Stafford Horne <shorne@...il.com>, 
	linux-openrisc@...r.kernel.org, Yoshinori Sato <ysato@...rs.sourceforge.jp>, 
	Rich Felker <dalias@...c.org>, John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>, linux-sh@...r.kernel.org
Subject: Re: [PATCH v5 2/4] atomic: Specify alignment for atomic_t and atomic64_t

On Tue, Dec 16, 2025 at 2:38 PM Finn Thain <fthain@...ux-m68k.org> wrote:
>
> Some recent commits incorrectly assumed 4-byte alignment of locks.
> That assumption fails on Linux/m68k (and, interestingly, would have
> failed on Linux/cris also). The jump label implementation makes a
> similar alignment assumption.
>
> The expectation that atomic_t and atomic64_t variables will be naturally
> aligned seems reasonable, as indeed they are on 64-bit architectures.
> But atomic64_t isn't naturally aligned on csky, m68k, microblaze, nios2,
> openrisc and sh. Neither atomic_t nor atomic64_t are naturally aligned
> on m68k.
>
> This patch brings a little uniformity by specifying natural alignment
> for atomic types. One benefit is that atomic64_t variables do not get
> split across a page boundary. The cost is that some structs grow which
> leads to cache misses and wasted memory.
>
> Cc: Guo Ren <guoren@...nel.org>
> Cc: linux-csky@...r.kernel.org
> Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
> Cc: linux-m68k@...ts.linux-m68k.org
> Cc: Dinh Nguyen <dinguyen@...nel.org>
> Cc: Jonas Bonn <jonas@...thpole.se>
> Cc: Stefan Kristiansson <stefan.kristiansson@...nalahti.fi>
> Cc: Stafford Horne <shorne@...il.com>
> Cc: linux-openrisc@...r.kernel.org
> Cc: Yoshinori Sato <ysato@...rs.sourceforge.jp>
> Cc: Rich Felker <dalias@...c.org>
> Cc: John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>
> Cc: linux-sh@...r.kernel.org
> Link: https://lore.kernel.org/lkml/CAFr9PX=MYUDGJS2kAvPMkkfvH+0-SwQB_kxE4ea0J_wZ_pk=7w@mail.gmail.com
> Link: https://lore.kernel.org/lkml/CAMuHMdW7Ab13DdGs2acMQcix5ObJK0O2dG_Fxzr8_g58Rc1_0g@mail.gmail.com/
> Signed-off-by: Finn Thain <fthain@...ux-m68k.org>
> ---
> Changed since v2:
>  - Specify natural alignment for atomic64_t.
> Changed since v1:
>  - atomic64_t now gets an __aligned attribute too.
>  - The 'Fixes' tag has been dropped because Lance sent a different fix
>    for commit e711faaafbe5 ("hung_task: replace blocker_mutex with encoded
>    blocker") that's suitable for -stable.
> ---
>  include/asm-generic/atomic64.h | 2 +-
>  include/linux/types.h          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
> index 100d24b02e52..f22ccfc0df98 100644
> --- a/include/asm-generic/atomic64.h
> +++ b/include/asm-generic/atomic64.h
> @@ -10,7 +10,7 @@
>  #include <linux/types.h>
>
>  typedef struct {
> -       s64 counter;
> +       s64 __aligned(sizeof(s64)) counter;
This alignment is okay for all.

Acked-by: Guo Ren <guoren@...nel.org>

>  } atomic64_t;
>
>  #define ATOMIC64_INIT(i)       { (i) }
> diff --git a/include/linux/types.h b/include/linux/types.h
> index 6dfdb8e8e4c3..a225a518c2c3 100644
> --- a/include/linux/types.h
> +++ b/include/linux/types.h
> @@ -179,7 +179,7 @@ typedef phys_addr_t resource_size_t;
>  typedef unsigned long irq_hw_number_t;
>
>  typedef struct {
> -       int counter;
> +       int __aligned(sizeof(int)) counter;
>  } atomic_t;
>
>  #define ATOMIC_INIT(i) { (i) }
> --
> 2.49.1
>


-- 
Best Regards
 Guo Ren

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ