From patchwork Thu Jun 9 07:34:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 9166395 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 89A706048F for ; Thu, 9 Jun 2016 07:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 798E12823D for ; Thu, 9 Jun 2016 07:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E29428319; Thu, 9 Jun 2016 07:36:26 +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 E6D0F2823D for ; Thu, 9 Jun 2016 07:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425254AbcFIHfx (ORCPT ); Thu, 9 Jun 2016 03:35:53 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35878 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425244AbcFIHfw (ORCPT ); Thu, 9 Jun 2016 03:35:52 -0400 Received: by mail-pf0-f170.google.com with SMTP id t190so10906694pfb.3 for ; Thu, 09 Jun 2016 00:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:from:to:subject:date; bh=rNi28u7Qu+fd2KjKx98nVPi9INLHUZvSbdKri+o5+iw=; b=QivTytrpqetSNSEK/p9B8gMQkj8jRuOVRacJwTMY+P5NPIEilUbe2xgRYoq7J3VG/L gKLJIEXSgv0uROJYwdR+8DwWENmWqf9Tk37VrARNmhpZCvaBhm/3zLbynV72CKEErLxZ gsthfPQYJHGWqxRrecLRogW5SolbKtNX1SOp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:subject:date; bh=rNi28u7Qu+fd2KjKx98nVPi9INLHUZvSbdKri+o5+iw=; b=FVjQYn9CZ9zrbAXruMPgm6Tg0qphwXd48okeeWpdHOhiyuLLfJFUqEf55/a/YSA9xe zURJnON1FfOHacTztIE4XMGXV0+h6zsZEsQ8kidF44MXPP9NLY4bi5Q3eHQI74Els0q+ Andt8ng21oA5LqYIXRvkia6tmQSSLmozY/dRsp3t+xYfYdHl5olKNDFIXARZetw1U26m sxlK8BlU8tA4gJvztuVBz+Q7/y+ROR36R+D7I6Jo8T7xQGenrjGJTI6QsXuEeB610ib8 8P4MdULqfnO+t7WiZCzuT93FC3Xt8VjN4pG+ZD8MheolYrSKmHFrh7PqFkTuPWeod4Xx yXyQ== X-Gm-Message-State: ALyK8tI08/a4P6G6ZpTq4QhRNY9G/J5VBphPABclGcrd/10kU5+SKeyLFmfdQ+0hXtCUUj9I X-Received: by 10.98.73.214 with SMTP id r83mr3210406pfi.114.1465457752048; Thu, 09 Jun 2016 00:35:52 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id r85sm7438021pfr.48.2016.06.09.00.35.47 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jun 2016 00:35:50 -0700 (PDT) Message-ID: <57591c56.582b620a.f8dc2.19d7@mx.google.com> X-Google-Original-Message-ID: <1465457684-9848-1-git-send-email-y> From: zhaoyang.huang@linaro.org X-Google-Original-From: y 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: [RFC PATCH v2 1/2] power/cpuidle: enhance the precision of state select Date: Thu, 9 Jun 2016 15:34:43 +0800 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 From: Zhaoyang Huang 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: