From: Thomas Gleixner <tglx@linutronix.de>
To: linke li <lilinke99@qq.com>
Cc: lilinke99@qq.com, Frederic Weisbecker <frederic@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tick: use READ_ONCE() to read jiffies in concurrent environment
Date: Thu, 07 Mar 2024 22:15:20 +0100 [thread overview]
Message-ID: <877cidu4k7.ffs@tglx> (raw)
In-Reply-To: <tencent_8B422629CF388976D1303D2C5B0720089305@qq.com>
On Sun, Feb 25 2024 at 11:12, linke li wrote:
> In function tick_sched_do_timer(), jiffies is read using READ_ONCE()
> in line 224, while read directly in line 217
>
> 217 if (ts->last_tick_jiffies != jiffies) {
> 218 ts->stalled_jiffies = 0;
> 219 ts->last_tick_jiffies = READ_ONCE(jiffies);
> 220 } else {
> 221 if (++ts->stalled_jiffies == MAX_STALLED_JIFFIES) {
> 222 tick_do_update_jiffies64(now);
> 223 ts->stalled_jiffies = 0;
> 224 ts->last_tick_jiffies = READ_ONCE(jiffies);
> 225 }
> 226 }
Please do not paste the code which is changed by the patch into the
changelog. Describe the problem you are trying to solve.
> There is patch similar to this. commit c1c0ce31b242 ("r8169: fix the
> KCSAN reported data-race in rtl_tx() while reading tp->cur_tx")
The other patch has absolutely nothing to do with this code and . Describe
the problem and the solution.
> This patch find two read of same variable while one is protected, another
> is not. And READ_ONCE() is added to protect.
This patch finds nothing. Explain it correctly why it matters that the
first read is not marked READ_ONCE(). Is this solving a correctness
problem or are you adding it just to shut up the KCSAN warning?
> @@ -214,7 +214,7 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
> * If the jiffies update stalled for too long (timekeeper in stop_machine()
> * or VMEXIT'ed for several msecs), force an update.
> */
> - if (ts->last_tick_jiffies != jiffies) {
> + if (ts->last_tick_jiffies != READ_ONCE(jiffies)) {
> ts->stalled_jiffies = 0;
> ts->last_tick_jiffies = READ_ONCE(jiffies);
> } else {
Thanks,
tglx
next prev parent reply other threads:[~2024-03-07 21:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 3:12 [PATCH] tick: use READ_ONCE() to read jiffies in concurrent environment linke li
2024-03-07 21:15 ` Thomas Gleixner [this message]
2024-03-08 8:46 ` linke li
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=877cidu4k7.ffs@tglx \
--to=tglx@linutronix.de \
--cc=frederic@kernel.org \
--cc=lilinke99@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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.