All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Finn Thain <fthain@linux-m68k.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Lance Yang" <lance.yang@linux.dev>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Eero Tamminen" <oak@helsinkinet.fi>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Will Deacon" <will@kernel.org>,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] atomic: Specify natural alignment for atomic_t
Date: Wed, 27 Aug 2025 11:45:16 +0900	[thread overview]
Message-ID: <20250827114516.efd544acda4e3c0492d893e7@kernel.org> (raw)
In-Reply-To: <7d9554bfe2412ed9427bf71ce38a376e06eb9ec4.1756087385.git.fthain@linux-m68k.org>

On Mon, 25 Aug 2025 12:03:05 +1000
Finn Thain <fthain@linux-m68k.org> wrote:

> Some recent commits incorrectly assumed the natural alignment of locks.
> That assumption fails on Linux/m68k (and, interestingly, would have failed
> on Linux/cris also). This leads to spurious warnings from the hang check
> code. Fix this bug by adding the necessary 'aligned' attribute.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Eero Tamminen <oak@helsinkinet.fi>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Will Deacon <will@kernel.org>
> Cc: stable@vger.kernel.org
> Reported-by: Eero Tamminen <oak@helsinkinet.fi>
> Closes: https://lore.kernel.org/lkml/CAMuHMdW7Ab13DdGs2acMQcix5ObJK0O2dG_Fxzr8_g58Rc1_0g@mail.gmail.com/
> Fixes: e711faaafbe5 ("hung_task: replace blocker_mutex with encoded blocker")
> Signed-off-by: Finn Thain <fthain@linux-m68k.org>

This seems good anyway because unaligned atomic memory access
sounds insane. So looks good to me.

Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Anyway, Lance's patch[1] is still needed. We'd better gracefully
ignore if the blocker is not aligned, because hung_task blocker
detection is an optional for debugging and not necessary for
the kernel operation.

[1] https://lore.kernel.org/all/20250823050036.7748-1-lance.yang@linux.dev/ 


Thank you,

> ---
> I tested this on m68k using GCC and it fixed the problem for me. AFAIK,
> the other architectures naturally align ints already so I'm expecting to
> see no effect there.
> ---
>  include/linux/types.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/types.h b/include/linux/types.h
> index 6dfdb8e8e4c3..cd5b2b0f4b02 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 counter __aligned(sizeof(int));
>  } atomic_t;
>  
>  #define ATOMIC_INIT(i) { (i) }
> -- 
> 2.49.1
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      parent reply	other threads:[~2025-08-27  2:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25  2:03 [PATCH] atomic: Specify natural alignment for atomic_t Finn Thain
2025-08-25  2:03 ` Finn Thain
2025-08-25  3:27 ` Lance Yang
2025-08-25  3:59   ` Finn Thain
2025-08-25  4:22     ` Lance Yang
2025-08-25  4:07   ` Finn Thain
2025-08-25  5:00     ` Lance Yang
2025-08-25  6:17       ` Finn Thain
2025-08-25  7:46         ` Lance Yang
2025-08-25 10:49           ` Finn Thain
2025-08-25 11:19             ` Lance Yang
2025-08-25 11:36               ` Lance Yang
2025-08-27 23:43                 ` Finn Thain
2025-08-28  2:05                   ` Lance Yang
2025-09-01  8:45                     ` Geert Uytterhoeven
2025-09-02 13:30                       ` Lance Yang
2025-09-02 14:14                         ` Geert Uytterhoeven
2025-09-06 11:43                       ` David Laight
2025-08-25 12:07           ` David Laight
2025-08-25 12:33             ` Lance Yang
2025-08-27  8:00               ` Finn Thain
2025-08-27  9:34                 ` Lance Yang
2025-09-01  8:48             ` Geert Uytterhoeven
2025-08-25  7:12 ` Peter Zijlstra
2025-08-25  8:03   ` Finn Thain
2025-08-25 11:41     ` Peter Zijlstra
2025-08-27  7:17       ` Finn Thain
2025-08-27 11:54         ` Peter Zijlstra
2025-08-28  9:53           ` Finn Thain
2025-09-01  9:36             ` Peter Zijlstra
2025-09-01  9:40               ` Peter Zijlstra
2025-09-08  1:30                 ` Finn Thain
2025-08-26 15:22 ` Eero Tamminen
2025-08-26 17:33   ` Lance Yang
2025-09-01  8:51   ` Geert Uytterhoeven
2025-09-01 15:12     ` Eero Tamminen
2025-09-06 11:50       ` David Laight
2025-08-27  2:45 ` Masami Hiramatsu [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=20250827114516.efd544acda4e3c0492d893e7@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oak@helsinkinet.fi \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.