Received: by 10.223.164.202 with SMTP id h10csp365601wrb; Wed, 15 Nov 2017 00:44:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMYEyCT3cQNymrhd0TjAz1UxYbZB7pMbkIjLEoHfe3Plg0muKjonxdWpKG5gYOIzMD6I64XT X-Received: by 10.159.196.152 with SMTP id c24mr15574340plo.413.1510735487863; Wed, 15 Nov 2017 00:44:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510735487; cv=none; d=google.com; s=arc-20160816; b=bBIVFLL3m9yfknUSQk4FOPOsgX2KKqSy0SYoABBl3nwr52LNrYuI5j2PxXRu8uy3Vh 8WUfdOgu/EQpxSxGUoGW3S+LyH/o/r7gLiuCpyU3p0iS5Non9+3uvZJbdiu9E683e6Aa raE2gxtEjnC3OlFDN4WibSm86C6yQrdefVtIi58BUFsML4j/iUYfjYMrhp1Mh8TI8l6D tHyMSWi2Otgl+7mNbjWubBL/Db+g5hTVjPBr+138k9LULvNLp8qveYecfAn8whwLK4xb 8LqbewvFWvgOQxqgT6GF6mLJAhZFiTUByFdLo25A2ixNwczQwwslEDqphybjZonXH0s4 Ny1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gD2sN8HyJxz84TfSN/iEBhMz7AN2yymDwVc/4umbCbk=; b=tZL+9+wsdNFRnJEovnJS4AdTzGDf38kVRtEU7DwdFyHDG5Ma5z+FLPXRaPQXwgAGCu bz5WFPdjLNJdqMOr2E2Y4mifqUk4SAlk24aBFdtpI7y5ms9FdiXe4fs1e35sOFLv42e9 GWr/v3nSjTICM3sg6RSIiTn3TIP04PqnEiqj/niLrREnMYf9gQjswrwmf/ktddqrg+91 CBdxTHz9V31MiyJWvlycguXxeeWaC7PlKu/dmPeIavnSrWJj4QG0CUok9P9qa0gOmBLL ouwxAmDTgN6EJiMxMrE1D3TdvEiWT/7KuH0PntBxtX05BzCtMy6ulmlwtTfTwXXPMT6s f0Bg== 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 34si17762631plz.343.2017.11.15.00.44.35; Wed, 15 Nov 2017 00:44:47 -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 S1756140AbdKOIk3 (ORCPT + 88 others); Wed, 15 Nov 2017 03:40:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56976 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755314AbdKOIkM (ORCPT ); Wed, 15 Nov 2017 03:40:12 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAF8dESG075134 for ; Wed, 15 Nov 2017 03:40:11 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e8dt1jqvk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 15 Nov 2017 03:40:11 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 15 Nov 2017 08:40:09 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 15 Nov 2017 08:40:07 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAF8e6p832374808; Wed, 15 Nov 2017 08:40:06 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5AB9A4C05A; Wed, 15 Nov 2017 08:35:20 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 705DC4C040; Wed, 15 Nov 2017 08:35:19 +0000 (GMT) Received: from fir03.in.ibm.com (unknown [9.124.102.72]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 15 Nov 2017 08:35:19 +0000 (GMT) From: Abhishek Goel To: trenn@suse.com, linux-pm@vger.kernel.org, shuah@kernel.org, linux-kernel@vger.kernel.org Cc: Abhishek Goel Subject: [PATCH v3] cpupower : Fix cpupower working when cpu0 is offline Date: Wed, 15 Nov 2017 14:10:02 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-GCONF: 00 x-cbid: 17111508-0040-0000-0000-0000040E800C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111508-0041-0000-0000-000020B135EE Message-Id: <20171115084002.23887-1-huntbag@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-15_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711150123 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpuidle_monitor used to assume that cpu0 is always online which is not a valid assumption on POWER machines. This patch fixes this by getting the cpu on which the current thread is running, instead of always using cpu0 for monitoring which may not be online. Signed-off-by: Abhishek Goel --- tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c index 1b5da00..5b3205f 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c +++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c @@ -130,15 +130,18 @@ static struct cpuidle_monitor *cpuidle_register(void) { int num; char *tmp; + int this_cpu; + + this_cpu = sched_getcpu(); /* Assume idle state count is the same for all CPUs */ - cpuidle_sysfs_monitor.hw_states_num = cpuidle_state_count(0); + cpuidle_sysfs_monitor.hw_states_num = cpuidle_state_count(this_cpu); if (cpuidle_sysfs_monitor.hw_states_num <= 0) return NULL; for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) { - tmp = cpuidle_state_name(0, num); + tmp = cpuidle_state_name(this_cpu, num); if (tmp == NULL) continue; @@ -146,7 +149,7 @@ static struct cpuidle_monitor *cpuidle_register(void) strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1); free(tmp); - tmp = cpuidle_state_desc(0, num); + tmp = cpuidle_state_desc(this_cpu, num); if (tmp == NULL) continue; strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1); -- 2.9.3 From 1584343242357718596@xxx Fri Nov 17 19:37:38 +0000 2017 X-GM-THRID: 1584045441082001808 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread