linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E . McKenney" <paulmck@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	stable@vger.kernel.org
Subject: Re: [RFC PATCH 5/8] entry: Explicitly flush pending rcuog wakeup before last rescheduling points
Date: Mon, 11 Jan 2021 13:54:46 +0100	[thread overview]
Message-ID: <20210111125446.GE242508@lothringen> (raw)
In-Reply-To: <X/w/qBdnnQ5pFQxJ@hirez.programming.kicks-ass.net>

On Mon, Jan 11, 2021 at 01:08:08PM +0100, Peter Zijlstra wrote:
> On Sat, Jan 09, 2021 at 03:05:33AM +0100, Frederic Weisbecker wrote:
> > Following the idle loop model, cleanly check for pending rcuog wakeup
> > before the last rescheduling point on resuming to user mode. This
> > way we can avoid to do it from rcu_user_enter() with the last resort
> > self-IPI hack that enforces rescheduling.
> > 
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar<mingo@kernel.org>
> > Cc: Paul E. McKenney <paulmck@kernel.org>
> > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  kernel/entry/common.c |  6 ++++++
> >  kernel/rcu/tree.c     | 12 +++++++-----
> >  2 files changed, 13 insertions(+), 5 deletions(-)
> > 
> > diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> > index 378341642f94..8f3292b5f9b7 100644
> > --- a/kernel/entry/common.c
> > +++ b/kernel/entry/common.c
> > @@ -178,6 +178,9 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
> >  		/* Architecture specific TIF work */
> >  		arch_exit_to_user_mode_work(regs, ti_work);
> >  
> > +		/* Check if any of the above work has queued a deferred wakeup */
> > +		rcu_nocb_flush_deferred_wakeup();
> > +
> >  		/*
> >  		 * Disable interrupts and reevaluate the work flags as they
> >  		 * might have changed while interrupts and preemption was
> > @@ -197,6 +200,9 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs)
> >  
> >  	lockdep_assert_irqs_disabled();
> >  
> > +	/* Flush pending rcuog wakeup before the last need_resched() check */
> > +	rcu_nocb_flush_deferred_wakeup();
> > +
> >  	if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK))
> >  		ti_work = exit_to_user_mode_loop(regs, ti_work);
> >  
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 2920dfc9f58c..3c4c0d5cea65 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -705,12 +705,14 @@ noinstr void rcu_user_enter(void)
> >  
> >  	lockdep_assert_irqs_disabled();
> >  	/*
> > -	 * We may be past the last rescheduling opportunity in the entry code.
> > -	 * Trigger a self IPI that will fire and reschedule once we resume to
> > -	 * user/guest mode.
> > +	 * Other than generic entry implementation, we may be past the last
> > +	 * rescheduling opportunity in the entry code. Trigger a self IPI
> > +	 * that will fire and reschedule once we resume in user/guest mode.
> >  	 */
> > -	if (do_nocb_deferred_wakeup(rdp) && need_resched())
> > -		irq_work_queue(this_cpu_ptr(&late_wakeup_work));
> > +	if (!IS_ENABLED(CONFIG_GENERIC_ENTRY) || (current->flags & PF_VCPU)) {
> 
> We have xfer_to_guest_mode_work() for that PF_VCPU case.

Ah very nice! I'll integrate that on the next iteration.

Thanks.

> 
> > +		if (do_nocb_deferred_wakeup(rdp) && need_resched())
> > +			irq_work_queue(this_cpu_ptr(&late_wakeup_work));
> > +	}

  reply	other threads:[~2021-01-11 12:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09  2:05 [RFC PATCH 0/8] rcu/sched: Fix ignored rescheduling after rcu_eqs_enter() v3 Frederic Weisbecker
2021-01-09  2:05 ` [RFC PATCH 1/8] rcu: Remove superfluous rdp fetch Frederic Weisbecker
2021-01-09  9:03   ` Greg KH
2021-01-10 10:59     ` Frederic Weisbecker
2021-01-09  2:05 ` [RFC PATCH 2/8] rcu: Pull deferred rcuog wake up to rcu_eqs_enter() callers Frederic Weisbecker
2021-01-09  2:05 ` [RFC PATCH 3/8] rcu/nocb: Perform deferred wake up before last idle's need_resched() check Frederic Weisbecker
2021-01-09  2:05 ` [RFC PATCH 4/8] rcu/nocb: Trigger self-IPI on late deferred wake up before user resume Frederic Weisbecker
2021-01-11 12:04   ` Peter Zijlstra
2021-01-11 12:35     ` Frederic Weisbecker
2021-01-09  2:05 ` [RFC PATCH 5/8] entry: Explicitly flush pending rcuog wakeup before last rescheduling points Frederic Weisbecker
2021-01-11  0:40   ` Frederic Weisbecker
2021-01-11  5:13     ` Paul E. McKenney
2021-01-11 11:50       ` Frederic Weisbecker
2021-01-11 12:08   ` Peter Zijlstra
2021-01-11 12:54     ` Frederic Weisbecker [this message]
2021-01-09  2:05 ` [RFC PATCH 6/8] sched: Report local wake up on resched blind zone within idle loop Frederic Weisbecker
2021-01-11 12:25   ` Peter Zijlstra
2021-01-11 12:56     ` Frederic Weisbecker
2021-01-12  8:24   ` [sched] 9720a64438: WARNING:at_kernel/sched/core.c:#sched_resched_local_assert_allowed kernel test robot
     [not found]   ` <161062476680.19482.8402362019173198799@build.alporthouse.com>
2021-01-14 15:19     ` [RFC PATCH 6/8] sched: Report local wake up on resched blind zone within idle loop Paul E. McKenney
2021-01-09  2:05 ` [RFC PATCH 7/8] entry: Report local wake up on resched blind zone while resuming to user Frederic Weisbecker
2021-01-13  2:46   ` [entry] 8e01c5f104: unixbench.score -2.2% regression kernel test robot
2021-01-09  2:05 ` [RFC PATCH 8/8] timer: Report ignored local enqueue in nohz mode Frederic Weisbecker

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=20210111125446.GE242508@lothringen \
    --to=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).