From: John Ogness <john.ogness@linutronix.de>
To: Andrew Halaney <ahalaney@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: pmladek@suse.com, senozhatsky@chromium.org, debarbos@redhat.com,
williams@redhat.com, jlelli@redhat.com,
linux-rt-users@vger.kernel.org
Subject: Re: [BUG] printk/nbcon can use RCU illegally prior to CPU online
Date: Fri, 19 Jul 2024 10:32:32 +0206 [thread overview]
Message-ID: <87a5idlrd3.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <436jncgrfxwcizjw5gxw3yar5ybo62zdctout6sti6gamwtnlw@gqrmo5ine6d2>
On 2024-07-18, Andrew Halaney <ahalaney@redhat.com> wrote:
> [ 5.061942] =============================
> [ 5.061942] WARNING: suspicious RCU usage
> [ 5.061942] 5.14.0-467.el9.x86_64+debug #1 Not tainted
> [ 5.061942] -----------------------------
> [ 5.061942] kernel/printk/nbcon.c:1118 suspicious rcu_dereference_check() usage!
In Petr Mladek's review of my latest printk-threading series, he pointed
out [0] that I was using the wrong RCU API in rcuwait_has_sleeper().
The patch below was his suggestion, which I was already folding into the
next version of my series.
John Ogness
[0] https://lore.kernel.org/lkml/ZmsLcu2tHmCfLiu0@pathway.suse.cz
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 0951c2c7fb1b..da462661876c 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1181,9 +1181,6 @@ static void nbcon_irq_work(struct irq_work *irq_work)
static inline bool rcuwait_has_sleeper(struct rcuwait *w)
{
- bool has_sleeper;
-
- rcu_read_lock();
/*
* Guarantee any new records can be seen by tasks preparing to wait
* before this context checks if the rcuwait is empty.
@@ -1196,10 +1193,7 @@ static inline bool rcuwait_has_sleeper(struct rcuwait *w)
* This pairs with nbcon_kthread_func:A.
*/
smp_mb(); /* LMM(rcuwait_has_sleeper:A) */
- has_sleeper = !!rcu_dereference(w->task);
- rcu_read_unlock();
-
- return has_sleeper;
+ return rcuwait_active(w);
}
/**
next prev parent reply other threads:[~2024-07-19 8:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 15:41 [BUG] printk/nbcon can use RCU illegally prior to CPU online Andrew Halaney
2024-07-18 15:57 ` Steven Rostedt
2024-07-18 18:13 ` Andrew Halaney
2024-07-18 19:24 ` Steven Rostedt
2024-07-18 19:34 ` Andrew Halaney
2024-07-18 20:17 ` Steven Rostedt
2024-07-19 7:55 ` John Ogness
2024-07-19 14:09 ` Andrew Halaney
2024-07-19 14:55 ` John Ogness
2024-07-19 15:02 ` Andrew Halaney
2024-07-19 8:26 ` John Ogness [this message]
2024-07-19 16:01 ` Andrew Halaney
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=87a5idlrd3.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=ahalaney@redhat.com \
--cc=debarbos@redhat.com \
--cc=jlelli@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=williams@redhat.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 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.