[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87blmqziek.fsf@nanos.tec.linutronix.de>
Date: Thu, 14 May 2020 16:43:31 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Joel Fernandes <joel@...lfernandes.org>
Cc: LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
"Paul E. McKenney" <paulmck@...nel.org>,
Andy Lutomirski <luto@...nel.org>,
Alexandre Chartre <alexandre.chartre@...cle.com>,
Frederic Weisbecker <frederic@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Juergen Gross <jgross@...e.com>,
Brian Gerst <brgerst@...il.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Will Deacon <will@...nel.org>
Subject: Re: [patch V4 part 3 11/29] rcu: Provide rcu_irq_exit_preempt()
Joel,
Joel Fernandes <joel@...lfernandes.org> writes:
> On Tue, May 05, 2020 at 03:44:05PM +0200, Thomas Gleixner wrote:
> Could you let me know which patch or part in the multi-part series is
> using it?
You found it :)
>> +void rcu_irq_exit_preempt(void)
>> +{
>> + lockdep_assert_irqs_disabled();
>> + rcu_nmi_exit();
>> +
>> + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) <= 0,
>> + "RCU dynticks_nesting counter underflow/zero!");
>
> Makes sense.
>
>> + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) <= 0,
>> + "RCU dynticks_nmi_nesting counter underflow/zero!");
>
> This new function will be called only from the outer-most IRQ that
> interrupted kernel mode (process context). Right? If so, a better (more
> specific) check for the second RCU_LOCKDEP_WARN above is:
>
> RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) != DYNTICK_IRQ_NONIDLE,
> "Bad RCU dynticks_nmi_nesting counter\n");
>
> That will make sure, it is only called from outer-most rcu_irq_exit() and
> interrupting kernel mode.
Makes sense.
> Or, if [1] is merged, then we could just combine the checks into one check.
> RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) != 1,
> "Bad RCU dynticks_nmi_nesting counter\n");
>
>> + RCU_LOCKDEP_WARN(rcu_dynticks_curr_cpu_in_eqs(),
>> + "RCU in extended quiescent state!");
>
> Makes sense.
>
> BTW, I wonder if a better place to do this "don't enter scheduler while RCU
> is not watching" is rcu_note_context_switch()...
I actually want to catch even the case where we don't schedule, i.e.
if (ret_to_kernel) {
if (interrupts_on_after_return((regs)) {
if (IS_ENABLED(CONFIG_PREEMPTION)) {
if (!preempt_count()) {
/* Preemption is possible ... */
rcu_irq_exit_preempt();
if (need_resched())
schedule_preempt_irq();
that catches any exit where preemption is possible and RCU is not
watching after rcu_irq_exit().
It does not matter whether need-resched is set here or not. Any
interrupt/exception could set it.
Yes, I'm paranoid :)
Thanks,
tglx
Powered by blists - more mailing lists