Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5435523ybc; Wed, 27 Nov 2019 04:05:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzrAPJBjE1TibHLOuNb5y6f50ItbWYHY8RbjhtYDjOGyT7CvheKB6sUoclrvMxU4waq6VTt X-Received: by 2002:a17:906:8258:: with SMTP id f24mr22666609ejx.308.1574856327813; Wed, 27 Nov 2019 04:05:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574856327; cv=none; d=google.com; s=arc-20160816; b=crsfhcaQ5pQZ1MaNQkZhv8s2uC2P5wNGkb5HysaUYM/O8B4FPovwKRgdhIqcpYoW5Z X46AcaS+eEDP+xGlQn/Q+feeQlzaRyBbrxTZej8AbMgg3nzIPlKKkk2zauEt5meAYyUH kWic/8SML9PrDr3VqI+DTejj4EIPxHIH/dE4E1EWaH3CRmpXtPhpRyL5HjYNhSXw5jBW pK/OOXOBYsvfZ75gkJPYz/t7B20MA+lpfY00MOlj9jwlAuf7hozWWaUKg7EIIlZlZ/u6 dbkYTsH4ZsgrAbcZkB6BGUiokKlnlHEgI3Qiw3w1KC5yyDa1tBpIMvsfHNkfkO2RXhrb D7GA== 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=0nQ7amcrV/UbNtfgkPCzhQWT4U8wTO78RqNVaob39Rc=; b=Pyi9il0AnxC6tr8dzQOm9MPwna6O/+i+q9FXRCCyohPwLREfyRwY12/IWqtDcod/Eq 4e+SYIRZ54nG/PLbEEepMjwBKSCveMzbkZXYL+JDgeWNVB6L5Lf/56oh89Mt6cahZZYN 1C2jg3oJX+eEvtvafviZD1POTrioC6a567HGvugj6ox63DartZXNGFN9CZnQFOhF4jJv r2LWXT3qNkIqOKQwGP7dTBBNyTQDQFqC68/SNf8jJDUBjofGi7uKIB7H2AQsj2z/H/Kb tTK3IX61blSqQZhE4QqIXHs1Toih1/W+qFV7gxxpLJMe/aJXGJXnkDwQfOefapK6tABb Qlew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d7si10598701eda.429.2019.11.27.04.05.04; Wed, 27 Nov 2019 04:05:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727008AbfK0MBw (ORCPT + 99 others); Wed, 27 Nov 2019 07:01:52 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:63844 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726984AbfK0MBv (ORCPT ); Wed, 27 Nov 2019 07:01:51 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARBrFJH135003; Wed, 27 Nov 2019 07:01:40 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 2whcy7pbv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Nov 2019 07:01:40 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xARC070S002618; Wed, 27 Nov 2019 12:01:40 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma02dal.us.ibm.com with ESMTP id 2wevd6we36-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Nov 2019 12:01:39 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARC1cbL30999034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 12:01:38 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 573F4C605D; Wed, 27 Nov 2019 12:01:38 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11B83C605B; Wed, 27 Nov 2019 12:01:38 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.124.35.209]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 12:01:38 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 6B1732E2ED5; Wed, 27 Nov 2019 17:31:35 +0530 (IST) From: "Gautham R. Shenoy" To: Michael Ellerman , Vaidyanathan Srinivasan , Nathan Lynch , Kamalesh Babulal , "Naveen N. Rao" , Tyrel Datwyler Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" Subject: [PATCH 1/3] powerpc/pseries: Account for SPURR ticks on idle CPUs Date: Wed, 27 Nov 2019 17:31:10 +0530 Message-Id: <1574856072-30972-2-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574856072-30972-1-git-send-email-ego@linux.vnet.ibm.com> References: <1574856072-30972-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.95,18.0.572 definitions=2019-11-27_02:2019-11-27,2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 adultscore=0 priorityscore=1501 phishscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270104 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" On PSeries LPARs, to compute the utilization, tools such as lparstat need to know the [S]PURR ticks when the CPUs were busy or idle. In the pseries cpuidle driver, we keep track of the idle PURR ticks in the VPA variable "wait_state_cycles". This patch extends the support to account for the idle SPURR ticks. Signed-off-by: Gautham R. Shenoy --- arch/powerpc/kernel/idle.c | 2 ++ drivers/cpuidle/cpuidle-pseries.c | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c index a36fd05..708ec68 100644 --- a/arch/powerpc/kernel/idle.c +++ b/arch/powerpc/kernel/idle.c @@ -33,6 +33,8 @@ unsigned long cpuidle_disable = IDLE_NO_OVERRIDE; EXPORT_SYMBOL(cpuidle_disable); +DEFINE_PER_CPU(u64, idle_spurr_cycles); + static int __init powersave_off(char *arg) { ppc_md.power_save = NULL; diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 74c2479..45e2be4 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -30,11 +30,14 @@ struct cpuidle_driver pseries_idle_driver = { static struct cpuidle_state *cpuidle_state_table __read_mostly; static u64 snooze_timeout __read_mostly; static bool snooze_timeout_en __read_mostly; +DECLARE_PER_CPU(u64, idle_spurr_cycles); -static inline void idle_loop_prolog(unsigned long *in_purr) +static inline void idle_loop_prolog(unsigned long *in_purr, + unsigned long *in_spurr) { ppc64_runlatch_off(); *in_purr = mfspr(SPRN_PURR); + *in_spurr = mfspr(SPRN_SPURR); /* * Indicate to the HV that we are idle. Now would be * a good time to find other work to dispatch. @@ -42,13 +45,16 @@ static inline void idle_loop_prolog(unsigned long *in_purr) get_lppaca()->idle = 1; } -static inline void idle_loop_epilog(unsigned long in_purr) +static inline void idle_loop_epilog(unsigned long in_purr, + unsigned long in_spurr) { u64 wait_cycles; + u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); wait_cycles += mfspr(SPRN_PURR) - in_purr; get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); + *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; get_lppaca()->idle = 0; ppc64_runlatch_on(); @@ -58,12 +64,12 @@ static int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - unsigned long in_purr; + unsigned long in_purr, in_spurr; u64 snooze_exit_time; set_thread_flag(TIF_POLLING_NRFLAG); - idle_loop_prolog(&in_purr); + idle_loop_prolog(&in_purr, &in_spurr); local_irq_enable(); snooze_exit_time = get_tb() + snooze_timeout; @@ -87,7 +93,7 @@ static int snooze_loop(struct cpuidle_device *dev, local_irq_disable(); - idle_loop_epilog(in_purr); + idle_loop_epilog(in_purr, in_spurr); return index; } @@ -113,9 +119,9 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - unsigned long in_purr; + unsigned long in_purr, in_spurr; - idle_loop_prolog(&in_purr); + idle_loop_prolog(&in_purr, &in_spurr); get_lppaca()->donate_dedicated_cpu = 1; HMT_medium(); @@ -124,7 +130,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, local_irq_disable(); get_lppaca()->donate_dedicated_cpu = 0; - idle_loop_epilog(in_purr); + idle_loop_epilog(in_purr, in_spurr); return index; } @@ -133,9 +139,9 @@ static int shared_cede_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - unsigned long in_purr; + unsigned long in_purr, in_spurr; - idle_loop_prolog(&in_purr); + idle_loop_prolog(&in_purr, &in_spurr); /* * Yield the processor to the hypervisor. We return if @@ -147,7 +153,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, check_and_cede_processor(); local_irq_disable(); - idle_loop_epilog(in_purr); + idle_loop_epilog(in_purr, in_spurr); return index; } -- 1.9.4