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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E1DC04AA5 for ; Wed, 24 Aug 2022 20:21:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25B9940008; Wed, 24 Aug 2022 16:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD5EE6B0074; Wed, 24 Aug 2022 16:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9DC0940008; Wed, 24 Aug 2022 16:21:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ACD806B0073 for ; Wed, 24 Aug 2022 16:21:03 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 80A83160266 for ; Wed, 24 Aug 2022 20:21:03 +0000 (UTC) X-FDA: 79835605206.12.7E25857 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf16.hostedemail.com (Postfix) with ESMTP id 0445418001B for ; Wed, 24 Aug 2022 20:21:02 +0000 (UTC) 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 3FA80B82691; Wed, 24 Aug 2022 20:21:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 885FEC433D6; Wed, 24 Aug 2022 20:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661372460; bh=NOf72QKODirrDmUvYantOE0140y5ossinOzMvF5uJG0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1T6N4sJrTq3MjfG5g87VXI8g4c7/Dn4tjSZz4tvIQQPmNViUj6xvz39G4+GdAJmre NOrv/DLGZQCrHi/J5z//XxHBGJ7E2vVzcM+2YzUvMjdl3Lm5nVYqWpxXs279yyaL05 J5vCnaa7AJrCPG+xjqoJqua+Nfnst2txhZ6YQI+o= Date: Wed, 24 Aug 2022 13:20:58 -0700 From: Andrew Morton To: Marcelo Tosatti Cc: atomlin@redhat.com, frederic@kernel.org, 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 v7 2/3] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too Message-Id: <20220824132058.d88d3230a3cc9c07f38c9237@linux-foundation.org> In-Reply-To: <20220817191524.201253713@redhat.com> References: <20220817191346.287594886@redhat.com> <20220817191524.201253713@redhat.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661372463; a=rsa-sha256; cv=none; b=jO9pHgKTi80fcd5qac3i1qLvZsWrXOzdgRV2DT6B2r7q/QxK6M87iThe4nS4jXniuPSFhM Z0XtPBxbruk2RBoI6AmrPpPLW/VHWqKfkcN/g/uDn8F/z40gnQPdwxGsR8n6N9V5YAIgrv B8aUnb9/oQYiaB5a+PNm1XzTDBTnXEM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=1T6N4sJr; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661372463; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uO44VF5bwjrn3uu80QWy6KqHyelc327z6STQ3en11Kw=; b=24l3Be4Jn98O/wYbj3kaxqu/xBEUPuip5xRRvWee6cTmXxfyD8TtPfZG0PmqhY/8UOVkfT bal/XbFtrABicHXN6KSJG8/+N4Iw9ZFJsMx515hK17X6/EjPZF/NY5vhGIJfhsocU+0lq0 UdjT10G/1I3UEr2VLL65QTVb9NdsgFU= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0445418001B X-Stat-Signature: eri1zxsqwd668mfdcdfgpyfekh6b545g Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=1T6N4sJr; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspam-User: X-HE-Tag: 1661372462-251090 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 17 Aug 2022 16:13:48 -0300 Marcelo Tosatti wrote: > From: Aaron Tomlin > > In the context of the idle task and an adaptive-tick mode/or a nohz_full > CPU, quiet_vmstat() can be called: before stopping the idle tick, > entering an idle state and on exit. In particular, for the latter case, > when the idle task is required to reschedule, the idle tick can remain > stopped and the timer expiration time endless i.e., KTIME_MAX. Now, > indeed before a nohz_full CPU enters an idle state, CPU-specific vmstat > counters should be processed to ensure the respective values have been > reset and folded into the zone specific 'vm_stat[]'. That being said, it > can only occur when: the idle tick was previously stopped, and > reprogramming of the timer is not required. I'd like to see input from tick/sched maintainers before toughing this one, please. > --- 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(); > + 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) > { > @@ -890,6 +905,9 @@ static void tick_nohz_stop_tick(struct t > ts->do_timer_last = 0; > } > > + /* Attempt to fold when the idle tick is stopped or not */ > + quiet_vmstat(); > + > /* Skip reprogram of event if its not changed */ > if (ts->tick_stopped && (expires == ts->next_tick)) { > /* Sanity check: make sure clockevent is actually programmed */ > @@ -911,7 +929,6 @@ static void tick_nohz_stop_tick(struct t > */ > if (!ts->tick_stopped) { > calc_load_nohz_start(); > - quiet_vmstat(); > > ts->last_tick = hrtimer_get_expires(&ts->sched_timer); > ts->tick_stopped = 1; Putting vmstat stuff inside core timer code is unattractive, to say the least!