From patchwork Tue Feb 11 15:11:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 24468 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E36E203F3 for ; Tue, 11 Feb 2014 15:12:39 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id c41sf18956705yho.1 for ; Tue, 11 Feb 2014 07:12:38 -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=OHGmGT77eVCRHJ8fWj85oR6PEwU2ElSvTKhhKuTgrvc=; b=OJGPPLgQ5kfhVg3DTFegIfDR2uUQUa5SpgKkK+NEXkj9eeJU2cLgbXKe5NfBtUFfJP 7fzm9/EQvqeYdr9z5K/eV5480syWk1XH2uZLh5CjrwMc7mQQigUJSZwE4BM2zLaOH+i7 NeTmzYRXHKZqaTLtCT50Uaymh9qGMkCTHRy3ZBNbljjWm2XYHRjICURbr7auppZrprp3 FdW/eFyhmp5rtNFXyjncZhridBM5cWFb/JPuor7OJjHiPXJbD8dT+mQYVCXGgN47L3gK 58Mo6RBlZrXJm1cCJnah9QCPYAbBGkEvFQ8kSlXqSZw3SW75SGO7sS0Rscnnnfpreyie 8KEg== X-Gm-Message-State: ALoCoQkxkFoGG/ziTPrqG+EYxecWnaLvZa4gZ30MOvBhH0yEQ/mTAqz5r/w8oWE94ov0zQf8FwBw X-Received: by 10.58.253.33 with SMTP id zx1mr13889938vec.10.1392131558270; Tue, 11 Feb 2014 07:12:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.47 with SMTP id s44ls2465770qgs.70.gmail; Tue, 11 Feb 2014 07:12:38 -0800 (PST) X-Received: by 10.52.189.33 with SMTP id gf1mr5957619vdc.26.1392131557881; Tue, 11 Feb 2014 07:12:37 -0800 (PST) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id a2si6010062vea.67.2014.02.11.07.12.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:12:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id w20so6109444vbb.27 for ; Tue, 11 Feb 2014 07:12:37 -0800 (PST) X-Received: by 10.220.110.69 with SMTP id m5mr23577vcp.55.1392131557786; Tue, 11 Feb 2014 07:12:37 -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.220.174.196 with SMTP id u4csp253498vcz; Tue, 11 Feb 2014 07:12:37 -0800 (PST) X-Received: by 10.68.241.134 with SMTP id wi6mr44550989pbc.44.1392131556822; Tue, 11 Feb 2014 07:12:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si19278636pbh.190.2014.02.11.07.12.36; Tue, 11 Feb 2014 07:12:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbaBKPLv (ORCPT + 27 others); Tue, 11 Feb 2014 10:11:51 -0500 Received: from mail-la0-f52.google.com ([209.85.215.52]:53260 "EHLO mail-la0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbaBKPLm (ORCPT ); Tue, 11 Feb 2014 10:11:42 -0500 Received: by mail-la0-f52.google.com with SMTP id c6so6064027lan.11 for ; Tue, 11 Feb 2014 07:11:41 -0800 (PST) X-Received: by 10.152.3.99 with SMTP id b3mr1365413lab.61.1392131500901; Tue, 11 Feb 2014 07:11:40 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-479-183.w86-201.abo.wanadoo.fr. [86.201.194.183]) by mx.google.com with ESMTPSA id qx7sm19964004lbb.9.2014.02.11.07.11.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:11:40 -0800 (PST) From: Daniel Lezcano To: mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, rjw@rjwysocki.net Cc: nicolas.pitre@linaro.org, preeti@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] idle: Move idle conditions in cpuidle_idle main function Date: Tue, 11 Feb 2014 16:11:30 +0100 Message-Id: <1392131491-5265-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392131491-5265-1-git-send-email-daniel.lezcano@linaro.org> References: <1392131491-5265-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=neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , This patch moves the condition before entering idle into the cpuidle main function located in idle.c. That simplify the idle mainloop functions and increase the readibility of the conditions to enter truly idle. This patch is code reorganization and does not change the behavior of the function. Signed-off-by: Daniel Lezcano --- kernel/sched/idle.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 8b10891..72b5926 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -75,6 +75,23 @@ static int cpuidle_idle_call(void) struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int next_state, entered_state; + /* + * In poll mode we reenable interrupts and spin. + * + * Also if we detected in the wakeup from idle path that the + * tick broadcast device expired for us, we don't want to go + * deep idle as we know that the IPI is going to arrive right + * away + */ + if (cpu_idle_force_poll || tick_check_broadcast_expired()) + return cpu_idle_poll(); + + if (current_clr_polling_and_test()) { + local_irq_enable(); + __current_set_polling(); + return 0; + } + stop_critical_timings(); rcu_idle_enter(); @@ -112,6 +129,8 @@ out: rcu_idle_exit(); start_critical_timings(); + __current_set_polling(); + return 0; } @@ -133,25 +152,8 @@ static void cpu_idle_loop(void) local_irq_disable(); arch_cpu_idle_enter(); - /* - * In poll mode we reenable interrupts and spin. - * - * Also if we detected in the wakeup from idle - * path that the tick broadcast device expired - * for us, we don't want to go deep idle as we - * know that the IPI is going to arrive right - * away - */ - if (cpu_idle_force_poll || tick_check_broadcast_expired()) { - cpu_idle_poll(); - } else { - if (!current_clr_polling_and_test()) { - cpuidle_idle_call(); - } else { - local_irq_enable(); - } - __current_set_polling(); - } + cpuidle_idle_call(); + arch_cpu_idle_exit(); /* * We need to test and propagate the TIF_NEED_RESCHED