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=-19.0 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,USER_AGENT_GIT autolearn=ham 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 1C9A9C43460 for ; Thu, 22 Apr 2021 12:02:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE3566145E for ; Thu, 22 Apr 2021 12:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236191AbhDVMCv (ORCPT ); Thu, 22 Apr 2021 08:02:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:56440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236165AbhDVMCt (ORCPT ); Thu, 22 Apr 2021 08:02:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F7216145B; Thu, 22 Apr 2021 12:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619092934; bh=+z6iEVB6WBColAXK43QQx8UoNC1wJ0ztdOjphulwwgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u445njB3fPAqnGN5yfEIbFR66CcrnXY+iNd/3dAnMVmQTMxXOHNZMEWhSeX2Pd8Y5 YZ5DGhyjEXKJsJM4S2jQj4rNU/P/wCNsJNdASYyF1gP7yghC2Rvo4COfChXzVG3+9R fi4ifctabQvH91D/2wuAEBPA0UCCCrGaAWlCL6a1gHO1rDD74IZYIKro7U6gSx8vu8 2NP25RPyglrhqwMkr/5mtqIyRdUi4dClXWJTspoutzb6+VYV/qknKPujit73WuHMpu M7gyw1LxTiFrOG1W2MkVvUuTZH1Rtog6POS+0aHOZvNVafUeZ0w9mZiqmYBbokN3Q9 aWc+Oujsk8BWw== From: Frederic Weisbecker To: Peter Zijlstra , Thomas Gleixner Cc: LKML , Yunfeng Ye , "Rafael J . Wysocki" , Frederic Weisbecker , Marcelo Tosatti Subject: [PATCH 4/8] tick/nohz: Update idle_exittime on actual idle exit Date: Thu, 22 Apr 2021 14:01:54 +0200 Message-Id: <20210422120158.33629-5-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422120158.33629-1-frederic@kernel.org> References: <20210422120158.33629-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunfeng Ye The idle_exittime field of tick_sched is used to record the time when the idle state was left. but currently the idle_exittime is updated in the function tick_nohz_restart_sched_tick(), which is not always in idle state when nohz_full is configured: tick_irq_exit tick_nohz_irq_exit tick_nohz_full_update_tick tick_nohz_restart_sched_tick ts->idle_exittime = now; It's thus overwritten by mistake on nohz_full tick restart. Move the update to the appropriate idle exit path instead. Signed-off-by: Yunfeng Ye Cc: Yunfeng Ye Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Marcelo Tosatti Cc: Rafael J. Wysocki Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 31efd55ed302..ffc13b9dfbe3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -921,8 +921,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) * Cancel the scheduled timer and restore the tick */ ts->tick_stopped = 0; - ts->idle_exittime = now; - tick_nohz_restart(ts, now); } @@ -1190,10 +1188,13 @@ unsigned long tick_nohz_get_idle_calls(void) return ts->idle_calls; } -static void tick_nohz_account_idle_ticks(struct tick_sched *ts) +static void tick_nohz_account_idle_time(struct tick_sched *ts, + ktime_t now) { unsigned long ticks; + ts->idle_exittime = now; + if (vtime_accounting_enabled_this_cpu()) return; /* @@ -1214,8 +1215,9 @@ void tick_nohz_idle_restart_tick(void) struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched); if (ts->tick_stopped) { - tick_nohz_restart_sched_tick(ts, ktime_get()); - tick_nohz_account_idle_ticks(ts); + ktime_t now = ktime_get(); + tick_nohz_restart_sched_tick(ts, now); + tick_nohz_account_idle_time(ts, now); } } @@ -1226,7 +1228,7 @@ static void tick_nohz_idle_update_tick(struct tick_sched *ts, ktime_t now) else tick_nohz_restart_sched_tick(ts, now); - tick_nohz_account_idle_ticks(ts); + tick_nohz_account_idle_time(ts, now); } /** -- 2.25.1