Received: by 10.223.176.5 with SMTP id f5csp979109wra; Fri, 2 Feb 2018 09:10:33 -0800 (PST) X-Google-Smtp-Source: AH8x224r1+eGoOuV48BKOONjmxhZvokYnlsH8w9FUn36rJDJmXpk2+P4Bcu6NmN7zSX0luhGUWk9 X-Received: by 10.99.112.75 with SMTP id a11mr33249825pgn.47.1517591433760; Fri, 02 Feb 2018 09:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591433; cv=none; d=google.com; s=arc-20160816; b=rExWEkSX4YEklGw4GwAMxMrXg19SxBSQ0gkbzXFL1/nbm1cM50kT6WcyI2LQRTKmnZ GwRGPZxYmziL9mfglYkx9vOmM/cN/Z6MGrc6+ur0RcTF7WKPoUXttnm5PO9Rkk4l15QB VUFoErWJAI56IBWNprnC/LRjhgKDOsFJQpsWLFyYbTa8WtWnPsOAIJ2o9p6W86rXc787 eqQ2fhaKz1MaoO8Q6BeJ1la+hVhfFJmnH5ULFf7+pOcJIBwhOJaWrtnx9oJ+8mZe1Wm9 p77GsnlBPZqbBM1U+FrE079ggrv1MjrM5CwLXk85GavnbFh4xunUeCqtGWIOnhm+KsEv 8IyQ== 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=qZN/Um9NxwKsdkD6mA6WV5Eik6GJX726rJSKGekJex8=; b=CMfMg2a/SXWTqHlsoKXPv84SqB+dnkFqjBRrn5YLTgGaCWtL4KDIbPjiVwy8uldKt3 CAxDwH2xyPyNDMgkg9aiUx4QKKAvHRuBPWRymt1vnf7+ynmyFfkoCxQwy1cBYc0Sc/0I XIjZrGlrgXZHJNMqNan4djSp1PegiIH6McRXEtyH//GipB6Sl2pbWN8q2RLC0bNxoqra IU+bnEipYoBTrx2a5DS0Vdkr99ElPxgJCgX+vtoRe1amBW4CmR0CLArgJNx85YLtsYek bCWD8xOJPqXk5prCzI2YGKAtgF3MyLDnkn0pEscyBGZ3Pc9eMB1lTtR594m88ZXM03PY kesA== 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 w2si1695775pgp.680.2018.02.02.09.10.18; Fri, 02 Feb 2018 09:10:33 -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 S1753261AbeBBRJo (ORCPT + 99 others); Fri, 2 Feb 2018 12:09:44 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36352 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbeBBRFB (ORCPT ); Fri, 2 Feb 2018 12:05:01 -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 671E3E16; Fri, 2 Feb 2018 17:05:00 +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.9 19/86] cpupower : Fix cpupower working when cpu0 is offline Date: Fri, 2 Feb 2018 17:57:39 +0100 Message-Id: <20180202140824.536513876@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@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.9-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);