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.2 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,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 EC5BCC433E6 for ; Thu, 11 Mar 2021 12:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9950F64FDF for ; Thu, 11 Mar 2021 12:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233366AbhCKMiC (ORCPT ); Thu, 11 Mar 2021 07:38:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:59850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233233AbhCKMh2 (ORCPT ); Thu, 11 Mar 2021 07:37:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38A0964FE2; Thu, 11 Mar 2021 12:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615466248; bh=yrQS4de1iJm9J9n5XDfZaqFGWiDn0IAQujRInbLCvLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYGiE2vG11jxzOPcV2OcBnHSrVZ6Ffc2TUDAU4fZNT5MJpyrkkUUh+4fgCc2LBE3+ VWZqgqkHsZB6dUkSTK2ajW126YhBebfXxccqe2ATWmm0TR0h30LhtyJRnSFtQaZtfe eoJJBCv2wzCJlQ1wOyqOOIPbIuH1P/PI33sJQP2bLoNT0g3EPnHaPUkGah+niTKTbW yNI+jEpTcg6Efm7x9PoYC2wGcTwLOOlGMNka9+V302uBd36aK74lIpLJPAdFSejBs6 NI48h6O7ok+Y5VCuQz5cowMXQ9CWNkRvNdU/bcV/67dM8+2hdRuFlAjGC0sW+CN5lR Ydf1VOhFhHIAw== From: Frederic Weisbecker To: Peter Zijlstra , Thomas Gleixner Cc: LKML , Yunfeng Ye , "Rafael J . Wysocki" , Ti Zhou , Frederic Weisbecker , "Paul E . McKenney" , Marcelo Tosatti , Ingo Molnar Subject: [PATCH 05/10] tick/nohz: Update idle_exittime on actual idle exit Date: Thu, 11 Mar 2021 13:37:03 +0100 Message-Id: <20210311123708.23501-6-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311123708.23501-1-frederic@kernel.org> References: <20210311123708.23501-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 c86b586d65e0..2a041d0dc3eb 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -917,8 +917,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); } @@ -1192,10 +1190,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; /* @@ -1216,8 +1217,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); } } @@ -1228,7 +1230,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