Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1911712ybl; Thu, 5 Dec 2019 08:56:08 -0800 (PST) X-Google-Smtp-Source: APXvYqw3pcxk3Q4LgMZMMcYey/4bmuJHTTah+UrGPz9507UMOUe2p8DuJd6/SYeccUrkfCB8g3U+ X-Received: by 2002:a9d:6c06:: with SMTP id f6mr6894093otq.318.1575564968684; Thu, 05 Dec 2019 08:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575564968; cv=none; d=google.com; s=arc-20160816; b=VC90FzcOfVM4nX+w5zRZIQmBYvxpk/iyljMe2rz2fEEBHVdqPlmooTowL1bL0Or4Di xlH89dxIT+VPc1cdiiKZRrQ9KM8pvlpcYfzNroWx/9Y6xFaz8rSTFDOq0jR+892bEmnG gT5iA6+xDOjGFNlLSvrutxoCJKsAre1w/fAwcFNvn+YAz8Qqskc0JPk93rMHsSDtoS1K accjVFD4Uih5mW0tBXUx0iBEJuSPLvkVCeVy/bGkBUMJEpLJAqZNTs2FBKxD6RcyIpqL zm2nNSTecNwUwhWIOxeON2d0WANyuV6YhQt4DH5d+hgubZdGYa63XB9okB5MIN0Ig7ce 6TiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date; bh=iebahlrBi2d1qP7OGwA2HIFHlYuiZZzWXMakm7I78vc=; b=JCBoYBONVTnT2YEJoJ4/37S7CUhQNTdfUTnGYszFBWIfFQq2Di44uYyOPtmygj6lHN YGgAwAE6EbgtkR4CqDSUOvGLWDt+2/YW9KK3GT0VJDCL0rxijavrlp0RTAxo5BaujZIg pQCvibLLIfht1z1q5dVBfTZYJdDqxwMPLCBS1z3O3x8GJ2I8GIJlFutrBloR16b8MucF cziIngd27GKhGwJUp/nMKtn9phcc1pzQoZPH5BOzT14r14PVcgSiys4LsJZRqo4G5MMY te6buqcbvbN1ghZjNHaKY0OAxbDDRZRnb+YHRmITjS/tB8YhTk5ZTM9kKYfMCJLo38sB jlxA== 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 q22si5683398otm.304.2019.12.05.08.55.54; Thu, 05 Dec 2019 08:56:08 -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 S1729598AbfLEQyH convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Dec 2019 11:54:07 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18134 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbfLEQyH (ORCPT ); Thu, 5 Dec 2019 11:54:07 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xB5GnOOQ120566 for ; Thu, 5 Dec 2019 11:54:06 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wq55sa6su-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Dec 2019 11:54:05 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Dec 2019 16:54:03 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Dec 2019 16:54:02 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xB5GrJng46662034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Dec 2019 16:53:19 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F8664C052; Thu, 5 Dec 2019 16:54:00 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 107F14C044; Thu, 5 Dec 2019 16:54:00 +0000 (GMT) Received: from localhost (unknown [9.199.48.150]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Dec 2019 16:53:59 +0000 (GMT) Date: Thu, 05 Dec 2019 22:23:58 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH 2/3] powerpc/sysfs: Show idle_purr and idle_spurr for every CPU To: "Gautham R. Shenoy" , Kamalesh Babulal , Michael Ellerman , Nathan Lynch , Vaidyanathan Srinivasan , Tyrel Datwyler Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <1574856072-30972-1-git-send-email-ego@linux.vnet.ibm.com> <1574856072-30972-3-git-send-email-ego@linux.vnet.ibm.com> In-Reply-To: <1574856072-30972-3-git-send-email-ego@linux.vnet.ibm.com> MIME-Version: 1.0 User-Agent: astroid/v0.15-13-gb675b421 (https://github.com/astroidmail/astroid) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 19120516-0008-0000-0000-0000033DB5EB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120516-0009-0000-0000-00004A5CDA0B Message-Id: <1575564547.si4rk0s96p.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-05_05:2019-12-04,2019-12-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 phishscore=0 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 clxscore=1011 mlxlogscore=921 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912050141 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gautham R. Shenoy wrote: > 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. > > The total PURR and SPURR ticks are already exposed via the per-cpu > sysfs files /sys/devices/system/cpu/cpuX/purr and > /sys/devices/system/cpu/cpuX/spurr. > > This patch adds support for exposing the idle PURR and SPURR ticks via > /sys/devices/system/cpu/cpuX/idle_purr and > /sys/devices/system/cpu/cpuX/idle_spurr. > > Signed-off-by: Gautham R. Shenoy > --- > arch/powerpc/kernel/sysfs.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c > index 80a676d..42ade55 100644 > --- a/arch/powerpc/kernel/sysfs.c > +++ b/arch/powerpc/kernel/sysfs.c > @@ -1044,6 +1044,36 @@ static ssize_t show_physical_id(struct device *dev, > } > static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL); > > +static ssize_t idle_purr_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct cpu *cpu = container_of(dev, struct cpu, dev); > + unsigned int cpuid = cpu->dev.id; > + struct lppaca *cpu_lppaca_ptr = paca_ptrs[cpuid]->lppaca_ptr; > + u64 idle_purr_cycles = be64_to_cpu(cpu_lppaca_ptr->wait_state_cycles); > + > + return sprintf(buf, "%llx\n", idle_purr_cycles); > +} > +static DEVICE_ATTR_RO(idle_purr); > + > +DECLARE_PER_CPU(u64, idle_spurr_cycles); > +static ssize_t idle_spurr_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct cpu *cpu = container_of(dev, struct cpu, dev); > + unsigned int cpuid = cpu->dev.id; > + u64 *idle_spurr_cycles_ptr = per_cpu_ptr(&idle_spurr_cycles, cpuid); Is it possible for a user to read stale values if a particular cpu is in an extended cede? Is it possible to use smp_call_function_single() to force the cpu out of idle? - Naveen