From: "Paul E. McKenney" <paulmck@kernel.org>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>,
"frederic@kernel.org" <frederic@kernel.org>,
"quic_neeraju@quicinc.com" <quic_neeraju@quicinc.com>,
"rcu@vger.kernel.org" <rcu@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rcu: Fix opposite might_sleep() check in rcu_blocking_is_gp()
Date: Sun, 18 Dec 2022 15:30:56 -0800 [thread overview]
Message-ID: <20221218233056.GU4001@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <CAEXW_YQvbcvxh7u7sU-VjdAYUWpxDzdH-68qk_AjY54hMjNYMg@mail.gmail.com>
On Sun, Dec 18, 2022 at 04:02:35PM -0500, Joel Fernandes wrote:
> On Sun, Dec 18, 2022 at 2:44 PM Paul E. McKenney <paulmck@kernel.org> wrote:
> [...]
> > > > > If not, I would do something like this:
> > > > >
> > > > > ---8<-----------------------
> > > > >
> > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > > > > index 79aea7df4345..23c2303de9f4 100644
> > > > > --- a/kernel/rcu/tree.c
> > > > > +++ b/kernel/rcu/tree.c
> > > > > @@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void)
> > > > > {
> > > > > int ret;
> > > > >
> > > > > + might_sleep(); /* Check for RCU read-side critical section. */
> > > > > +
> > > > > // Invoking preempt_model_*() too early gets a splat.
> > > > > if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE ||
> > > > > preempt_model_full() || preempt_model_rt())
> > > > > return rcu_scheduler_active == RCU_SCHEDULER_INACTIVE;
> >
> > If the scheduler is inactive (early boot with interrupts disabled),
> > we return here.
> >
> > > > > - might_sleep(); /* Check for RCU read-side critical section. */
> >
> > We get here only if the scheduler has started, and even then only in
> > preemption-disabled kernels.
> >
> > Or is you concern that the might_sleep() never gets invoked in kernels
> > with preemption enabled? Fixing that would require a slightly different
> > patch, though.
> >
> > Or should I have waited until tomorrow to respond to this email? ;-)
>
> No, I think you are quite right. I was not referring to
> rcu_sleep_check(), but rather the following prints in might_sleep(). I
> see an unconditional call to might_sleep() from kvfree_call_rcu() but
> not one from synchronize_rcu() which can also sleep.
>
> But I see your point, early boot code has interrupts disabled, but can
> still totally call synchronize_rcu() when the scheduler is INACTIVE.
> And might_sleep() might bitterly complain. Thanks for the
> clarification.
>
> pr_err("BUG: sleeping function called from invalid context at %s:%d\n",
> file, line);
> pr_err("in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d,
> name: %s\n",
> in_atomic(), irqs_disabled(), current->non_block_count,
> current->pid, current->comm);
> pr_err("preempt_count: %x, expected: %x\n", preempt_count(),
> offsets & MIGHT_RESCHED_PREEMPT_MASK);
And I do not believe that we have defined whether or not it is OK to
invoke single-argument kvfree_rcu() before the scheduler has started. ;-)
Thanx, Paul
prev parent reply other threads:[~2022-12-18 23:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 3:57 Zqiang
2022-12-17 1:03 ` Paul E. McKenney
2022-12-17 2:08 ` Zhang, Qiang1
2022-12-17 2:44 ` Zhang, Qiang1
2022-12-17 5:17 ` Paul E. McKenney
2022-12-18 2:01 ` Joel Fernandes
2022-12-18 18:06 ` Paul E. McKenney
2022-12-18 19:29 ` Joel Fernandes
2022-12-18 19:44 ` Paul E. McKenney
2022-12-18 21:02 ` Joel Fernandes
2022-12-18 23:30 ` Paul E. McKenney [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=20221218233056.GU4001@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--cc=frederic@kernel.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qiang1.zhang@intel.com \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®