From patchwork Wed Jan 21 11:19:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Preeti U Murthy X-Patchwork-Id: 431637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D99DD14029E for ; Thu, 22 Jan 2015 10:59:43 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id C96DD1A0DDC for ; Thu, 22 Jan 2015 10:59:43 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 86CE11A0D0D for ; Wed, 21 Jan 2015 22:19:28 +1100 (AEDT) Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Jan 2015 04:19:26 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Jan 2015 04:19:24 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 402CF19D803F for ; Wed, 21 Jan 2015 04:10:35 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0LBI62c30081240 for ; Wed, 21 Jan 2015 04:18:06 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0LBJNMT006856 for ; Wed, 21 Jan 2015 04:19:23 -0700 Received: from preeti.in.ibm.com ([9.79.180.66]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t0LBJB9Q006301; Wed, 21 Jan 2015 04:19:20 -0700 From: Preeti U Murthy To: skiboot@lists.ozlabs.org Date: Wed, 21 Jan 2015 16:49:11 +0530 Message-ID: <20150121111316.15405.3332.stgit@preeti.in.ibm.com> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15012111-0017-0000-0000-0000081BE6B1 X-Mailman-Approved-At: Thu, 22 Jan 2015 10:59:41 +1100 Cc: sapphire@lists.linux.ibm.com, svaidy@linux.vnet.ibm.com Subject: [Skiboot] [PATCH V2] cpuidle: Add validated metrics for idle states X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The idle states are characterized by latency and residency numbers which determine the breakeven point for entry into them. The latency is a measure of the exit overhead from the idle state and residency is the minimum amount of time that a CPU must be predicted to be idle so as to reap the powersavings from entering into that idle state. These numbers are made use of by the cpuidle governors in the kernel to arrive at the appropriate idle state that a CPU must enter into when there is no work to be done. Today the kernel uses the latency numbers given by the firmware. To arrive at a value for residency, it uses a multiplier of 10 on the latency number. The latency number coded in the firmware is inaccurate as is the technique for calculating the residency. This patch codes in the the measured latency numbers for the idle states. The residency numbers have been arrived at experimentally after ensuring that the performance of latency sensitive workloads do not regress while allowing deeper idle states to be entered into during low load situations. The kernel is expected to use these values for optimal power efficiency. Signed-off-by: Preeti U Murthy --- Changes from V1: https://w3-01.ibm.com/stg/linux/ltc/mailinglists/pipermail/sapphire/2014-November/004353.html 1. Use the measured numbers for exit latency and tune only the target_residency for optimal power efficiency. 2. Expose both these numbers in the firmware. hw/slw.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/hw/slw.c b/hw/slw.c index b72a0aa..4ac0f1a 100644 --- a/hw/slw.c +++ b/hw/slw.c @@ -395,6 +395,7 @@ static bool idle_prepare_core(struct proc_chip *chip, struct cpu_thread *c) struct cpu_idle_states { char name[MAX_NAME_LEN]; u32 latency_ns; + u32 residency_ns; u32 flags; u64 pmicr; u64 pmicr_mask; @@ -427,7 +428,8 @@ struct cpu_idle_states { static struct cpu_idle_states power7_cpu_idle_states[] = { { /* nap */ .name = "nap", - .latency_ns = 1000, + .latency_ns = 10000, + .residency_ns = 100000, .flags = 0*IDLE_DEC_STOP \ | 0*IDLE_TB_STOP \ | 1*IDLE_LOSE_USER_CONTEXT \ @@ -444,7 +446,8 @@ static struct cpu_idle_states power7_cpu_idle_states[] = { static struct cpu_idle_states power8_cpu_idle_states[] = { { /* nap */ .name = "nap", - .latency_ns = 1000, + .latency_ns = 10000, + .residency_ns = 100000, .flags = 0*IDLE_DEC_STOP \ | 0*IDLE_TB_STOP \ | 1*IDLE_LOSE_USER_CONTEXT \ @@ -456,7 +459,8 @@ static struct cpu_idle_states power8_cpu_idle_states[] = { .pmicr_mask = 0 }, { /* fast sleep (with workaround) */ .name = "fastsleep_", - .latency_ns = 100000, + .latency_ns = 40000, + .residency_ns = 300000000, .flags = 1*IDLE_DEC_STOP \ | 1*IDLE_TB_STOP \ | 1*IDLE_LOSE_USER_CONTEXT \ @@ -470,6 +474,8 @@ static struct cpu_idle_states power8_cpu_idle_states[] = { { /* Winkle */ .name = "winkle", .latency_ns = 10000000, + .residency_ns = 1000000000, /* Placeholder only.Winkle is not used by + the cpuidle subsystem today */ .flags = 1*IDLE_DEC_STOP \ | 1*IDLE_TB_STOP \ | 1*IDLE_LOSE_USER_CONTEXT \ @@ -496,6 +502,7 @@ static void add_cpu_idle_state_properties(void) /* Buffers to hold idle state properties */ char *name_buf; u32 *latency_ns_buf; + u32 *residency_ns_buf; u32 *flags_buf; u64 *pmicr_buf; u64 *pmicr_mask_buf; @@ -571,6 +578,7 @@ static void add_cpu_idle_state_properties(void) /* Allocate memory to idle state property buffers. */ name_buf = (char *) malloc(nr_states * sizeof(char) * MAX_NAME_LEN); latency_ns_buf = (u32 *) malloc(nr_states * sizeof(u32)); + residency_ns_buf= (u32 *) malloc(nr_states * sizeof(u32)); flags_buf = (u32 *) malloc(nr_states * sizeof(u32)); pmicr_buf = (u64 *) malloc(nr_states * sizeof(u64)); pmicr_mask_buf = (u64 *) malloc(nr_states * sizeof(u64)); @@ -594,6 +602,9 @@ static void add_cpu_idle_state_properties(void) *latency_ns_buf = cpu_to_fdt32(states[i].latency_ns); latency_ns_buf++; + *residency_ns_buf = cpu_to_fdt32(states[i].residency_ns); + residency_ns_buf++; + *flags_buf = cpu_to_fdt32(states[i].flags); flags_buf++; @@ -612,6 +623,7 @@ static void add_cpu_idle_state_properties(void) /* Point buffer pointers back to beginning of the buffer */ name_buf -= name_buf_len; latency_ns_buf -= num_supported_idle_states; + residency_ns_buf -= num_supported_idle_states; flags_buf -= num_supported_idle_states; pmicr_buf -= num_supported_idle_states; pmicr_mask_buf -= num_supported_idle_states; @@ -621,6 +633,8 @@ static void add_cpu_idle_state_properties(void) name_buf_len* sizeof(char)); dt_add_property(power_mgt, "ibm,cpu-idle-state-latencies-ns", latency_ns_buf, num_supported_idle_states * sizeof(u32)); + dt_add_property(power_mgt, "ibm,cpu-idle-state-residency-ns", + residency_ns_buf, num_supported_idle_states * sizeof(u32)); dt_add_property(power_mgt, "ibm,cpu-idle-state-flags", flags_buf, num_supported_idle_states * sizeof(u32)); dt_add_property(power_mgt, "ibm,cpu-idle-state-pmicr", pmicr_buf, @@ -630,6 +644,7 @@ static void add_cpu_idle_state_properties(void) free(name_buf); free(latency_ns_buf); + free(residency_ns_buf); free(flags_buf); free(pmicr_buf); free(pmicr_mask_buf);