From patchwork Tue May 17 14:54:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 67990 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2121359qge; Tue, 17 May 2016 07:54:16 -0700 (PDT) X-Received: by 10.66.100.197 with SMTP id fa5mr2644711pab.25.1463496856624; Tue, 17 May 2016 07:54:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si5023323pfa.119.2016.05.17.07.54.16; Tue, 17 May 2016 07:54:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbcEQOyP (ORCPT + 3 others); Tue, 17 May 2016 10:54:15 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:35621 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbcEQOyO (ORCPT ); Tue, 17 May 2016 10:54:14 -0400 Received: by mail-wm0-f44.google.com with SMTP id e201so143522792wme.0 for ; Tue, 17 May 2016 07:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LUvNuqnZ4EMivSelT+NKe76ZP/SfMn2nX3tVZqlExAc=; b=W9Yfi7v6Bsw8adI2zio7jNXZGCheojvVSdZZnxQcBCgqKPzLwsRTubQL2J0foygHi8 zkaMkr4k4v4P2QSQ1y0tO+jPKiQiYrSZR4obU3dYwu9lUgOjz1iMQY1OQnXGmpm3spEc cjukDrr2523ogRDFlRMFgV09WTAm+6wrBGzZw= 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; bh=LUvNuqnZ4EMivSelT+NKe76ZP/SfMn2nX3tVZqlExAc=; b=P2m7aZ8evyWhQv1uKW+lRtILloy3m/VH5/l88m+kgIyZyxyGvW3EGMeiAG3tan1fMs 8FXV93VQ4usvBsxu+qgzTN8ow9TaMcvglwVBmeeACMe0dvNxVkC7dnkdfXdd3fx5z7kf VPjbI3/qYB34LsL+KnAlxGftjiaVPWbu84u36AYKqDD2q7u50RqJMFW8RXZKODZxAVej udjttpKy6P+hq+tsODTgSfBxr4HvYmSupm1AsgTA6pgoOSlK83Sfsg4ug4FBxVV3o3BS Tw5QGTCtQfWt7Ob5FZDOM1M1WSaVEaTRJyg+28AYp/2aN0IivW8Zh9v0wq7CPSN3Qi0H rO4A== X-Gm-Message-State: AOPr4FVwo9qT0Fnq6TE+M2LOTFGdyiq+kHIQ+JXHW+nLaXm22U5Zxp1b2RQYVEXiR3vdOugJ X-Received: by 10.28.6.17 with SMTP id 17mr2080939wmg.26.1463496852819; Tue, 17 May 2016 07:54:12 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id u6sm24433489wmd.21.2016.05.17.07.54.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 May 2016 07:54:12 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: gregory.clement@free-electrons.com, linux-pm@vger.kernel.org, linux@armlinux.org.uk, paul.burton@imgtec.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH] cpuidle: Fix coupled state parameter in cpuidle_enter() Date: Tue, 17 May 2016 16:54:00 +0200 Message-Id: <1463496840-2858-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The commit 0b89e9aa2856 rightfully fixed a regression by letting the couple idle state framework to handle local interrupt enabling when the cpu is exiting an idle state. The current code check if the idle state is a coupled one and, if so, it will let the couple code to enable the interrupt. This way, it can decrement the ready-count before handling the interrupts. This mechanism prevents the other cpus to wait for a cpu which is handling interrupts. But the check is done against the state index returned by the back end driver 'enter' functions which could be different from the initial index passed as parameter to the cpuidle_enter_state() function. entered_state = target_state->enter(dev, drv, index); [ ... ] if (!cpuidle_state_is_coupled(drv, entered_state)) local_irq_enable(); [ ... ] If the 'index' is referring to a coupled idle state but the 'entered_state' is *not* coupled, then the interrupts are enabled again. All cpus blocked on the sync barrier may busy loop longer if the cpu has interrupts to handle before decrementing the ready-count. Thus consuming more energy than saving. Fixes: 0b89e9aa2856 "cpuidle: delay enabling interrupts until all coupled CPUs leave idle" Cc: stable@vger.kernel.org Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index f996efc..cd021ed 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, tick_broadcast_exit(); } - if (!cpuidle_state_is_coupled(drv, entered_state)) + if (!cpuidle_state_is_coupled(drv, index)) local_irq_enable(); diff = ktime_to_us(ktime_sub(time_end, time_start));