Received: by 10.223.176.46 with SMTP id f43csp287717wra; Tue, 23 Jan 2018 21:07:17 -0800 (PST) X-Google-Smtp-Source: AH8x224zrwvISxAi3WQ5H9Zw+K5gxlKqqXuV39Tgjls2dSZEAyEoMFQJPcXPqvzi61JfaEwIP+OY X-Received: by 2002:a17:902:820c:: with SMTP id x12-v6mr7287399pln.103.1516770437304; Tue, 23 Jan 2018 21:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770437; cv=none; d=google.com; s=arc-20160816; b=ktJrn0EQeIUb3yloav7EVLj1bpUCbSqH+3Dv9diHgR151NySYb8MDmkkiLiciFHcnn hErO+NVWlk96iQCC9coQ55TuvRx5QTMU/RpxYb65gv3IxKxmcP2T8049YhDlF1d/ikjY 6yJi5Kn7vUBIuMnxQScTuJ7H7Pu1uSL9DHiN3xxqUjR/p7pZgPB5x1RyG+/Swb3y6oWo o7+T2FC6vmvu75kwa9EfuzA8+StlAHpE7243ftxp7n+SMzZpmN29BgViWyALHkd/bvNp Fb5XON56pKY4eb39okuFEimbRzbLiwGLj/VJLxUdsR+kzjGeZwcceXASxXlOfPfhiWvY EKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=z6qOn/FdOjw1k80Uqs32+gpJxf1Ez7yuThsKoUwcINY=; b=PfEeS0zW3odPpq4SVUn1aWRdLh+p1CW0l+UQLjG546GtYg/0USra2ixJxcvOrJc85P u4h6F69PVj5gL7/lYDNg+k2WDcie01gBANLLv0E16r+MAE+YQF24kpXZYwC16/Bj2SC3 VNp2mbIrqUXl7tz6c3bwWIgR5YquXwugSeL2Qtqn+YmAhwr9ffh+o/XXkO54XSTXXPCK WXN5AnFJUd38Pt9rvUS+s6GFBInSPoeA0VxggwwcHlzpR0EpjvZtEXhZc0+vdhHtL3uy mv4Du6CTB84v+sQHMy0yIIxNPBkLVtlJCpjw1VoEcgywBHqzGdnTMkd72De1dBxOyHtR Gudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=VlNqKftj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h70si15447559pgc.19.2018.01.23.21.07.03; Tue, 23 Jan 2018 21:07:17 -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=@microsoft.com header.s=selector1 header.b=VlNqKftj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932088AbeAXFGr (ORCPT + 99 others); Wed, 24 Jan 2018 00:06:47 -0500 Received: from mail-cys01nam02on0106.outbound.protection.outlook.com ([104.47.37.106]:53792 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752467AbeAXEO0 (ORCPT ); Tue, 23 Jan 2018 23:14:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=z6qOn/FdOjw1k80Uqs32+gpJxf1Ez7yuThsKoUwcINY=; b=VlNqKftj3q5YmkcWBXWSsi1dqjl26XAupoGfYhw8BXLKRN1wb2PcDSHZXJRf7XE4Z4b5iCwwJEbjp1eXUwuCF4D/5830/4lCDtn53PgxoLudYs367DLXxdxTpMicp/Fp0cKFFEce7SF6eFNVaYBvh8oXqXSKqFRxKjahoHcZ4IY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0920.namprd21.prod.outlook.com (52.132.132.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.3; Wed, 24 Jan 2018 04:14:23 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:14:23 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Abhishek Goel , Shuah Khan , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 005/100] cpupower : Fix cpupower working when cpu0 is offline Thread-Topic: [PATCH AUTOSEL for 4.14 005/100] cpupower : Fix cpupower working when cpu0 is offline Thread-Index: AQHTlMnQiQHN8XSyE0W5FPi+VfV8hQ== Date: Wed, 24 Jan 2018 04:14:23 +0000 Message-ID: <20180124041414.32065-5-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0920;6:diBSwyEdSw8YUku/7TxbjmN1fnw/tBdmSlOMkgl+Iosn0aVpoVQABF6r9/FlXoPmtVbQ50HW2dqBVDQ8cIjoqH1wOK/UkpRYaBtobme6nLy3A26VO94dT2ZOgFaJqtrghCYd2suIVCo8DXdZpU6ikSnwAuTF/JmV8NfivPQ7BEEgAGiiG3OE3DtcFlPzLfcd6dS9G/HqmegWZB79pfwF2dNKkcZBJHOw2IBN8FcDe8YV0ignhbBXq66qGxyEciw+kW+SZuPFQvBH02vP7EbnI7G72tClxYWKzmn+/POhvrAHvAW3aBP10xNOBCmAUsPml9LP9+DWO63pEQR9SqUNVd9ShP0IkCBnNi9b5ax56/7oKlm3cBcU3m+65I7cHACv;5:r7XGnwxqi4ABMJEpZYHh/MP972XD61+VkgyHlrzTYLSjqkcMMjlf4r1tLcIuglPj4lTmWKbDbVGxa3YW0ANp6FoTlpfKch9vNZbAxUHaw2NqOOo76vuJiI0rwxZTryvH0Fjd1jcxCbRnUWxCTRt63FucnbtN9+PpgoPJSf5yC8I=;24:LU1Uti1ACdHBs42ZSmkej0Xwk5eVVuowUF+P8ZX+WXjTgjii3YnEdNBws5LT7RfMZT4bn6ZKfccB7evzrulbgm3Vgl8MQVFYJzWj5VCSJ3s=;7:j95cbwmDqBrxYQ0a7mbn+7Gg+27/enVeQGfRwnSoL2NZrgOYvJKu70qQNvaqtwFxmobiy/CS769CioHnwc4e42RKQjHfVKG6zowRI2oBLmf9kH/J/bNm3f+fLLOEuGYacOYsm7mnyd7T0RdyaiwwZazSws8YKJHvVFX7WmZ9oTwElu/O4gr5QqY1TFj8Zi+IwftPjb7P2vrvnfjnjMWFHgGHNJndaqtbSGhVUqj/RWqyUFVr850VMgyM/QLS+6SD x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: c1883439-bcac-4309-39c4-08d562e0f34b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0920; x-ms-traffictypediagnostic: DM5PR2101MB0920: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(72170088055959)(89211679590171)(209352067349851)(104084551191319)(7411616537696); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(3231046)(2400081)(944501161)(93006095)(93001095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0920;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0920; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(376002)(396003)(39380400002)(346002)(189003)(199004)(105586002)(106356001)(86362001)(2900100001)(66066001)(305945005)(14454004)(22452003)(72206003)(3280700002)(3660700001)(10290500003)(5660300001)(36756003)(2950100002)(7736002)(478600001)(110136005)(316002)(97736004)(81166006)(6116002)(3846002)(26005)(1076002)(6346003)(54906003)(25786009)(81156014)(6436002)(10090500001)(68736007)(107886003)(99286004)(8676002)(8936002)(4326008)(5250100002)(2501003)(86612001)(6486002)(2906002)(6506007)(76176011)(6512007)(102836004)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0920;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: J4azcFKYBBALKt4SzJsVTsqOuhOkvMOKGfOkMpm0855ipZAVW8oYO1D8C9Zw5lfxbcZX4bALiq5n+L5XuvZX9A== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1883439-bcac-4309-39c4-08d562e0f34b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:23.5281 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0920 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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/tool= s/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c index 1b5da0066ebf..5b3205f16217 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 =3D sched_getcpu(); =20 /* Assume idle state count is the same for all CPUs */ - cpuidle_sysfs_monitor.hw_states_num =3D cpuidle_state_count(0); + cpuidle_sysfs_monitor.hw_states_num =3D cpuidle_state_count(this_cpu); =20 if (cpuidle_sysfs_monitor.hw_states_num <=3D 0) return NULL; =20 for (num =3D 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) { - tmp =3D cpuidle_state_name(0, num); + tmp =3D cpuidle_state_name(this_cpu, num); if (tmp =3D=3D NULL) continue; =20 @@ -146,7 +149,7 @@ static struct cpuidle_monitor *cpuidle_register(void) strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1); free(tmp); =20 - tmp =3D cpuidle_state_desc(0, num); + tmp =3D cpuidle_state_desc(this_cpu, num); if (tmp =3D=3D NULL) continue; strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1); --=20 2.11.0