{"id":805063,"url":"http://patchwork.ozlabs.org/api/1.2/patches/805063/?format=json","web_url":"http://patchwork.ozlabs.org/project/skiboot/patch/20170823153140.21183-1-svaidy@linux.vnet.ibm.com/","project":{"id":44,"url":"http://patchwork.ozlabs.org/api/1.2/projects/44/?format=json","name":"skiboot firmware development","link_name":"skiboot","list_id":"skiboot.lists.ozlabs.org","list_email":"skiboot@lists.ozlabs.org","web_url":"http://github.com/open-power/skiboot","scm_url":"http://github.com/open-power/skiboot","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170823153140.21183-1-svaidy@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-08-23T15:31:40","name":"[v2] slw: Modify the power9 stop0_lite latency & residency","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4252dae6e4b0d8bc887a900a5d8870a6b3e8e6a2","submitter":{"id":497,"url":"http://patchwork.ozlabs.org/api/1.2/people/497/?format=json","name":"Vaidyanathan Srinivasan","email":"svaidy@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/skiboot/patch/20170823153140.21183-1-svaidy@linux.vnet.ibm.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/805063/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/805063/checks/","tags":{},"related":[],"headers":{"Return-Path":"<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","skiboot@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","skiboot@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xcs186Xs2z9s3T\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 24 Aug 2017 01:34:36 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xcs185dBNzDrJg\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 24 Aug 2017 01:34:36 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n\t[148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xcry657nBzDrJr\n\tfor <skiboot@lists.ozlabs.org>; Thu, 24 Aug 2017 01:31:58 +1000 (AEST)","from pps.filterd (m0098396.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7NFVkVc083012\n\tfor <skiboot@lists.ozlabs.org>; Wed, 23 Aug 2017 11:31:56 -0400","from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2chbd93ss3-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <skiboot@lists.ozlabs.org>; Wed, 23 Aug 2017 11:31:56 -0400","from localhost\n\tby e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <skiboot@lists.ozlabs.org> from <svaidy@linux.vnet.ibm.com>;\n\tThu, 24 Aug 2017 01:31:53 +1000","from d23relay06.au.ibm.com (202.81.31.225)\n\tby e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tThu, 24 Aug 2017 01:31:52 +1000","from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138])\n\tby d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv7NFVpY742139776\n\tfor <skiboot@lists.ozlabs.org>; Thu, 24 Aug 2017 01:31:51 +1000","from d23av02.au.ibm.com (localhost [127.0.0.1])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv7NFVgL9002030\n\tfor <skiboot@lists.ozlabs.org>; Thu, 24 Aug 2017 01:31:42 +1000","from drishya.in.ibm.com ([9.85.69.117])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv7NFVc1Z001872; Thu, 24 Aug 2017 01:31:40 +1000"],"From":"Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>","To":"Michael Neuling <mikey@neuling.org>, Anton Blanchard <anton@samba.org>","Date":"Wed, 23 Aug 2017 21:01:40 +0530","X-Mailer":"git-send-email 2.9.5","X-TM-AS-MML":"disable","x-cbid":"17082315-0012-0000-0000-0000025A5552","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17082315-0013-0000-0000-000007760CEE","Message-Id":"<20170823153140.21183-1-svaidy@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-23_06:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708230233","Subject":"[Skiboot] [PATCH v2] slw: Modify the power9 stop0_lite latency &\n\tresidency","X-BeenThere":"skiboot@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Mailing list for skiboot development <skiboot.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/skiboot/>","List-Post":"<mailto:skiboot@lists.ozlabs.org>","List-Help":"<mailto:skiboot-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=subscribe>","Cc":"skiboot@lists.ozlabs.org, \"Gautham R. Shenoy\" <ego@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"Skiboot\"\n\t<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"},"content":"From: \"Gautham R. Shenoy\" <ego@linux.vnet.ibm.com>\n\nCurrently skiboot exposes the exit-latency for stop0_lite as 200ns and\nthe target-residency to be 2us.\n\nHowever, the kernel cpu-idle infrastructure rounds up the latency to\nmicroseconds and lists the stop0_lite latency as 0us, putting it on\npar with snooze state. As a result, when the predicted latency is\nsmall (< 1us), cpuidle will select stop0_lite instead of snooze. The\ndifference between these states is that snooze doesn't require an\ninterrupt to exit from the state, but stop0_lite does. And the value\n200ns doesn't include the interrupt latency.\n\nThis shows up in the context_switch2 benchmark\n(http://ozlabs.org/~anton/junkcode/context_switch2.c) where the number\nof context switches per second with the stop0_lite disabled is found\nto be roughly 30% more than with stop0_lite enabled.","diff":"===============================================================================\nx latency_200ns_residency_2us\n+ latency_200ns_residency_2us_stop0_lite_disabled\n    N           Min           Max        Median           Avg        Stddev\nx 100        222784        473466        294510     302295.26       45380.6\n+ 100        205316        609420        385198     396338.72     78135.648\nDifference at 99.0% confidence\n\t94043.5 +/- 23276.2\n\t31.1098% +/- 7.69983%\n\t(Student's t, pooled s = 63892.8)\n===============================================================================\n\nThis can be correlated with the number of times cpuidle enters\nstop0_lite compared to snooze.\n===================================================================\nlatency=200ns, residency=2us\n   stop0_lite enabled.\n\t* snooze usage      = 7\n\t* stop0 lite usage  = 3200324\n\t* stop1 lite usage  = 6\n stop0_lite disabled\n\t* snooze usage: 287846\n\t* stop0_lite usage: 0\n\t* stop1_lite usage: 0\n==================================================================\n\nHence, bump up the exit latency of stop0_lite to 1us. Since the target\nresidency is chosen to be 10 times the exit latency, set the target\nresidency to 10us.\n\nWith these values, we see a 50% improvement in the number of context\nswitches:\n=====================================================================\nx latency_200ns_residency_2us\n+ latency_1us_residency_10us\n    N           Min           Max        Median           Avg        Stddev\nx 100        222784        473466        294510     302295.26       45380.6\n+ 100        281790        710784        514878     510224.62     85163.252\nDifference at 99.0% confidence\n\t207929 +/- 24858.3\n\t68.7835% +/- 8.22319%\n\t(Student's t, pooled s = 68235.5)\n=====================================================================\n\nThe cpuidle usage statistics show that we choose stop0_lite less often\nin such cases.\n\nlatency = 1us, residency = 10us\n    stop0_lite enabled\n\t* snooze usage      = 536808\n\t* stop0 lite usage  = 3\n\t* stop1 lite usage  = 7\n\nReported-by: Anton Blanchard <anton@samba.org>\nSigned-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>\nSigned-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>\n---\n \n Changes from v1:\n [PATCH] power9-dd1:slw: Modify the stop0_lite latency & residency\n https://lists.ozlabs.org/pipermail/skiboot/2017-April/007011.html\n\n Update latency to atleast 1us for both DD1 and DD2 idle states.\n\n --Vaidy\n\n hw/slw.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/hw/slw.c b/hw/slw.c\nindex c0ab9de..98040e6 100644\n--- a/hw/slw.c\n+++ b/hw/slw.c\n@@ -508,8 +508,8 @@ static struct cpu_idle_states power8_cpu_idle_states[] = {\n static struct cpu_idle_states power9_cpu_idle_states[] = {\n \t{\n \t\t.name = \"stop0_lite\", /* Enter stop0 with no state loss */\n-\t\t.latency_ns = 200,\n-\t\t.residency_ns = 2000,\n+\t\t.latency_ns = 1000,\n+\t\t.residency_ns = 10000,\n \t\t.flags = 0*OPAL_PM_DEC_STOP \\\n \t\t       | 0*OPAL_PM_TIMEBASE_STOP  \\\n \t\t       | 0*OPAL_PM_LOSE_USER_CONTEXT \\\n@@ -522,8 +522,8 @@ static struct cpu_idle_states power9_cpu_idle_states[] = {\n \t\t.pm_ctrl_reg_mask = OPAL_PM_PSSCR_MASK },\n \t{\n \t\t.name = \"stop0\",\n-\t\t.latency_ns = 300,\n-\t\t.residency_ns = 3000,\n+\t\t.latency_ns = 2000,\n+\t\t.residency_ns = 20000,\n \t\t.flags = 0*OPAL_PM_DEC_STOP \\\n \t\t       | 0*OPAL_PM_TIMEBASE_STOP  \\\n \t\t       | 0*OPAL_PM_LOSE_USER_CONTEXT \\\n@@ -653,8 +653,8 @@ static struct cpu_idle_states power9_cpu_idle_states[] = {\n static struct cpu_idle_states power9_ndd1_cpu_idle_states[] = {\n \t{\n \t\t.name = \"stop0_lite\",\n-\t\t.latency_ns = 200,\n-\t\t.residency_ns = 2000,\n+\t\t.latency_ns = 1000,\n+\t\t.residency_ns = 10000,\n \t\t.flags = 0*OPAL_PM_DEC_STOP \\\n \t\t       | 0*OPAL_PM_TIMEBASE_STOP  \\\n \t\t       | 0*OPAL_PM_LOSE_USER_CONTEXT \\\n","prefixes":["v2"]}