Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754469AbdIZKMr (ORCPT ); Tue, 26 Sep 2017 06:12:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44373 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754456AbdIZKMp (ORCPT ); Tue, 26 Sep 2017 06:12:45 -0400 Date: Tue, 26 Sep 2017 15:42:36 +0530 From: Gautham R Shenoy To: Abhishek Goel Cc: trenn@suse.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpupower : Fix cpupower working when cpu0 is offline Reply-To: ego@linux.vnet.ibm.com References: <20170922110218.120948-1-huntbag@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170922110218.120948-1-huntbag@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 x-cbid: 17092610-0020-0000-0000-00000CC355DE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007795; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000231; SDB=6.00922571; UDB=6.00463715; IPR=6.00702712; BA=6.00005607; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017279; XFM=3.00000015; UTC=2017-09-26 10:12:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092610-0021-0000-0000-00005E477D16 Message-Id: <20170926101236.GA25906@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-26_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709260152 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2162 Lines: 70 On Fri, Sep 22, 2017 at 04:32:18PM +0530, Abhishek Goel wrote: > cpuidle_monitor used to assume that cpu0 is always online. On what platform is this assumption not valid and what is the problem caused due to this. > Now the > cpuidle_monitor function searches for the first online cpu and use > it, instead of always using cpu0 which may not be online. Mention that this is the fix performed by this patch. > > Signed-off-by: Abhishek Goel > --- > tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 14 +++++++++++--- > 1 file changed, 11 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..adacf99 100644 > --- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c > +++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c > @@ -130,15 +130,23 @@ static struct cpuidle_monitor *cpuidle_register(void) > { > int num; > char *tmp; > + int first_online_cpu; > + > + for (num = 0; num < cpu_count; num++) { > + if (cpupower_is_cpu_online(num)) > + break; > + }; Don't we have an API that gives the list by parsing "/sys/devices/system/cpu/online" ? > + first_online_cpu = num; > > /* 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(first_online_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(first_online_cpu, num); > if (tmp == NULL) > continue; > > @@ -146,7 +154,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(first_online_cpu, num); > if (tmp == NULL) > continue; > strncpy(cpuidle_cstates[num].desc, tmp, >CSTATE_DESC_LEN - 1); Looks ok to me otherwise. > -- > 2.9.3 >