From patchwork Wed Jan 29 20:31:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 315212 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 82FFB2C0404 for ; Thu, 30 Jan 2014 07:32:07 +1100 (EST) Received: from mail-qc0-f176.google.com (mail-qc0-f176.google.com [209.85.216.176]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D292A2C00A1 for ; Thu, 30 Jan 2014 07:31:41 +1100 (EST) Received: by mail-qc0-f176.google.com with SMTP id e16so3603680qcx.35 for ; Wed, 29 Jan 2014 12:31: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:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=2r5vf0evRcKAmhvkND7O4Vh7I/232ZA9m2MRzyZqFBM=; b=BeKmH5PlJ3D2y7htaEsN+PG15/7S01uHJDt32gwP+tP/i5Bew0f7ySo4dc5JbW8CqM /qzvRoYsucf5quRiFXxuBWLIl/QkWv0VkTs8N+Sf0/2Z1rz6NpT2CIw/eG7LFIxBZFx0 79qXatkLIZmQsJ2nSILAkW/X98jZmZWu1svxuZli0neDnYhzb496NMm3TQOJcbxB2Awj lun/nFcusPJNrziCeYdPsy+QYb7QShEVtGvsh3cyL//vuEvaVP7+ZXlQnie2MvlKU2Tx ygk7dmart2RfgLAnqRf5qSojFXZ+xVvzu6oIpExIYKuJDU1lAwitUZpktGygTZFMmRKm XsdQ== X-Gm-Message-State: ALoCoQkFiukXXtZWbGbY6mwvWotNWf8Kova22nkgL76roOo+CvJAA1aqjQ7qEHNE2+1pDiMQcM8P X-Received: by 10.140.43.3 with SMTP id d3mr14641233qga.70.1391027498759; Wed, 29 Jan 2014 12:31:38 -0800 (PST) Received: from xanadu.home (modemcable177.143-130-66.mc.videotron.ca. [66.130.143.177]) by mx.google.com with ESMTPSA id j65sm5066623qgj.18.2014.01.29.12.31.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 12:31:38 -0800 (PST) Date: Wed, 29 Jan 2014 15:31:36 -0500 (EST) From: Nicolas Pitre To: Olof Johansson , Russell King , Benjamin Herrenschmidt , Preeti U Murthy , Paul Mundt , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Daniel Lezcano Subject: Re: [PATCH v2 1/6] idle: move the cpuidle entry point to the generic idle loop In-Reply-To: <1391017513-12995-2-git-send-email-nicolas.pitre@linaro.org> Message-ID: References: <1391017513-12995-1-git-send-email-nicolas.pitre@linaro.org> <1391017513-12995-2-git-send-email-nicolas.pitre@linaro.org> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Cc: linaro-kernel@lists.linaro.org, linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, 29 Jan 2014, Nicolas Pitre wrote: > In order to integrate cpuidle with the scheduler, we must have a better > proximity in the core code with what cpuidle is doing and not delegate > such interaction to arch code. > > Architectures implementing arch_cpu_idle() should simply enter > a cheap idle mode in the absence of a proper cpuidle driver. > > Signed-off-by: Nicolas Pitre > Acked-by: Daniel Lezcano As mentioned in my reply to Olof's comment on patch #5/6, here's a new version of this patch adding the safety local_irq_enable() to the core code. ----- >8 From: Nicolas Pitre Subject: idle: move the cpuidle entry point to the generic idle loop In order to integrate cpuidle with the scheduler, we must have a better proximity in the core code with what cpuidle is doing and not delegate such interaction to arch code. Architectures implementing arch_cpu_idle() should simply enter a cheap idle mode in the absence of a proper cpuidle driver. In both cases i.e. whether it is a cpuidle driver or the default arch_cpu_idle(), the calling convention expects IRQs to be disabled on entry and enabled on exit. There is a warning in place already but let's add a forced IRQ enable here as well. This will allow for removing the forced IRQ enable some implementations do locally and allowing for the warning to trig. Signed-off-by: Nicolas Pitre diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c index 988573a9a3..14ca43430a 100644 --- a/kernel/cpu/idle.c +++ b/kernel/cpu/idle.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include #include @@ -95,8 +96,10 @@ static void cpu_idle_loop(void) if (!current_clr_polling_and_test()) { stop_critical_timings(); rcu_idle_enter(); - arch_cpu_idle(); - WARN_ON_ONCE(irqs_disabled()); + if (cpuidle_idle_call()) + arch_cpu_idle(); + if (WARN_ON_ONCE(irqs_disabled())) + local_irq_enable(); rcu_idle_exit(); start_critical_timings(); } else {