From patchwork Fri Jun 17 09:13:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 9183107 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 BFE5F60776 for ; Fri, 17 Jun 2016 09:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B8CF27E33 for ; Fri, 17 Jun 2016 09:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87362283A8; Fri, 17 Jun 2016 09:13:54 +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=ham 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 CBC9427E33 for ; Fri, 17 Jun 2016 09:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbcFQJNr (ORCPT ); Fri, 17 Jun 2016 05:13:47 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34927 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbcFQJNq (ORCPT ); Fri, 17 Jun 2016 05:13:46 -0400 Received: by mail-pa0-f43.google.com with SMTP id hl6so26858727pac.2 for ; Fri, 17 Jun 2016 02:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=FiVUyJIp9PwP5KST8suPZliHBns9Vbj0qbLGMS9U5q4=; b=LQMeEixkPQ967/SzV4VIMHItcco2C5pN55mTQI4hBKyQk8OYbP+ejuZ82luHK7Oagi k1mQTqSn3yVjgybUIor9nE5hafem1OIIUwCdwIqlDKGuoCpBhY6bsPzHXVR/BESXRi+X na7+ygeXSB033mwu8p7g+XR+qGf+4/3gYd3S8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=FiVUyJIp9PwP5KST8suPZliHBns9Vbj0qbLGMS9U5q4=; b=YA32Z7DdhEemrG6kGPblN9oCgwOJwGFxhuV0fUNCQqfWHsvsp8Mh65h7qK/JuAnHIG do1mnJy/+AsHLR/xkFurh+G54W+idQAlvdHvf5+2+PVVP0SS8aEZZcGfo/CeEwJ0YcyY DcqwephXkSrOg/06OeI70G9DlRmwKTemwlgjOJT1hh3iUYvFH/W31fB7/DV20peRywAb VJJ5pPDh9L5YaJGgCKiKV46p0jlIqh1DxmbwqWOoIYOxAxBPFVPwFa8VjozYhCdQExiN 2tB1es4RxQ9CTnFuzAib4Fn95KfiKK3GzG8+Bn3gRkuOQXplzNfvQinK9/e7y1dPVXP6 pl0g== X-Gm-Message-State: ALyK8tK62leb6dHGhM28xBY9Fu9mqgLe4cDLdIyfJqNv9zKHKsO0HWmeQ8EWf1TWQjzLSpfd X-Received: by 10.66.25.38 with SMTP id z6mr1341307paf.11.1466154825325; Fri, 17 Jun 2016 02:13:45 -0700 (PDT) Received: from bj03382pcu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id 7sm37356841pfa.28.2016.06.17.02.13.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 02:13:44 -0700 (PDT) From: Zhaoyang Huang X-Google-Original-From: Zhaoyang Huang To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, zhaoyang.huang@spreadtrum.com, tglx@linutronix.de Subject: [RESEND PATCH v2 1/2] power/cpuidle: enhance the precision of state select Date: Fri, 17 Jun 2016 17:13:35 +0800 Message-Id: <1466154816-17900-1-git-send-email-zhaoyang.huang@spreadtrum.com> X-Mailer: git-send-email 1.7.9.5 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 In previous version, cpu_pm_enter is invoked after the governor select the state, which cause the executing time of cpu_pm_enter is included in the idle time. Moving it before the state selection. Signed-off-by: Zhaoyang Huang --- kernel/sched/idle.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index bd12c6c..929da2e 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -130,6 +131,7 @@ static void cpuidle_idle_call(void) struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int next_state, entered_state; + int ret; /* * Check if the idle task must be rescheduled. If it is the @@ -174,12 +176,16 @@ static void cpuidle_idle_call(void) /* * Ask the cpuidle framework to choose a convenient idle state. */ - next_state = cpuidle_select(drv, dev); - entered_state = call_cpuidle(drv, dev, next_state); - /* - * Give the governor an opportunity to reflect on the outcome - */ - cpuidle_reflect(dev, entered_state); + ret = cpu_pm_enter(); + if (!ret) { + next_state = cpuidle_select(drv, dev); + entered_state = call_cpuidle(drv, dev, next_state); + cpu_pm_exit(); + /* + * Give the governor an opportunity to reflect on the outcome + */ + cpuidle_reflect(dev, entered_state); + } } exit_idle: