Received: by 10.223.176.5 with SMTP id f5csp987077wra; Fri, 2 Feb 2018 09:17:12 -0800 (PST) X-Google-Smtp-Source: AH8x224otcXKsegOfzA+r2ZeXkZk6I4cM0Jmcw2AKGQuLe1+Ko10fxD34V8ISoQkf85Itk5kTRFu X-Received: by 2002:a17:902:9a04:: with SMTP id v4-v6mr34905262plp.252.1517591832380; Fri, 02 Feb 2018 09:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591832; cv=none; d=google.com; s=arc-20160816; b=cimts///2aK1pQpRcaKGY9FigOtb2CDJ+TTCdifmxzzOw5qFsea+n7u1yigNZs9mj3 zXAI+ughMkYiJf3XppBRI9ftrWPtR10FedOkAP+Oe7nYifTVrQNeIpXaZdYL20wzBOsE rVfUUtCqZX5/IMif+Gmlq5e0NEjQ0dmdznkxu6OX4SOqoVIaekFuKyeUmyKHnvDNqu5M ZzCQWLMtYd2Mtk53GW5sk2JwAcyPHlZBerGDneTWsjUWF/yjbvBDhKCF3Ql2UFg9JQsq PoKaIAMYxsfmw3YaxbVvsVaNIXD6/LDj4Q+k5PW6MVX0yNWy+wr4GYiK+YsLNUUz3YXu W9Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YhWl6ZeOec0w/sSLdBD/oqmbUdoDWQTMz/rtI7ocyOM=; b=axqBvOXeFlmimRNTqCjCmXpNQADYRQpGIgQVvbr18k/pU4CqNAiBVBqAZul1yh8RCm PvQJRns2sbVgDYSV4Gn/Cx+sEiR24zXwGJ466mPa2w2rG4B8UP0lPqDwbLHSh/6Jek5s IfzdiT1eby1aKd8at/IBi9tN+lPRrCkH1c85/AXPYKTKXYpDgKIgLuJiXroucnasq2nj xmPZdZbTAM/zuxlGGBFjqqD4qxBiajionIokEtTsdMvzknhaOlfGffh/nCn2hZs2aDPC 3ZUiyXBHhqF0BwkNMGSe6Oe1+AYAvQ9r6AhnJr62XBjc6V5vUHnHzS5QywTyr7ulxe6m ov6A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si1713793pgo.189.2018.02.02.09.16.56; Fri, 02 Feb 2018 09:17:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753551AbeBBRQ1 (ORCPT + 99 others); Fri, 2 Feb 2018 12:16:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38180 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752569AbeBBRKH (ORCPT ); Fri, 2 Feb 2018 12:10:07 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2C5A4DE5; Fri, 2 Feb 2018 17:10:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abhishek Goel , Shuah Khan , Sasha Levin Subject: [PATCH 4.14 035/156] cpupower : Fix cpupower working when cpu0 is offline Date: Fri, 2 Feb 2018 17:56:56 +0100 Message-Id: <20180202140841.897364427@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abhishek Goel [ Upstream commit dbdc468f35ee827cab2753caa1c660bdb832243a ] 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 Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- 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_r { 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_r 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);