Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7982794pxb; Fri, 19 Feb 2021 04:35:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxB0/wDkMXlYuCOh1wf+yaKPnbpGIpXqie8ipwme7LCKaRW7xtxPposIroh6xv6asZ4J/B X-Received: by 2002:a50:ce18:: with SMTP id y24mr9303266edi.208.1613738101736; Fri, 19 Feb 2021 04:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613738101; cv=none; d=google.com; s=arc-20160816; b=laqQD7Ae7j/9WUR0s1oLXDG2/GIfG09TT3wn6wKffp4bowc0W5K9/pCEaWE/lDrrGb Dm+bh5XBfCURPhX89TWWQb/jnc8RoTooUx/9eZaWG6DoxO9S20uuXmoyHyhl8t+F8KWq 24oIwRe6rUqHqvh7Y18RQVCzs0gPPwoeA5fPS7pOhcpM01VSWo8UXJhIGE8orSjtX85A n8ZpvfHVYqB473gQop1YuuBrLtJ9xnUXqLR3jyto6RHMBEcCEs530QCZxA4XoM9ijJkO AiGy1/O4i2NKhtKpfEfdOf/pmq9yZQv4S8BPIkxLU/zO9OwoLUyO0RW0QJ+w8erw/G34 cVyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=amOzQxCKiLczUTFS0vxl6Bs7k5+TXlHzdvJF7YJTT68=; b=ChkPnuI96blY8IT2KfGh3oq2Os5JnLTRD9tio/V2oClnUsV98F0OyUQXEoa04RSO2E YGEDwhJJBw4TTIpKaQoJQFA80m/isSqIxw/1mjEbB7sJvFcK1Z6WhSJBcWc35/kv6qWx PovzzW6YTSwMZ6oSD9z1zjXUMpy2oSxNJjg1L59xKsTyd4RNPEjRkAPucXh8lsyLEHWn z3vrMzg9NniQwS6XrMV7UlX1Xy42maAg9+DdGtCEWvtAlwkEpjncfseJV/OyyouvoeyX Iwg6zPlyTY1P8KVIDgd+CpdsgulRbvevOrzIfA7/llixO1GdOjZon5xszo9L7xgkpMs9 wmew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=To+UdOop; 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 a20si6605343ejg.492.2021.02.19.04.34.32; Fri, 19 Feb 2021 04:35:01 -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=To+UdOop; 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 S230091AbhBSMdx (ORCPT + 99 others); Fri, 19 Feb 2021 07:33:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:44292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbhBSMdw (ORCPT ); Fri, 19 Feb 2021 07:33:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B373664E54; Fri, 19 Feb 2021 12:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613737992; bh=pZIQqFujw5R6jSZxYrLEFYhYSZcD29FIGY6b7nQuEy0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=To+UdOopDsJaN/V46ujKSg9JZNVwaZIMT8PuYqagR+6ZwP2+gETbiIcijlnq5brTk LDhpLGZP01yzUiv0KrDbABnDTDTfOlL//EIBDJK/eVxOk1zgPEUnTtdRYyiMrSuCmr 0xguMliizKlpr66WKuoGtHe7KcxsfGlR6KE9MGU6TQdmiJjbSWxvTBdG1vHdBq0iWA wNDc5I1JglhFVVyKOV3bEmvJWAKNTSSFPVHU5EM2YFUhloDfNHbSLjfoCRsZ1J10K0 fRTyN7E/ovOKUoG5zh0BExytT9ZXtEeDPHBxleESYlyRNPSGvb9qckG65Fk25JArjX 1NiUgvKjJ+0SQ== Date: Fri, 19 Feb 2021 13:33:09 +0100 From: Frederic Weisbecker To: Yunfeng Ye Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, Shiyuan Hu , Hewenliang Subject: Re: [PATCH] tick/nohz: Make the idle_exittime update correctly Message-ID: <20210219123309.GC51281@lothringen> References: <2e194669-c074-069c-4fda-ad5bc313a611@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e194669-c074-069c-4fda-ad5bc313a611@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 05, 2020 at 05:41:52PM +0800, Yunfeng Ye wrote: > 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; > > So move to tick_nohz_stop_idle() to make the idle_exittime update > correctly. > > Signed-off-by: Yunfeng Ye > --- > kernel/time/tick-sched.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index 749ec2a583de..be2e5d772d50 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) > { > update_ts_time_stats(smp_processor_id(), ts, now, NULL); > ts->idle_active = 0; > + ts->idle_exittime = now; > > sched_clock_idle_wakeup_event(); > } > @@ -901,7 +902,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); > } Hi, I've edited and queued on top of latest changes, see below. I'll post it after the merge window. --- From: Yunfeng Ye Date: Wed, 10 Feb 2021 00:08:54 +0100 Subject: [PATCH] tick/nohz: Update idle_exittime on actual idle exit 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 Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 79796286a4ba..2907c762a8fe 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -918,8 +918,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); } @@ -1231,6 +1229,7 @@ static void tick_nohz_idle_update_tick(struct tick_sched *ts, ktime_t now) else tick_nohz_restart_sched_tick(ts, now); + ts->idle_exittime = now; tick_nohz_account_idle_ticks(ts); } -- 2.25.1