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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A125C25B04 for ; Wed, 14 Dec 2022 12:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237578AbiLNMut (ORCPT ); Wed, 14 Dec 2022 07:50:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiLNMuZ (ORCPT ); Wed, 14 Dec 2022 07:50:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B380EA for ; Wed, 14 Dec 2022 04:49:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0B7C8B818AE for ; Wed, 14 Dec 2022 12:49:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 371E5C433D2; Wed, 14 Dec 2022 12:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671022168; bh=MfURZ9LBGJIdU91BwgSvPBsaxxo8gfXFc4ZKjgaELJs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uUap6aiHDZvgbDfx3ZAuiCMW7MxWYq/v3Z7YS+Tpg6e0QdJsDwtQC0E4X+aBSUARX ZuckVeOGUZY1KbnSKt1riHxPHeUqGrvvdA7VWreYeCBPzgfiYIPHA9uDwtFHmakAfX pDN6ReDJycypdCrZgO9GlNCZ5MhJDAwMQDRW6r+3ef+yWwkQFh5HEem6Q7KE9onz1V dOjDre9So8BJTN+Op/fxGSIRrB4nbIDmMWaLS+hgcfqJuXviaayipf/jvy7nefNv0a 0YdlWYPcUCnTZwj+fh80mvY/46CqwUPKMO+BJ+hsAU5FVomY0yEqb7hoe5k6Rr9tVb UKDHoVeLCdsyQ== Date: Wed, 14 Dec 2022 13:49:25 +0100 From: Frederic Weisbecker To: Marcelo Tosatti Cc: atomlin@redhat.com, cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v9 4/5] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped Message-ID: <20221214124925.GB1925147@lothringen> References: <20221206161826.698593151@redhat.com> <20221206162416.509808578@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221206162416.509808578@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 06, 2022 at 01:18:30PM -0300, Marcelo Tosatti wrote: > From: Aaron Tomlin > > This patch ensures CPU-specific vmstat differentials do not remain > when the scheduling-tick is stopped and before exiting to user-mode > in the context of nohz_full only. > > A trivial test program was used to determine the impact of the proposed > changes and under vanilla. The mlock(2) and munlock(2) system calls was > used solely to modify vmstat item 'NR_MLOCK'. The following is an average > count of CPU-cycles across the aforementioned system calls: > > Vanilla Modified > > Cycles per syscall 8461 8690 (+2.6%) > > Signed-off-by: Aaron Tomlin This is missing your Signed-off-by: Also can you make this (and also the conditional vmstat_shepherd ignore nohz_full CPUs and also the in-place local arming) a Kconfig option perhaps? Something like CONFIG_FLUSH_WORK_ON_RESUME_USER (depend on NO_HZ_FULL). I'm using "WORK" instead of "VMSTAT" so that we can even add more stuff there later. This way I'll stop worrying about the potential HPC users who may not care about the occasional interrupt and prefer to have reasonably fast syscalls. Then after some time if nobody complains, we can remove the Kconfig entry. Thanks. > --- > include/linux/tick.h | 5 +++-- > kernel/time/tick-sched.c | 15 +++++++++++++++ > 2 files changed, 18 insertions(+), 2 deletions(-) > > Index: linux-2.6/include/linux/tick.h > =================================================================== > --- linux-2.6.orig/include/linux/tick.h > +++ linux-2.6/include/linux/tick.h > @@ -11,7 +11,6 @@ > #include > #include > #include > -#include > > #ifdef CONFIG_GENERIC_CLOCKEVENTS > extern void __init tick_init(void); > @@ -272,6 +271,7 @@ static inline void tick_dep_clear_signal > > extern void tick_nohz_full_kick_cpu(int cpu); > extern void __tick_nohz_task_switch(void); > +void __tick_nohz_user_enter_prepare(void); > extern void __init tick_nohz_full_setup(cpumask_var_t cpumask); > #else > static inline bool tick_nohz_full_enabled(void) { return false; } > @@ -296,6 +296,7 @@ static inline void tick_dep_clear_signal > > static inline void tick_nohz_full_kick_cpu(int cpu) { } > static inline void __tick_nohz_task_switch(void) { } > +static inline void __tick_nohz_user_enter_prepare(void) { } > static inline void tick_nohz_full_setup(cpumask_var_t cpumask) { } > #endif > > @@ -308,7 +309,7 @@ static inline 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(); > + __tick_nohz_user_enter_prepare(); > } > > #endif > Index: linux-2.6/kernel/time/tick-sched.c > =================================================================== > --- linux-2.6.orig/kernel/time/tick-sched.c > +++ linux-2.6/kernel/time/tick-sched.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > > @@ -519,6 +520,20 @@ void __tick_nohz_task_switch(void) > } > } > > +void __tick_nohz_user_enter_prepare(void) > +{ > + struct tick_sched *ts; > + > + if (tick_nohz_full_cpu(smp_processor_id())) { > + ts = this_cpu_ptr(&tick_cpu_sched); > + > + if (ts->tick_stopped) > + quiet_vmstat(true); > + rcu_nocb_flush_deferred_wakeup(); > + } > +} > +EXPORT_SYMBOL_GPL(__tick_nohz_user_enter_prepare); > + > /* Get the boot-time nohz CPU list from the kernel parameters. */ > void __init tick_nohz_full_setup(cpumask_var_t cpumask) > { > >