Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1334048ybl; Tue, 3 Dec 2019 05:39:08 -0800 (PST) X-Google-Smtp-Source: APXvYqy2QfvAjqmDjoK+P1dJzuT6UDZoKIxO1Y7BIwtO95BjpFPlHEd18F5cC1WZPIpmlJOMIOZ8 X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr3268891oto.30.1575380348207; Tue, 03 Dec 2019 05:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575380348; cv=none; d=google.com; s=arc-20160816; b=eyLMqiIX/FL0oB6Xc52MMADgzVHvOMT+owiZ13+r3iaM5g8ZdPUYU5MULMQB6k7IIg Xj+/HXaR4+y21uh22rTb/QS0Ia28Q+GNZBQofrhAKl44tyZF7tBbkLdUaIVLbCkMGHvw K7ybIYJJwIdsotkd60rW12pQxQh+aM7E7zv8FmfkR4rsMSUj3KEElI0JiFGzg3PwswxC NQid+cSoWx6208oaWInRpMRRNepAjk8pri9O6l23TaS7Cbx1ffFMSCcvy14cK10j4tpC VXD6t5eHV6lhmgnm9b3OJxxv5FNZoUkFQh7IKLWyEkqQ3LxG9a9gxlz4+SMM+jA4C0AX nNyg== 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 :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=k4u4esEOSnohle0DCwBOzeLKZug70xX70IcUUkD26WE=; b=Hlo1JoNL9ceRCqWhL13ZAY63HsM8Nc8eN1vZ0Jm4RXdJjZB6zJnuh+FDnPuPTgn2LH XoSTvVXrz41uNisJglIZRYdSjGp878uqR/dh6V15ykG15HH/Ni1eu8WBP5ktvGfl5rVI FmLKPe+f4ne42id60yT1O8oSkeH3K85GifJINtW3aTQ+JfQdnPHc38ZZ3dSIlEHtVvua c3oR2PSK5NwNDB/pUdw7MBm/nokE+stpmbGHpvUgg9FZKeeOKlgItsmTqVMBAHzpGmOM M7A2XL3OQIVQ7Tw1YFqmLn4MWXzsn2Vrt95zUOGxbvnNf1K71VPQuL/Ia7jaL6V/9TJ5 rtvg== 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 w5si1290461oia.239.2019.12.03.05.38.55; Tue, 03 Dec 2019 05:39: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 S1726115AbfLCNiF (ORCPT + 99 others); Tue, 3 Dec 2019 08:38:05 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:28016 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbfLCNiF (ORCPT ); Tue, 3 Dec 2019 08:38:05 -0500 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 xB3DbjGO141937 for ; Tue, 3 Dec 2019 08:38:04 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wnqm1kkjw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Dec 2019 08:38:04 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Dec 2019 13:38:02 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) 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) Tue, 3 Dec 2019 13:37:58 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xB3DbvqM27066668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Dec 2019 13:37:57 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39641A4065; Tue, 3 Dec 2019 13:37:57 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71B07A405F; Tue, 3 Dec 2019 13:37:55 +0000 (GMT) Received: from JAVRIS.in.ibm.com (unknown [9.85.70.93]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 3 Dec 2019 13:37:55 +0000 (GMT) Subject: Re: [PATCH 2/3] powerpc/sysfs: Show idle_purr and idle_spurr for every CPU To: "Gautham R. Shenoy" , Michael Ellerman , Vaidyanathan Srinivasan , Nathan Lynch , "Naveen N. Rao" , Tyrel Datwyler Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <1574856072-30972-1-git-send-email-ego@linux.vnet.ibm.com> <1574856072-30972-3-git-send-email-ego@linux.vnet.ibm.com> From: Kamalesh Babulal Date: Tue, 3 Dec 2019 19:07:53 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <1574856072-30972-3-git-send-email-ego@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19120313-0008-0000-0000-0000033C5B53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120313-0009-0000-0000-00004A5B7624 Message-Id: <9b8f82b0-86dd-d524-aae6-34f8c33bd2c2@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-03_03:2019-12-02,2019-12-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912030107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/27/19 5:31 PM, 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. The patch looks good to me, with a minor file mode nit pick mentioned below. > > 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); per cpu purr/spurr sysfs file is created with file mode 0400. Using DEVICE_ATTR_RO for their idle_* variants will create sysfs files with 0444 as their file mode, you should probably use DEVICE_ATTR() with file mode 0400 to have consist permission for both variants. -- Kamalesh