public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Zhouyi Zhou <zhouzhouyi@gmail.com>
Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org,
	paulmck@kernel.org, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH linux-next] mark access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE
Date: Mon, 9 Jan 2023 13:51:29 +0100	[thread overview]
Message-ID: <Y7wN0TKU1jDyTZs5@lothringen> (raw)
In-Reply-To: <20221219052128.18190-1-zhouzhouyi@gmail.com>

On Mon, Dec 19, 2022 at 01:21:28PM +0800, Zhouyi Zhou wrote:
> mark access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE to fix concurrency bug
> reported by KCSAN.
> 
> Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
> ---
> During the rcutorture test on linux-next,
> ./tools/testing/selftests/rcutorture/bin/torture.sh --do-kcsan  --kcsan-kmake-arg "CC=clang-12"
> following KCSAN BUG is reported:
> [   35.397089] BUG: KCSAN: data-race in tick_nohz_idle_stop_tick / tick_nohz_next_event^M
> [   35.400593] ^M
> [   35.401377] write to 0xffffffffb64b1270 of 4 bytes by task 0 on cpu 3:^M
> [   35.405325]  tick_nohz_idle_stop_tick+0x14c/0x3e0^M
> [   35.407162]  do_idle+0xf3/0x2a0^M
> [   35.408016]  cpu_startup_entry+0x15/0x20^M
> [   35.409084]  start_secondary+0x8f/0x90^M
> [   35.410207]  secondary_startup_64_no_verify+0xe1/0xeb^M
> [   35.411607] ^M
> [   35.412042] no locks held by swapper/3/0.^M
> [   35.413172] irq event stamp: 53048^M
> [   35.414175] hardirqs last  enabled at (53047): [<ffffffffb41f8404>] tick_nohz_idle_enter+0x104/0x140^M
> [   35.416681] hardirqs last disabled at (53048): [<ffffffffb41229f1>] do_idle+0x91/0x2a0^M
> [   35.418988] softirqs last  enabled at (53038): [<ffffffffb40bf21e>] __irq_exit_rcu+0x6e/0xc0^M
> [   35.421347] softirqs last disabled at (53029): [<ffffffffb40bf21e>] __irq_exit_rcu+0x6e/0xc0^M
> [   35.423685] ^M
> [   35.424119] read to 0xffffffffb64b1270 of 4 bytes by task 0 on cpu 0:^M
> [   35.425870]  tick_nohz_next_event+0x233/0x2b0^M
> [   35.427119]  tick_nohz_idle_stop_tick+0x8f/0x3e0^M
> [   35.428386]  do_idle+0xf3/0x2a0^M
> [   35.429265]  cpu_startup_entry+0x15/0x20^M
> [   35.430429]  rest_init+0x20c/0x210^M
> [   35.431382]  arch_call_rest_init+0xe/0x10^M
> [   35.432508]  start_kernel+0x544/0x600^M
> [   35.433519]  secondary_startup_64_no_verify+0xe1/0xeb^M
> 
> fix above bug by marking access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE

This has been discussed before with passion:

http://archive.lwn.net:8080/linux-kernel/1C65422C-FFA4-4651-893B-300FAF9C49DE@lca.pw/T/

To me data_race() would be more appropriate but that would need a changelog with
proper analysis of the tick_do_timer_cpu state machine.

One more thing on my TODO list, but feel free to beat me at it :-)

Thanks.

  parent reply	other threads:[~2023-01-09 12:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19  5:21 [PATCH linux-next] mark access to tick_do_timer_cpu with READ_ONCE/WRITE_ONCE Zhouyi Zhou
2023-01-06 14:33 ` Paul E. McKenney
2023-01-09 12:51 ` Frederic Weisbecker [this message]
2023-01-09 13:13   ` Zhouyi Zhou
2023-01-09 15:25   ` Paul E. McKenney
2023-01-09 15:59     ` Zhouyi Zhou
2023-01-23  0:44       ` Zhouyi Zhou
2023-01-23 16:54         ` Paul E. McKenney
2023-01-11  9:02   ` Thomas Gleixner

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=Y7wN0TKU1jDyTZs5@lothringen \
    --to=frederic@kernel.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=zhouzhouyi@gmail.com \
    /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