From patchwork Fri Nov 7 14:31:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 5253581 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8EC0BC11AC for ; Fri, 7 Nov 2014 14:33:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFCE820154 for ; Fri, 7 Nov 2014 14:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B61C02012E for ; Fri, 7 Nov 2014 14:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752738AbaKGObj (ORCPT ); Fri, 7 Nov 2014 09:31:39 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:36641 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752728AbaKGObh (ORCPT ); Fri, 7 Nov 2014 09:31:37 -0500 Received: by mail-wg0-f45.google.com with SMTP id x12so3870652wgg.32 for ; Fri, 07 Nov 2014 06:31:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lCYeXbxTPaAEOZ4GB1uc5uM92iil7W28nJY/GUYy6AQ=; b=Rfg2MIK1B0g7QyBK5smuVntx9ghUeC6ld13YwvgWEKRFfGp1hLNFFRrIiIRIYTaoa7 litY5pWrzhAgENIZWDM97m/MbPH5GMbxZLM51uw2BMFwp9t3V2f3l6hjllAgPIODvGb3 MrrxxQURpJWoANBiuXFxobRnWabNtAWhTGPAXNfTh9wHLcc5yf/oIM6bUBUn0fgMQOPt fVTfvdoVFZ7spDNmk4v5PxX10doZL6mXyE57Lgs35gbsU+YtcpGW34aqBShVGfxZaqFQ I9Dn4PDEq8A/Fy1ZNrlV6XyUmhHlK/0I3IeWZkn+OHh2c0ShGRdTK+OhYu1g/I2NIwxO DITw== X-Gm-Message-State: ALoCoQlAVaN5fL16JJN2ebbP/4R8510aE5eHYGO0w9Fn4iV/q1rmrBwyIGyBRTiWhVV389/LtYLu X-Received: by 10.180.91.227 with SMTP id ch3mr5567558wib.17.1415370695649; Fri, 07 Nov 2014 06:31:35 -0800 (PST) Received: from localhost.localdomain (AToulouse-656-1-898-91.w109-223.abo.wanadoo.fr. [109.223.3.91]) by mx.google.com with ESMTPSA id bl9sm2231926wib.24.2014.11.07.06.31.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Nov 2014 06:31:35 -0800 (PST) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: preeti@linux.vnet.ibm.com, nicolas.pitre@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, lenb@kernel.org Subject: [PATCH V3 1/6] sched: idle: Add a weak arch_cpu_idle_poll function Date: Fri, 7 Nov 2014 15:31:22 +0100 Message-Id: <1415370687-18688-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415370687-18688-1-git-send-email-daniel.lezcano@linaro.org> References: <1415370687-18688-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The poll function is called when a timer expired or if we force to poll when the cpu_idle_force_poll option is set. The poll function does: local_irq_enable(); while (!tif_need_resched()) cpu_relax(); This default poll function suits for the x86 arch because its rep; nop; hardware power optimization. But on other archs, this optimization does not exists and we are not saving power. The arch specific bits may want to optimize this loop by adding their own optimization. Give an opportunity to the different platform to specify their own polling loop by adding a weak cpu_idle_poll_loop function. Signed-off-by: Daniel Lezcano Reviewed-by: Preeti U. Murthy --- kernel/sched/idle.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index c47fce7..ea65bbae 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -42,18 +42,6 @@ static int __init cpu_idle_nopoll_setup(char *__unused) __setup("hlt", cpu_idle_nopoll_setup); #endif -static inline int cpu_idle_poll(void) -{ - rcu_idle_enter(); - trace_cpu_idle_rcuidle(0, smp_processor_id()); - local_irq_enable(); - while (!tif_need_resched()) - cpu_relax(); - trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); - rcu_idle_exit(); - return 1; -} - /* Weak implementations for optional arch specific functions */ void __weak arch_cpu_idle_prepare(void) { } void __weak arch_cpu_idle_enter(void) { } @@ -65,6 +53,23 @@ void __weak arch_cpu_idle(void) local_irq_enable(); } +void __weak arch_cpu_idle_poll(void) +{ + local_irq_enable(); + while (!tif_need_resched()) + cpu_relax(); +} + +static inline int cpu_idle_poll(void) +{ + rcu_idle_enter(); + trace_cpu_idle_rcuidle(0, smp_processor_id()); + arch_cpu_idle_poll(); + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); + rcu_idle_exit(); + return 1; +} + /** * cpuidle_idle_call - the main idle function *