Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp352866ybv; Tue, 4 Feb 2020 23:09:53 -0800 (PST) X-Google-Smtp-Source: APXvYqx2cvnZioVzynEdh5FrTP42bjxLlmZcGnAq7M0/CeeODOJ1gvQTRrXdN/epe70ph5OGI1+C X-Received: by 2002:a9d:d06:: with SMTP id 6mr25460402oti.176.1580886593342; Tue, 04 Feb 2020 23:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580886593; cv=none; d=google.com; s=arc-20160816; b=esJqI5GuieDe9FqRbPBpMprwz8fj04gZTbXLw3+KJ+o2/+RxQP+r/+4zJQPk3ONslI ajsfrj1uarIlmUY+g6p1Y00PiEP7xZWc40lZduFASSTwwPBBEP88HG5p7W7t5zYFsZhG 7DLaGMwdX2bUkwbmYH8eniwAbfnYcuVG6Jiv/b1axF6vNEsn2SM0zMhF5jMvE4+ooDRa qqiD7PdZB+FFW+r9TvCLDHfDGUD/82tBqqQtstozmQlzn/tofYKVb4TrK7+zj4UeZnrZ cxIHpV2nNhYblF9kp2mGAx81M9xb97SWKozfv6WQUsmCrsKQJ9ANyvOrLVnEpTmVqNwK 1jDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=wk1eSZfKa/uCgbSeaHgMYGqmJFfEX4IDkxY2j1qLt5w=; b=nZm38Y5y3M4B4ijW8aZUt8hxw99DQg5vXkhDGuynaKgvTYt8GH6bLK8HNQ5FMkHr/V 7uHJFtrhb1Rq6ehv6hYHtuwfJbtMqDxKLgbSiiFXNMGb6IAa3bpybYjMAMdUF8cm95v2 ihiEemdAfQ9YHb7/BY6jIT7LinnJSmFseDxXZqedCqfJ35wumjFv/W7FP9eswQC1RR1G RdPC60v8VJGyM+VnlpLCqZ6PnZREa5yjMuWj5R7wvpUR0Ei36pir1tjpvhEbGRrtX+cD c3LjkNzlx+arJCgXRnka7qO8w15sF8yp9OPad1R+jTQVok7we0Jbgm2YWIxkzomylqgV 2a5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=UEcN8lJl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si12705471otk.276.2020.02.04.23.09.40; Tue, 04 Feb 2020 23:09:53 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=UEcN8lJl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbgBEHIt (ORCPT + 99 others); Wed, 5 Feb 2020 02:08:49 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:7940 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbgBEHIt (ORCPT ); Wed, 5 Feb 2020 02:08:49 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48CCMy2cvlz9vC0w; Wed, 5 Feb 2020 08:08:46 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=UEcN8lJl; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Y1E3cpL1tbsk; Wed, 5 Feb 2020 08:08:46 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48CCMy1Z4Xz9vC0v; Wed, 5 Feb 2020 08:08:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1580886526; bh=wk1eSZfKa/uCgbSeaHgMYGqmJFfEX4IDkxY2j1qLt5w=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=UEcN8lJl+hLeHllKoyJOwY62yfGvvpmIqaeajwXBqXqBdkh2b1rqwxDMOC6P57IRn 3w1aFHGTQBExTzJaDV7Etbho4vLzNy5nTSwMEQSCiODyjwktRyijUsuLyYoZpRc621 k8X4gKws4MWvQRplmTxxdcKt7iEUv8gGqfMo7lCA= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 03A518B820; Wed, 5 Feb 2020 08:08:47 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id SuJQpOUhv6DV; Wed, 5 Feb 2020 08:08:46 +0100 (CET) Received: from [172.25.230.107] (unknown [172.25.230.107]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B90FA8B778; Wed, 5 Feb 2020 08:08:46 +0100 (CET) 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 , Kamalesh Babulal , "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: Christophe Leroy Message-ID: Date: Wed, 5 Feb 2020 08:08:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 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; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 27/11/2019 à 13:01, Gautham R. Shenoy a écrit : > 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. Might be a candid question, but I see in arch/powerpc/kernel/time.c that PURR/SPURR are already taken into account by the kernel to calculate utilisation when CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is selected. As far as I understand, you are wanting to expose this to userland to redo the calculation there. What is wrong with the values reported by the kernel ? Christophe > > 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); > + > + return sprintf(buf, "%llx\n", *idle_spurr_cycles_ptr); > +} > +static DEVICE_ATTR_RO(idle_spurr); > + > +static void create_idle_purr_spurr_sysfs_entry(struct device *cpudev) > +{ > + device_create_file(cpudev, &dev_attr_idle_purr); > + device_create_file(cpudev, &dev_attr_idle_spurr); > +} > + > static int __init topology_init(void) > { > int cpu, r; > @@ -1067,6 +1097,8 @@ static int __init topology_init(void) > register_cpu(c, cpu); > > device_create_file(&c->dev, &dev_attr_physical_id); > + if (firmware_has_feature(FW_FEATURE_SPLPAR)) > + create_idle_purr_spurr_sysfs_entry(&c->dev); > } > } > r = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powerpc/topology:online", >