Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp944986ybt; Tue, 7 Jul 2020 04:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV0Yixez1DPY0bAEOGwaTf8Yf0d9hOuDw1lVyCMFrtB5wPDvN532I7CWWeNGviaJHJ95fV X-Received: by 2002:a17:906:c187:: with SMTP id g7mr21776379ejz.108.1594120357218; Tue, 07 Jul 2020 04:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594120357; cv=none; d=google.com; s=arc-20160816; b=ZfTdTHFgOUVx58RgQnSbva44QCnFHDsoG6iPN2QcP9iXOPjsUL7MKd7rtnl+f9+Xv7 5lqwz54e1mCRGQQG4IxkQQotD22ahPqvhMtAPiJAa8suSfLeAAgbDlEGhFri53WRlsfq g1k9/UUquTa7Z5ibEr53OOMuH63CcSPRU0ShjUouodH8nM0/5n80FRxCaJF/aogWBFga su2I9vR5bXPRZDcxfDQTStbFlB7xxa/Ri3KHbxa6kKOWUj4+YMtRBVs+wVQRVzHnoKcc jBvuHTHmXh5mny3KQFEF0w+aKxxJbK4GOQ/5myt8AgOTl+5g0TAABN8kEWXVy/82BLXk ioSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=g5J88hDEY7CQD9m0p7oc0HF5euJxYOS/LD3hSYXM0CM=; b=mofW+DF2OxJtIV/Lsd8TS7VgYdUpi6u8FbQcxuis1GDruu7OywgIjfFazg+xE7TNrg SYPe1zg69zARjZdTrKdD2x/sLRHcTNkcPxo+tgsy6QfhquzCdMweMqkzS1c53qpsfXhG XV6f1/oixzdTcmShw/LKe5O1eMpL1T8fsL38eRIMcOUH6EhR/rja2SBR2zpy8kUfkj9L ikpeBIHpbwZLVVRqE+KM8GanEBtPhoOkUf6uyqBCwHN5JbxTcfDQQeqjEZTEgRPcSAt2 oY09W+aSmg5taA0f16l27yIVKPIPLpHYLJHRoXzkKzyopPwuU8ebinPTXg/Z2bGtGZOG tzbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh22si15078240ejb.85.2020.07.07.04.12.11; Tue, 07 Jul 2020 04:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgGGLMG (ORCPT + 99 others); Tue, 7 Jul 2020 07:12:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46050 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgGGLMF (ORCPT ); Tue, 7 Jul 2020 07:12:05 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 067B2i2C089251; Tue, 7 Jul 2020 07:12:01 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32482ks4dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 07:12:01 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 067B3Cxq092607; Tue, 7 Jul 2020 07:12:01 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 32482ks4cx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 07:12:01 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 067AxJYl027900; Tue, 7 Jul 2020 11:12:00 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 324aejecmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 11:12:00 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 067BBxxc49611132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2020 11:11:59 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7704B112062; Tue, 7 Jul 2020 11:11:59 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4603112061; Tue, 7 Jul 2020 11:11:58 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.85.70.202]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2020 11:11:58 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 8EAC92E48CB; Tue, 7 Jul 2020 16:41:54 +0530 (IST) From: "Gautham R. Shenoy" To: Nicholas Piggin , Anton Blanchard , Nathan Lynch , Michael Ellerman , Michael Neuling , Vaidyanathan Srinivasan Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Gautham R. Shenoy" Subject: [PATCH 4/5] cpuidle-pseries : Include extended CEDE states in cpuidle framework Date: Tue, 7 Jul 2020 16:41:38 +0530 Message-Id: <1594120299-31389-5-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594120299-31389-1-git-send-email-ego@linux.vnet.ibm.com> References: <1594120299-31389-1-git-send-email-ego@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-07_06:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 clxscore=1011 phishscore=0 suspectscore=0 cotscore=-2147483648 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007070081 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" This patch exposes those extended CEDE states to the cpuidle framework which are responsive to external interrupts and do not need an H_PROD. Since as per the PAPR, all the extended CEDE states are non-responsive to timers, we indicate this to the cpuidle subsystem via the CPUIDLE_FLAG_TIMER_STOP flag for all those extende CEDE states which can wake up on external interrupts. With the patch, we are able to see the extended CEDE state with latency hint = 1 exposed via the cpuidle framework. $ cpupower idle-info CPUidle driver: pseries_idle CPUidle governor: menu analyzing CPU 0: Number of idle states: 3 Available idle states: snooze CEDE XCEDE1 snooze: Flags/Description: snooze Latency: 0 Usage: 33429446 Duration: 27006062 CEDE: Flags/Description: CEDE Latency: 1 Usage: 10272 Duration: 110786770 XCEDE1: Flags/Description: XCEDE1 Latency: 12 Usage: 26445 Duration: 1436433815 Benchmark results: TLDR: Over all we do not see any additional benefit from having XCEDE1 over CEDE. ebizzy : 2 threads bound to a big-core. With this patch, we see a 3.39% regression compared to with only CEDE0 latency fixup. x With only CEDE0 latency fixup * With CEDE0 latency fixup + CEDE1 N Min Max Median Avg Stddev x 10 2893813 5834474 5832448 5327281.3 1055941.4 * 10 2907329 5834923 5831398 5146614.6 1193874.8 context_switch2: With the context_switch2 there are no observable regressions in the results. context_switch2 CPU0 CPU1 (Same Big-core, different small-cores). No difference with and without patch. x without_patch * with_patch N Min Max Median Avg Stddev x 500 343644 348778 345444 345584.02 1035.1658 * 500 344310 347646 345776 345877.22 802.19501 context_switch2 CPU0 CPU8 (different big-cores). Minor 0.05% improvement with patch x without_patch * with_patch N Min Max Median Avg Stddev x 500 287562 288756 288162 288134.76 262.24328 * 500 287874 288960 288306 288274.66 187.57034 schbench: No regressions observed with schbench Without Patch: Latency percentiles (usec) 50.0th: 29 75.0th: 40 90.0th: 50 95.0th: 61 *99.0th: 13648 99.5th: 14768 99.9th: 15664 min=0, max=29812 With Patch: Latency percentiles (usec) 50.0th: 30 75.0th: 40 90.0th: 51 95.0th: 59 *99.0th: 13616 99.5th: 14512 99.9th: 15696 min=0, max=15996 Signed-off-by: Gautham R. Shenoy --- drivers/cpuidle/cpuidle-pseries.c | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 502f906..6f893cd 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -362,9 +362,59 @@ static int add_pseries_idle_states(void) for (i = 0; i < nr_xcede_records; i++) { u64 latency_tb = xcede_records[i].wakeup_latency_tb_ticks; u64 latency_us = tb_to_ns(latency_tb) / NSEC_PER_USEC; + char name[CPUIDLE_NAME_LEN]; + unsigned int latency_hint = xcede_records[i].latency_hint; + u64 residency_us; + + if (!xcede_records[i].responsive_to_irqs) { + pr_info("cpuidle : Skipping XCEDE%d. Not responsive to IRQs\n", + latency_hint); + continue; + } if (latency_us < min_latency_us) min_latency_us = latency_us; + snprintf(name, CPUIDLE_NAME_LEN, "XCEDE%d", latency_hint); + + /* + * As per the section 14.14.1 of PAPR version 2.8.1 + * says that alling H_CEDE with the value of the cede + * latency specifier set greater than zero allows the + * processor timer facility to be disabled (so as not + * to cause gratuitous wake-ups - the use of H_PROD, + * or other external interrupt is required to wake the + * processor in this case). + * + * So, inform the cpuidle-subsystem that the timer + * will be stopped for these states. + * + * Also, bump up the latency by 10us, since cpuidle + * would use timer-offload framework which will need + * to send an IPI to wakeup a CPU whose timer has + * expired. + */ + if (latency_hint > 0) { + dedicated_states[nr_states].flags = CPUIDLE_FLAG_TIMER_STOP; + latency_us += 10; + } + + /* + * Thumb rule : Reside in the XCEDE state for at least + * 10x the time required to enter and exit that state. + */ + residency_us = latency_us * 10; + + strlcpy(dedicated_states[nr_states].name, (const char *)name, + CPUIDLE_NAME_LEN); + strlcpy(dedicated_states[nr_states].desc, (const char *)name, + CPUIDLE_NAME_LEN); + dedicated_states[nr_states].exit_latency = latency_us; + dedicated_states[nr_states].target_residency = residency_us; + dedicated_states[nr_states].enter = &dedicated_cede_loop; + cede_latency_hint[nr_states] = latency_hint; + pr_info("cpuidle : Added %s. latency-hint = %d\n", + name, latency_hint); + nr_states++; } /* -- 1.9.4