Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4686083ybl; Mon, 3 Feb 2020 23:54:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyXLvsCisxQGPRxG3MSANo8MDj2lDYDc+JpwepZOZV6Fv9V8ejzPHR4MZVGF3tuTSmfWoxp X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr20316691otp.137.1580802851610; Mon, 03 Feb 2020 23:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580802851; cv=none; d=google.com; s=arc-20160816; b=ZCs30IuAYwy8YXDJbr3MgoA8aj0QKcrEDRjQfmmmG5o4gqakpBUwYyOiTIBbGLMLXm NexFKNHMaB1FM0fm6mcwFA6ap5b3CLOF8GXi+h9hECE9/1qgUZCk4BPpvmzyCnQasl5z MITGuVouE93/tE7AyS86ycR7x3OXG1C8HGz+HWBzWVMb22JB21QNVCjDuY3q3Ide2apQ cxDjwvuawACm8YMzQKLiv8XdX9H96VW9di5pFlBPr4YX2aaJSJ+lgolc1Pl6WRW94sQQ CIxf6/MbfafTnB5w2Ab/IcXXTiqaO8ztKiT7T4k36t3PCbsDBjgFDIoPuAa0Csq6WP6Y rTRQ== 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=1oFp9M/A60EZDOP0j02ep0i6+AhPgLjzUVArfoHN+M0=; b=uTbp6fLOwog6JzFFtlePysl4mt/qgA+CuVAENf5Ay+aPXkgZQ1TV+9Q0C9MQhY2WdE WV2owVNlhbmNu6jKuL5aOTCbDrR2qZPqaJ87wwPZKzS5Q85na8rzgHE+JRln7YeG2hXL QYZY++yOn9dDtJtXYC/06OcsSqEZQvHi7mVvm9Bh1f4KY9ECcKChqYal+M9VNOLGeX5I Ewk4LHdO4UZ6MSVghhLlexrwwiJV/OKQIt6HEUCEpCH+ZxkUBdxIHJpY3WXrPLYfvjXO OCXu55waFno1BcUrvY9BHtuyKfBCHhGxCE4+56vOv5dcKfdLOVd0Jf2oCe3QNvTH4OXW umgw== 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 e13si10956958otr.167.2020.02.03.23.53.59; Mon, 03 Feb 2020 23:54:11 -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 S1726883AbgBDHw3 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 4 Feb 2020 02:52:29 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43828 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgBDHw3 (ORCPT ); Tue, 4 Feb 2020 02:52:29 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0147pmEm130460 for ; Tue, 4 Feb 2020 02:52:28 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxy9hrxku-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Feb 2020 02:52:28 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Feb 2020 07:52:26 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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, 4 Feb 2020 07:52:23 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0147qLFh40960210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Feb 2020 07:52:21 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E5C242049; Tue, 4 Feb 2020 07:52:21 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D45842041; Tue, 4 Feb 2020 07:52:21 +0000 (GMT) Received: from localhost (unknown [9.199.60.222]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 4 Feb 2020 07:52:20 +0000 (GMT) Date: Tue, 04 Feb 2020 13:22:19 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH 2/3] powerpc/sysfs: Show idle_purr and idle_spurr for every CPU To: ego@linux.vnet.ibm.com Cc: Kamalesh Babulal , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Nathan Lynch , Vaidyanathan Srinivasan , Tyrel Datwyler References: <1574856072-30972-1-git-send-email-ego@linux.vnet.ibm.com> <1574856072-30972-3-git-send-email-ego@linux.vnet.ibm.com> <1575564547.si4rk0s96p.naveen@linux.ibm.com> <20200203045013.GC13468@in.ibm.com> In-Reply-To: <20200203045013.GC13468@in.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: 20020407-0008-0000-0000-0000034F8587 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020407-0009-0000-0000-00004A70116E Message-Id: <1580802180.jpxk9s8apz.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-04_01:2020-02-04,2020-02-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 mlxscore=0 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=898 bulkscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2002040057 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gautham R Shenoy wrote: > Hi Naveen, > > On Thu, Dec 05, 2019 at 10:23:58PM +0530, Naveen N. Rao wrote: >> >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? > > Yes, if the CPU whose idle_spurr cycle is being read is still in idle, > then we will miss reporting the delta spurr cycles for this last > idle-duration. Yes, we can use an smp_call_function_single(), though > that will introduce IPI noise. How often will idle_[s]purr be read ? Since it is possible for a cpu to go into extended cede for multiple seconds during which time it is possible to mis-report utilization, I think it is better to ensure that the sysfs interface for idle_[s]purr report the proper values through use of IPI. With repect to lparstat, the read interval is user-specified and just gets passed onto sleep(). - Naveen