Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp312437pxf; Thu, 11 Mar 2021 04:39:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdXmRcBx4vXaw8Lz1F/bE4ltembayRGDwgK5Dw+0t9oss6g51F4GJ3g8Y1QPbJtssH13+J X-Received: by 2002:aa7:c456:: with SMTP id n22mr8148400edr.277.1615466364476; Thu, 11 Mar 2021 04:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615466364; cv=none; d=google.com; s=arc-20160816; b=LILTDncIlK404tKNyu6xcDvVlHQiwnHcDrA5T+Wp2K2b3B+LjgVeYeyhcpdJgsGCuu HWt3gpjst+rdCJOFOQ5+iJHk5MwjEcxE08ZTRqq6EtM4+YzC8k+WA8wlG5RdVRX4C9p6 2prP7eCknU6ZRJ8jMZzNvfBHpyLD708IFZCHeIQCRWIjR1Q4VHnOc+8maHZBPtyfKoQ5 xX8/KqjX5cbGcIPoTAfaCeIk+HBLlxdpvO5MANGVt7Kx3at0Oq0avZVZsxWcnsNoBfZQ h2i7zR9c1/TIdUpBqP9sGI7thDXTifHXCFlNRVP1WKgVRv6h0u4QrhGJKvbo9Dhmkqzv gi+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rP9N6X/2kftIl4HsXr4x4RHiduYkvprJxsF41kk0np4=; b=qnFfRrworxiDbH7zHTPXlKkCvRya8dqrN+QicqDLS2krsESNUYUiCgbihZ8hqlVpQl o82kY+xut3czvGP4/mRhHdlaCenQ6TNElnVo9ICK7EpHnqhE7IUuVna4DyUXqyVoGmap W5j6u29sdIVY5JmsjFUWuGWEOkug8CymRqzCoXP1aHEVusUDXnF5Mc3Hm/FkKQbUgciS 7OTo58pAnZVQ3l4+Y811w1DrffoMEcZS5m8piG5OcFZLgmKfBhuJ+yO2alsogcbQgVLa u9P2tEiVaUpuCu4hyB2l2S0lHuikkEDdliusM8MdrThKreei6oP2vDuhaDAeWMxZG7Nk SGiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EYGiE2vG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si1316389ejn.395.2021.03.11.04.39.01; Thu, 11 Mar 2021 04:39:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EYGiE2vG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233252AbhCKMiC (ORCPT + 99 others); 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