From patchwork Thu Apr 20 13:08:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 9690341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B91260383 for ; Thu, 20 Apr 2017 13:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04D4C205AD for ; Thu, 20 Apr 2017 13:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDC0528387; Thu, 20 Apr 2017 13:08:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7CAA205AD for ; Thu, 20 Apr 2017 13:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S945574AbdDTNIT (ORCPT ); Thu, 20 Apr 2017 09:08:19 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:50539 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941539AbdDTNIS (ORCPT ); Thu, 20 Apr 2017 09:08:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DK0juQBSo41tf1nQitcxgqgDjO0adQsZfwYQjR+OXgs=; b=GI30FC1SzoKkYaK30+8OcLIffv Yjz+j3mmCjd+6+lhKrwNuuaEbCDIm2AJ+8QE7gkXU7AExYEcr5fy9iyTPge3FMyuiCk1JC1CCCJ54 tdf0JIKDKls/Lcr0RaL5vEoUMyFTxxiUI3UelTnyyrCVEl/Vpg5JzZNjfcyNXeeSwuaBaVIaGynBG Do/5OIzzTbw7UdSYTtY98BQAMMUqPhKRkjX34XuA9frOrYNHweZkTkD3QzXI4CL/Aq9uMnr1Bv6a3 qPNPL17xKTCN5Xi+sniTEmVYodo+sA6ycn2pF54ePCTASJc3iT0CjNZK/iHRV+XmlvDLX/6nJ6Wsj 83ZnT2Gw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1d1Bom-0007YH-5H; Thu, 20 Apr 2017 13:08:16 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3E984203AA6C1; Thu, 20 Apr 2017 15:08:13 +0200 (CEST) Date: Thu, 20 Apr 2017 15:08:13 +0200 From: Peter Zijlstra To: ville.syrjala@linux.intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" Subject: Re: [PATCH] Revert "cpuidle: Replace ktime_get() with local_clock()" Message-ID: <20170420130813.h7dycr5cptbrvdkz@hirez.programming.kicks-ass.net> References: <20170420124447.13716-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170420124447.13716-1-ville.syrjala@linux.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Apr 20, 2017 at 03:44:47PM +0300, ville.syrjala@linux.intel.com wrote: > From: Ville Syrjälä > > This reverts commit e93e59ce5b85e6c2b444f09fd1f707274ec066dc. > > The TSC stops in deeper C states, On some old hardware (Core2 era and before) only. You've forgotten to mention what hardware you've observed problems with. > so using local_clock() in cpuidle But on said hardware, local_clock() isn't an immediate TSC user. > to track the C state residency seems like a bad idea. With local_clock() > powertop is reporting mostly 0% residency for C states here. Presumably > the core is still spending most of its time in some deep C-state since > the totals typically add up to only 5% or so, so perhaps the governor > isn't getting totally confused by these bogus numbers. But let's go > back to using ktime_get() as that at least works correctly across the > board. Does this cure it? Tested-by: Ville Syrjälä --- drivers/cpuidle/cpuidle.c | 2 ++ kernel/sched/clock.c | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 548b90be7685..e0d4ad108887 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -219,6 +219,8 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, entered_state = target_state->enter(dev, drv, index); start_critical_timings(); + sched_clock_idle_wakeup_event(0); + time_end = ns_to_ktime(local_clock()); trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 00a45c45beca..15e848706be4 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -347,6 +347,9 @@ void sched_clock_tick(void) { struct sched_clock_data *scd; + if (timekeeping_suspended) + return; + WARN_ON_ONCE(!irqs_disabled()); /* @@ -378,11 +381,7 @@ EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event); */ void sched_clock_idle_wakeup_event(u64 delta_ns) { - if (timekeeping_suspended) - return; - sched_clock_tick(); - touch_softlockup_watchdog_sched(); } EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);