From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0387C43331 for ; Tue, 31 Mar 2020 12:25:07 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CFEB20838 for ; Tue, 31 Mar 2020 12:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CFEB20838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48s7nX5vRgzDrCP for ; Tue, 31 Mar 2020 23:25:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=ego@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48s7Tm363HzDqsD for ; Tue, 31 Mar 2020 23:11:23 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02VC3jjL031124; Tue, 31 Mar 2020 08:11:17 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 303uj37ff1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Mar 2020 08:11:17 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02VC3xlw032316; Tue, 31 Mar 2020 08:11:16 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com with ESMTP id 303uj37feh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Mar 2020 08:11:16 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02VCAMqQ005821; Tue, 31 Mar 2020 12:11:15 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma01dal.us.ibm.com with ESMTP id 301x776t70-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Mar 2020 12:11:15 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02VCBFxG38601170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Mar 2020 12:11:15 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FC12112063; Tue, 31 Mar 2020 12:11:15 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD133112061; Tue, 31 Mar 2020 12:11:14 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.85.71.250]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 31 Mar 2020 12:11:14 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id A64672E3B08; Tue, 31 Mar 2020 17:41:10 +0530 (IST) From: "Gautham R. Shenoy" To: Paul Mackerras , Michael Neuling , Nicholas Piggin , Michael Ellerman , David Gibson , Vaidyanathan Srinivasan , Bharata B Rao Subject: [RFC/PATCH 3/3] cpuidle/pseries: Add stop0lite state Date: Tue, 31 Mar 2020 17:40:58 +0530 Message-Id: <1585656658-1838-4-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585656658-1838-1-git-send-email-ego@linux.vnet.ibm.com> References: <1585656658-1838-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.138, 18.0.676 definitions=2020-03-31_04:2020-03-31, 2020-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 impostorscore=0 adultscore=0 mlxlogscore=746 lowpriorityscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 phishscore=0 clxscore=1011 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310106 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@ozlabs.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, "Gautham R. Shenoy" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: "Gautham R. Shenoy" The POWER ISA v3.0 allows stop instruction to be executed from a HV=0,PR=0 context. If the PSSCR[ESL|EC] bits are cleared, then the stop instruction thus executed will cause the thread to pause, thereby donating its cycles to the other threads in the core until the paused thread is woken up by an interrupt. In this patch we define a cpuidle state for pseries guests named stop0lite. This has a latency and residency intermediate to that of snooze and CEDE. While snooze has non-existent latency, it consumes the CPU cycles without contributing to anything useful. CEDE on the other hand requires a full VM exit, which can result in some other vCPU being scheduled on this physical CPU thereby delaying the scheduling of the CEDEd vCPU back. In such cases, when the expected idle duration is small (1-20us), the vCPU can go to this stop0lite state which provides a nice intermediate state between snooze and CEDE. Signed-off-by: Gautham R. Shenoy --- drivers/cpuidle/cpuidle-pseries.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 74c2479..9c8c18d 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -20,6 +20,7 @@ #include #include #include +#include struct cpuidle_driver pseries_idle_driver = { .name = "pseries_idle", @@ -170,6 +171,26 @@ static int shared_cede_loop(struct cpuidle_device *dev, .enter = &dedicated_cede_loop }, }; + + +static int stop_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) +{ + unsigned long srr1 = 0; + + if (!prep_irq_for_idle_irqsoff()) + return index; + + __ppc64_runlatch_off(); + asm volatile("stop"); + __ppc64_runlatch_on(); + fini_irq_for_idle_irqsoff(); + irq_set_pending_from_srr1(srr1); + + return index; +} + /* * States for shared partition case. */ @@ -180,6 +201,12 @@ static int shared_cede_loop(struct cpuidle_device *dev, .exit_latency = 0, .target_residency = 0, .enter = &snooze_loop }, + { /* stop0_lite */ + .name = "stop0lite", + .desc = "Pauses the CPU", + .exit_latency = 2, + .target_residency=20, + .enter = &stop_loop }, { /* Shared Cede */ .name = "Shared Cede", .desc = "Shared Cede", -- 1.9.4