Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4158202ybb; Tue, 7 Apr 2020 01:48:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKPn2COmsM3qI1XJMxdh0gBmXmPMyEbvzmWW7LK7Nrlan1B4tZftKJ8bT41Iw4n6LHm3pAs X-Received: by 2002:a05:6808:253:: with SMTP id m19mr886469oie.107.1586249338488; Tue, 07 Apr 2020 01:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586249338; cv=none; d=google.com; s=arc-20160816; b=EygPkpS2eAp/xhS5WSvt6Bogntv6w5CaTh1gl+oVuR2wtzNallizX2dMzHSgOcolz1 SArES01rogRSEynM4wTF6aK74tumEPKkVyLnJjLjrF8IjnYnrZ4znWWDbZzTh1no0wTX v+Pz0exhYCg7WMQMyTv7xJHd2/R/CbpdKi6G8pOm2ikGf46m9Artczo9rfMREI27aiZq XzDnUKcA+WzPX3Zm394q5MWXF0uBcfxR2K5cQqjAZsGIOhPvTHCWj3/FLF/9PaXQyVW5 0P5ekVjtRSkFlh44qr7csmV2O+WA0r1rJ+czlS9Gu8en88Ld21R2pv6sOV0bxcqBm+sN axfg== 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=OewfWRND+NX43oxXSC9/Y0wJdHANCMpJZ8CJSlBxCZY=; b=u8RwseBTmkGhzI0u4ALgn+Ut1VD0OL8qXxQL+XLsr/wegJDg1xzZx+cy+lBhRS1bzO sjSStBubM4HmF/JzJ9igv7NDTRw7dDZYlQyaB+wp6NJDZB90ojg1UgxWLenlnd7j7+IX rqIFQLPIp7r0PI0GULfj2JK9bmexwQEKdQdauwto9H+etHggouLXUUf6wRCHlc3+1xuh e2v38d9xkQVrkw4nd9Nb1DC1UeBNoV/gz4f76mPaABpAIcime+8O54zWK1OIirvvNboG xXudOTJegyam+7ot1K9RjL6YdLEzx/YBEiXGGqi/dxZCJe1djXUpXhygZxFmtUBTM9hx Ntgw== 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 m26si1116839otj.109.2020.04.07.01.48.46; Tue, 07 Apr 2020 01:48:58 -0700 (PDT) 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 S1728029AbgDGIsO (ORCPT + 99 others); Tue, 7 Apr 2020 04:48:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:29070 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgDGIsN (ORCPT ); Tue, 7 Apr 2020 04:48:13 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0378XpYi016857; Tue, 7 Apr 2020 04:48:05 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 306nvvjkgj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Apr 2020 04:48:05 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0378g4xX032477; Tue, 7 Apr 2020 08:48:03 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 306hv66pt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Apr 2020 08:48:03 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0378m3ON54395362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Apr 2020 08:48:03 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B9D6AC05E; Tue, 7 Apr 2020 08:48:03 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC452AC059; Tue, 7 Apr 2020 08:48:02 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.79.178.96]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 7 Apr 2020 08:48:02 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 146482E3349; Tue, 7 Apr 2020 14:17:59 +0530 (IST) From: "Gautham R. Shenoy" To: Nathan Lynch , Michael Ellerman , Vaidyanathan Srinivasan , Kamalesh Babulal , "Naveen N. Rao" , Tyrel Datwyler Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" Subject: [PATCH v5 3/5] powerpc/pseries: Account for SPURR ticks on idle CPUs Date: Tue, 7 Apr 2020 14:17:41 +0530 Message-Id: <1586249263-14048-4-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1586249263-14048-1-git-send-email-ego@linux.vnet.ibm.com> References: <1586249263-14048-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-04-07_01:2020-04-07,2020-04-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 mlxscore=0 priorityscore=1501 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004070068 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 calculate utilization, we need to know the [S]PURR ticks when the CPUs were busy or idle. Via pseries_idle_prolog(), pseries_idle_epilog(), we track 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/include/asm/idle.h | 17 +++++++++++++++++ arch/powerpc/platforms/pseries/setup.c | 2 ++ 2 files changed, 19 insertions(+) diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h index b90d75a..0efb250 100644 --- a/arch/powerpc/include/asm/idle.h +++ b/arch/powerpc/include/asm/idle.h @@ -5,13 +5,20 @@ #include #ifdef CONFIG_PPC_PSERIES +DECLARE_PER_CPU(u64, idle_spurr_cycles); DECLARE_PER_CPU(u64, idle_entry_purr_snap); +DECLARE_PER_CPU(u64, idle_entry_spurr_snap); static inline void snapshot_purr_idle_entry(void) { *this_cpu_ptr(&idle_entry_purr_snap) = mfspr(SPRN_PURR); } +static inline void snapshot_spurr_idle_entry(void) +{ + *this_cpu_ptr(&idle_entry_spurr_snap) = mfspr(SPRN_SPURR); +} + static inline void update_idle_purr_accounting(void) { u64 wait_cycles; @@ -22,10 +29,19 @@ static inline void update_idle_purr_accounting(void) get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); } +static inline void update_idle_spurr_accounting(void) +{ + u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); + u64 in_spurr = *this_cpu_ptr(&idle_entry_spurr_snap); + + *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; +} + static inline void pseries_idle_prolog(void) { ppc64_runlatch_off(); snapshot_purr_idle_entry(); + snapshot_spurr_idle_entry(); /* * Indicate to the HV that we are idle. Now would be * a good time to find other work to dispatch. @@ -36,6 +52,7 @@ static inline void pseries_idle_prolog(void) static inline void pseries_idle_epilog(void) { update_idle_purr_accounting(); + update_idle_spurr_accounting(); get_lppaca()->idle = 0; ppc64_runlatch_on(); } diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 4905c96..1b55e80 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -318,7 +318,9 @@ static int alloc_dispatch_log_kmem_cache(void) } machine_early_initcall(pseries, alloc_dispatch_log_kmem_cache); +DEFINE_PER_CPU(u64, idle_spurr_cycles); DEFINE_PER_CPU(u64, idle_entry_purr_snap); +DEFINE_PER_CPU(u64, idle_entry_spurr_snap); static void pseries_lpar_idle(void) { /* -- 1.9.4