From patchwork Tue Nov 7 17:35:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakash, Prashanth" X-Patchwork-Id: 10047065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFA636032D for ; Tue, 7 Nov 2017 17:37:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E6B2A28D for ; Tue, 7 Nov 2017 17:37:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BF792A291; Tue, 7 Nov 2017 17:37:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E66882A270 for ; Tue, 7 Nov 2017 17:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EiXIWll2SZxPY7Mg1EKNpNFAijfWzXMDVHowSsKllZ0=; b=N3/oAfBAC8Lvh9k2t7ekYMQsWJ zC+NWBX8JkiM3tE63LBWCUe3d7mhFh0YU/Kkzb1wOXqLTIW1ynyLfJWN7dDtAQuGCI91rbL8yYh2J EpzQrlnX+po1p2TRmhGUSJ9S2/+nNoPooFnjBXQL3H7WYyRYs09JEJFWf7/V9zY086iV3HLUCSp7n yjn8VLMuKS+bQyC8E0CfzjHkrXesdu87TjGYpcNQgYhMEa62CeeHObtqd3US2X8cQyHhwxEmg1mGO 3Bw87IPZi1mXFKWcJF884VQD+7AfWNhH1P+v81R43HowAZxkDT+rZIsGhepJJTYrk3CosXF40IM9X niEkQUaA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eC7o4-0003Yy-8S; Tue, 07 Nov 2017 17:37:00 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC7nR-0002o6-Ek for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2017 17:36:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 15BFA607CB; Tue, 7 Nov 2017 17:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1510076165; bh=h4if0V9QrRNAyq68uXgJsegrHwLSW+C4J81SpDUhW60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WjTrF9wZ4oUcmM51hTLLWvJLFhIgNdEMknexUreXinFag1Ex6BiyWi1+hh+w2AVc5 S8FuzKnVZ2RIVYUggD56UioIPLCCF7xdQBSHcO0JnuQoIof8qYpm6Sm42vyefK1WHe 4UBWbywrQcNh65kgcZUPwJ6CrOU1cqD2V4SH8veI= Received: from pprakash-lnx.qualcomm.com (unknown [129.46.15.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pprakash@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A73C160794; Tue, 7 Nov 2017 17:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1510076164; bh=h4if0V9QrRNAyq68uXgJsegrHwLSW+C4J81SpDUhW60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBAfbOJwsy1VQl2YwX7ZSeI6PkfRbXG4UY2PVVGL2LdOz7WPW3BORdIzibprbKbSn kvROjmtchZvJmtUiPswud2GLDu812qN8/T2No6mE+n3wX1KnCMhur/1rQSRlq5m+dY X+os28tj2+TTcBYvB+CHZvtm4B9LhHRcAf4y1l6A= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A73C160794 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pprakash@codeaurora.org From: Prashanth Prakash To: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] cpuidle: Add new macro to enter a retention idle state Date: Tue, 7 Nov 2017 10:35:32 -0700 Message-Id: <1510076133-18139-2-git-send-email-pprakash@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1510076133-18139-1-git-send-email-pprakash@codeaurora.org> References: <1510076133-18139-1-git-send-email-pprakash@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171107_093621_636077_0D8CED76 X-CRM114-Status: GOOD ( 13.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sudeep.holla@arm.com, Prashanth Prakash , rjw@rjwysocki.net, daniel.lezcano@linaro.org, will.deacon@arm.com, catalin.marinas@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If a CPU is entering a low power idle state where it doesn't lose any context, then there is no need to call cpu_pm_enter()/cpu_pm_exit(). Add a new macro(CPU_PM_CPU_IDLE_ENTER_RETENTION) to be used by cpuidle drivers when they are entering retention state. By not calling cpu_pm_enter and cpu_pm_exit we reduce the latency involved in entering and exiting the retention idle states. On ARM64 based Qualcomm Server Platform we measured below overhead for for calling cpu_pm_enter and cpu_pm_exit for retention states. workload: stress --hdd #CPUs --hdd-bytes 32M -t 30 Average overhead of cpu_pm_enter - 1.2us Average overhead of cpu_pm_exit - 3.1us Signed-off-by: Prashanth Prakash --- include/linux/cpuidle.h | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 8f7788d..54cbd9d 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -258,21 +258,29 @@ static inline int cpuidle_register_governor(struct cpuidle_governor *gov) #endif #define CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx) \ -({ \ - int __ret; \ - \ - if (!idx) { \ - cpu_do_idle(); \ - return idx; \ - } \ - \ - __ret = cpu_pm_enter(); \ - if (!__ret) { \ - __ret = low_level_idle_enter(idx); \ - cpu_pm_exit(); \ - } \ - \ - __ret ? -1 : idx; \ + __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, 0) + +#define CPU_PM_CPU_IDLE_ENTER_RETENTION(low_level_idle_enter, idx) \ + __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, 1) + +#define __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, is_retention) \ +({ \ + int __ret = 0; \ + \ + if (!idx) { \ + cpu_do_idle(); \ + return idx; \ + } \ + \ + if (!is_retention) \ + __ret = cpu_pm_enter(); \ + if (!__ret) { \ + __ret = low_level_idle_enter(idx); \ + if (!is_retention) \ + cpu_pm_exit(); \ + } \ + \ + __ret ? -1 : idx; \ }) #endif /* _LINUX_CPUIDLE_H */