From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52625C47089 for ; Thu, 27 May 2021 15:48:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31608613BF for ; Thu, 27 May 2021 15:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233750AbhE0PuC (ORCPT ); Thu, 27 May 2021 11:50:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:35270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhE0Pt5 (ORCPT ); Thu, 27 May 2021 11:49:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 33E35613C3; Thu, 27 May 2021 15:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622130504; bh=hQW1kh/BKjJFBNVUEjSKpbQOA8E3uC65goMUf6mc/ds=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=XHwNu/5mk1lELTcz2H+ibcCE7S/waMBOLYLsETanWXDunGmovFZp9iRu94Sr1J7d9 oix2ydjwWDmWgT9kr7hYXzBmo4mWKrJ82OMMlxjgG0/yzJ8hBlQuLkuaq82b/+oftE VNE3wuyV1ceCKgy7ZjMsv2QGYOr1Zsx1HXwTWlKtygAMddafgNz3JHLeXEmhcPeZZz z8RkWHf51NXxsClTWoKBPb+SY6Fp5tzYGoV7w/w1PM8IXfKloRupMgp2Az0FulZiqe Mx8eJtTpUMTMI2gQpKqkKPA05nLCPhewpo0HUGPlx8B1B9vXjA826Cs/5Iob/lHqK2 af07Pdu7NLghQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E86925C0176; Thu, 27 May 2021 08:48:23 -0700 (PDT) Date: Thu, 27 May 2021 08:48:23 -0700 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: Peter Zijlstra , Ingo Molnar , LKML , Thomas Gleixner , kernel test robot , stable@vger.kernel.org Subject: Re: [PATCH] tick/nohz: Only check for RCU deferred wakeup on user/guest entry when needed Message-ID: <20210527154823.GC4397@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20210527113441.465489-1-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210527113441.465489-1-frederic@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 27, 2021 at 01:34:41PM +0200, Frederic Weisbecker wrote: > Checking for and processing RCU-nocb deferred wakeup upon user/guest > entry is only relevant when nohz_full runs on the local CPU, otherwise > the periodic tick should take care of it. The above initially confused me into thinking that we were dealing with non-local CPUs, and the patch itself straightened me out. How about something like this? Because the periodic tick is active during user/guest execution on non-nohz_full CPUs, only nohz_full CPUs need to check for RCU-nocb deferred wakeup on user/guest transitions. > Make sure we don't needlessly pollute these fast-paths as a -3% > performance regression on a will-it-scale.per_process_ops has been > reported so far. > > Reported-by: kernel test robot > Fixes: 47b8ff194c1f (entry: Explicitly flush pending rcuog wakeup before last rescheduling point) > Fixes: 4ae7dc97f726 (entry/kvm: Explicitly flush pending rcuog wakeup before last rescheduling point) > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: stable@vger.kernel.org > Cc: Paul E. McKenney > Cc: Thomas Gleixner > Signed-off-by: Frederic Weisbecker Reviewed-by: Paul E. McKenney > --- > include/linux/entry-kvm.h | 3 ++- > include/linux/tick.h | 7 +++++++ > kernel/entry/common.c | 5 +++-- > kernel/time/tick-sched.c | 1 + > 4 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/include/linux/entry-kvm.h b/include/linux/entry-kvm.h > index 8b2b1d68b954..136b8d97d8c0 100644 > --- a/include/linux/entry-kvm.h > +++ b/include/linux/entry-kvm.h > @@ -3,6 +3,7 @@ > #define __LINUX_ENTRYKVM_H > > #include > +#include > > /* Transfer to guest mode work */ > #ifdef CONFIG_KVM_XFER_TO_GUEST_WORK > @@ -57,7 +58,7 @@ int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu); > static inline void xfer_to_guest_mode_prepare(void) > { > lockdep_assert_irqs_disabled(); > - rcu_nocb_flush_deferred_wakeup(); > + tick_nohz_user_enter_prepare(); > } > > /** > diff --git a/include/linux/tick.h b/include/linux/tick.h > index 7340613c7eff..1a0ff88fa107 100644 > --- a/include/linux/tick.h > +++ b/include/linux/tick.h > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > > #ifdef CONFIG_GENERIC_CLOCKEVENTS > extern void __init tick_init(void); > @@ -300,4 +301,10 @@ static inline void tick_nohz_task_switch(void) > __tick_nohz_task_switch(); > } > > +static inline void tick_nohz_user_enter_prepare(void) > +{ > + if (tick_nohz_full_cpu(smp_processor_id())) > + rcu_nocb_flush_deferred_wakeup(); > +} > + > #endif > diff --git a/kernel/entry/common.c b/kernel/entry/common.c > index a0b3b04fb596..bf16395b9e13 100644 > --- a/kernel/entry/common.c > +++ b/kernel/entry/common.c > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > > #include "common.h" > > @@ -186,7 +187,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, > local_irq_disable_exit_to_user(); > > /* Check if any of the above work has queued a deferred wakeup */ > - rcu_nocb_flush_deferred_wakeup(); > + tick_nohz_user_enter_prepare(); > > ti_work = READ_ONCE(current_thread_info()->flags); > } > @@ -202,7 +203,7 @@ 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(); > + tick_nohz_user_enter_prepare(); > > if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) > ti_work = exit_to_user_mode_loop(regs, ti_work); > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index 828b091501ca..6784f27a3099 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -230,6 +230,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs) > > #ifdef CONFIG_NO_HZ_FULL > cpumask_var_t tick_nohz_full_mask; > +EXPORT_SYMBOL_GPL(tick_nohz_full_mask); > bool tick_nohz_full_running; > EXPORT_SYMBOL_GPL(tick_nohz_full_running); > static atomic_t tick_dep_mask; > -- > 2.25.1 >