Re: [patch V4 part 3 11/29] rcu: Provide rcu_irq_exit_preempt()

From: Joel Fernandes
Date: Fri May 15 2020 - 15:00:47 EST


On Thu, May 14, 2020 at 04:43:31PM +0200, Thomas Gleixner wrote:
[...]
> > 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, your way of doing it is better. Let us do it this way then.

Thanks!

- Joel