From patchwork Thu Jun 9 03:08:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 9166163 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 4A56260572 for ; Thu, 9 Jun 2016 03:10:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4122B281FE for ; Thu, 9 Jun 2016 03:10:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35F88282DC; Thu, 9 Jun 2016 03:10:01 +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 70BC32823D for ; Thu, 9 Jun 2016 03:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933912AbcFIDJu (ORCPT ); Wed, 8 Jun 2016 23:09:50 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34856 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933858AbcFIDJs (ORCPT ); Wed, 8 Jun 2016 23:09:48 -0400 Received: by mail-pf0-f169.google.com with SMTP id c2so8690696pfa.2 for ; Wed, 08 Jun 2016 20:09:48 -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=HIr264Z4vWoB58w1L5Nl9nFM3IH1L/tVFd8Dw0a+1cY7keDzwlEIeYubOhP3WzLli6 E4QTLBG+bkLnfBM6/lH8NPhu8S8hnJ17SbvogilOoNb92NLVZIPLe5ZqWvOKvJoIqC7O PoNsjJ0TVAWohvDAYI1mKQVEOdvCcYrcKTlHs= 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=ID/JGkjGzcR/r7tDaTpwLWW0b/TOlths3wXV71kVNvTHmvI4zRZJS+n7OXxFhYA2qD Hd5zJLUEzxMOD0TptwUTVpipZJKBW2PgmOSY8swGnzC7CHpc13p4f8UMJ/WS9+TOOeko QjDTiqtadVlZX6NvkO3eIGukR63mEki3Ml5WMV4dvSgQbWvfEsiqA7ZD0Yo2ecZz2/E8 gFzqs9IKz/ds397Z8GK0I9yTZCoLxLPX3oOKcaJ5q7WuN/KSlniuCg2foQHAnaR6it4t 7V+/HGS2OFmlVhDlUCy1ZTEMiZ6DmjrUrTdICgja+sjV+zfas58OnNixOJW1AMntxuS7 AMlg== X-Gm-Message-State: ALyK8tLDmrmwCzgcRRTPPYvbIH06Y0CmbmIf5BYwwVfpTcoeevc6gjkoMF8OnzOv1ntcJsif X-Received: by 10.98.35.10 with SMTP id j10mr2149626pfj.10.1465441787429; Wed, 08 Jun 2016 20:09:47 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id a17sm5472417pfa.70.2016.06.08.20.09.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 20:09:47 -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 Subject: [RFC PATCH] power/cpuidle: enhance the precision of state select Date: Thu, 9 Jun 2016 11:08:40 +0800 Message-Id: <1465441720-5527-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: