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: 40414 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 53903240F7 for ; Fri, 7 Nov 2014 14:32:03 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf3059384lam.0 for ; Fri, 07 Nov 2014 06:32:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gsm79Zzbg0IHTjFdHjp1U8fx66VUamPwU/rj2NlqoC0=; b=fXA4Q3B5vgnD7FmlQD4peniHIb2q8PkwlIyoJtRkZyj8mf7cbm2k8QKLSjwYW4tCCl NVQa7mlr9i3FlITpCL3iBYLDQr/HD8ffRYUT6DGzLHtHnj9oHDbCmn90kG4/ZH/VtYGb oz3+6wz6aR5x/aODJ6bbrY+eriVZOI6ebjFMGDd+3uR7k7rm/2i0V358jSRUCThTGaAw 5BMnZblhI9LqzK1BktdLLSYAKiXOe1PmXqkcnQmxoJKJ+6mNzlgsD8qTk9ckdsEkN98y ipiA7t8JJsrMZcC4KnVEekiujHuC2akunVM+VdOTNBNaLLy8GSLzpAVHix9YK6Io+jIj C/4Q== X-Gm-Message-State: ALoCoQnz9rI8LjEM6rB8RbqNJ/Awp6Ev/MGgpcgW6kxOtmSN0nKBT7ymJ9CtxKDvEQYN8uhVOxgb X-Received: by 10.112.89.195 with SMTP id bq3mr2057229lbb.9.1415370722223; Fri, 07 Nov 2014 06:32:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.168 with SMTP id u8ls193723lag.103.gmail; Fri, 07 Nov 2014 06:32:02 -0800 (PST) X-Received: by 10.112.146.37 with SMTP id sz5mr11501591lbb.27.1415370722047; Fri, 07 Nov 2014 06:32:02 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ka2si15415554lbc.9.2014.11.07.06.32.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 06:32:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id pn19so4550427lab.18 for ; Fri, 07 Nov 2014 06:32:02 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr11490630laa.71.1415370721949; Fri, 07 Nov 2014 06:32:01 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp206816lbc; Fri, 7 Nov 2014 06:32:01 -0800 (PST) X-Received: by 10.66.221.198 with SMTP id qg6mr12646967pac.106.1415370720295; Fri, 07 Nov 2014 06:32:00 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha3si9066618pbc.225.2014.11.07.06.31.57 for ; Fri, 07 Nov 2014 06:32:00 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752808AbaKGObk (ORCPT + 25 others); Fri, 7 Nov 2014 09:31:40 -0500 Received: from mail-wg0-f41.google.com ([74.125.82.41]:51604 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752713AbaKGObh (ORCPT ); Fri, 7 Nov 2014 09:31:37 -0500 Received: by mail-wg0-f41.google.com with SMTP id k14so3837689wgh.28 for ; Fri, 07 Nov 2014 06:31:35 -0800 (PST) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 *