From patchwork Thu Apr 20 12:44:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 9690331 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 7BBF760326 for ; Thu, 20 Apr 2017 12:45:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63E4B28402 for ; Thu, 20 Apr 2017 12:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 586E12845B; Thu, 20 Apr 2017 12:45:24 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 31FF028433 for ; Thu, 20 Apr 2017 12:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S945367AbdDTMox (ORCPT ); Thu, 20 Apr 2017 08:44:53 -0400 Received: from mga05.intel.com ([192.55.52.43]:54021 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943646AbdDTMow (ORCPT ); Thu, 20 Apr 2017 08:44:52 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 20 Apr 2017 05:44:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,225,1488873600"; d="scan'208";a="76726851" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga002.jf.intel.com with SMTP; 20 Apr 2017 05:44:48 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 20 Apr 2017 15:44:47 +0300 From: ville.syrjala@linux.intel.com To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Lezcano , Peter Zijlstra , "Rafael J . Wysocki" , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Subject: [PATCH] Revert "cpuidle: Replace ktime_get() with local_clock()" Date: Thu, 20 Apr 2017 15:44:47 +0300 Message-Id: <20170420124447.13716-1-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.10.2 MIME-Version: 1.0 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 From: Ville Syrjälä This reverts commit e93e59ce5b85e6c2b444f09fd1f707274ec066dc. The TSC stops in deeper C states, so using local_clock() in cpuidle 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. Note that the code has changed somewhat since the regression happened, so this isn't a 1:1 revert of the offending commit. Cc: stable@vger.kernel.org Cc: Daniel Lezcano Cc: Peter Zijlstra (Intel) Cc: Rafael J. Wysocki Signed-off-by: Ville Syrjälä --- drivers/cpuidle/cpuidle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 548b90be7685..24a52805527f 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -213,13 +213,13 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, sched_idle_set_state(target_state); trace_cpu_idle_rcuidle(index, dev->cpu); - time_start = ns_to_ktime(local_clock()); + time_start = ktime_get(); stop_critical_timings(); entered_state = target_state->enter(dev, drv, index); start_critical_timings(); - time_end = ns_to_ktime(local_clock()); + time_end = ktime_get(); trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); /* The cpu is no longer idle or about to enter idle. */