From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933503AbcCKCRJ (ORCPT ); Thu, 10 Mar 2016 21:17:09 -0500 Received: from mail-by2on0088.outbound.protection.outlook.com ([207.46.100.88]:10894 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933443AbcCKCRH convert rfc822-to-8bit (ORCPT ); Thu, 10 Mar 2016 21:17:07 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0O3URO8-08-GJU-02 X-M-MSG: From: Huang Rui To: Guenter Roeck , Jean Delvare CC: , , , Aravind Gopalakrishnan , Borislav Petkov , Huang Rui Subject: [PATCH v4 0/6] hwmon: (fam15h_power) Introduce an accumulated power reporting algorithm Date: Fri, 11 Mar 2016 10:17:44 +0800 Message-ID: <1457662670-3354-1-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(199003)(164054003)(189002)(5001770100001)(23676002)(189998001)(50986999)(101416001)(86362001)(87936001)(50226001)(33646002)(77096005)(15975445007)(53416004)(50466002)(92566002)(4326007)(2906002)(19580405001)(19580395003)(5820100001)(36756003)(586003)(1096002)(47776003)(1220700001)(11100500001)(5003600100002)(5008740100001)(105586002)(229853001)(106466001)(81166005);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0718;H:atltwp02.amd.com;FPR:;SPF:None;MLV:sfv;A:1;MX:1;LANG:en; X-MS-Office365-Filtering-Correlation-Id: a5be11bb-8324-4eee-40a8-08d349533c8e X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0718;2:QSE9JtPglExdwqHbDbFCaTKhSNBzs18lKKRlvBkXKiRSZkXZKB6qSGJSz4yB7t3oYztaXBLZpfcCXRW4NUDW5QfmCXjHZ1ZRiLvzH4I7N/qQUObvTcTsAonPFAvm5oCSubbGiQpSQyulCUy9XyRRvcxQzsQZB4LLtlcGSw3jFYNSBvlzksNtghLP54QrNU8p;3:d3PXUeMsVMtljNZ9cE/vNfnSfF/40ScjVHMAR1IprpNgABgJZy4+QCyFx03aLg7C2FHQIlzUJxVPeUuebmCMNbT+kVPWXqwGjBDYnAmtVejwRLdB5np9mXhHwU689u6WrZGb7DGoaUohII+gRo+y9kAXJznXfcTtHQiIh6C5RdJsVA624hc2xu466oMj3R2zzUhqZ/alYLyP9PLHl2y6sHIYPW7cMcnDpBbHFGiMaUw=;25:iteKm2WftCmhOI09od40aMH/+YUW3JPuLxDOA/3bI972Tv9CLfj7PLCG0pJpCtKy+CwzNer9ruyp/bY/q2dYlfC7ykezA/UZys4K3yMrtPDt/0nR897hzlLM9uAEjaPPP2Dc+ruCKSAwwzYk42bYcY6wE0E4j79ONTHpQ32X/MM2MuqvOMTGeX4sWAzpez6X+NnhpxE1opKBds5IF9lCgjlA6SV8X8Fxny5m34GNt+78ra+hkIM+CAigwMOErlrul6mBQgP/8BM4azI3Hvdtzg7mLXtBsKQ0uHotZy/0VbF5gxju91B9AUXVvmcXRE5L+v94U6wVIJHIkAmH32zdSw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0718; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0718;20:XRQTkFNs8PGtv8C6uKPRJoj05vSytkxKFlQXaAWF6ArvR36CjwDU61keaLojMKlt2AOgjmaKqDx+H+OXruynlBLrx5qUEIH/As8yzjsfZYU2PcXBpZSeN2W5PMW4V7h/TX62pTeu0gO9E4GBzXfiKlDUWn+hJ9s8B60vGNyc4766ULO8cPCg5nXM/7oqwKX9j0xzvlnNAK1h5pF2bll4bVPmbHVcI4h99G9dVNDQ156N7mxCwoe8Q6BrklREFVXMByXeKbTVP8XRSx0NgAdDJt7UHL+b3psa+WEvaIbM134o94q+t+Efmo9gNegKH5z0RzcSVGNEpdDxZf1ma1eB2VB7Y0Rd240HRMYYFTPSdKaxNNB1eet8tVtigPov8w7JdwXBWt8Buf6dOY0fXDIslewa8Ei2c6hJ9VVYgBFF21sDPoMEfVM5NBub2OK9aXgCVLWn0Gz5Zup6RA0FH5Pyy27Z1zclBBWQBRMNYQ+I9RXBn9Ioz0bX4AD5GDop6Rp4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13018025)(8121501046)(5005006)(13015025)(13017025)(13023025)(13024025)(10201501046)(3002001);SRVR:SN1PR12MB0718;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0718; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0718;4:gBQKjucweYNlh3CRpvLUCaUJ/Z7IOFa8uPxic3e4IoL2gGY9wcieVTEz5mys2Hyx1oi7Gm6WOaZLG8E1uCd+vwwKsb3yJK7F9JuUGn1XS2IqW/3JaKmyEYJW5DyKlQGuwyj0weRVTCZyTkYaR4lOG/hdY9VNFnfztF1kbvx1HAdDr7AgThsB797cxCMmcu/rV3C1UjhfGNJYe48wC1fMNgW9CdE5R93vLzgiGK58fhdBLfSg8gPlsT+228a9mVe/tEf/RvNpeUzyVf4ooFZ7+A9xxOLMhQQ+26+PCel6EzBgcmZd+C3to9Ejg6PuEfh000yeQGXQM3fDUEKNtheIbkWsvay33qdGimpWS+Ccy/ROO1eav53JYcjmn7DYAVIgJ99H65uB0EyMeqLxcuAQFfNSRXXIjtwP+7h05SE4EOFJCaJG5SHZatbWW7cES7GRV6NeIGWSw6HxAnSIuOnEwA== X-Forefront-PRVS: 087894CD3C X-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4sUbBQDc7Uju1mdjxR3TOZZqwTqw7i2F9x/t0UXmuqtN8HYCUxc+5YnRIw5YvkhsAUPXy5aBCiR3sgqIq2JctmchhxDGT3eb5LepNuqEH5cG6AGbWlkpMpWQ1T16EJGbxW06U SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2016 02:17:01.3002 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0718 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, This serial of patches introduces an accumulated power reporting algorithm. It will calculate the average power consumption for the processor. The cpu feature flag is CPUID.8000_0007H:EDX[12]. This algorithm is used to test the comparison of processor power consumption with between MWAITX delay and TSC delay on AMD Carrizo platforms. Reference: https://lkml.kernel.org/r/1438744732-1459-1-git-send-email-ray.huang@amd.com Commit f96756 at tip ("x86/asm: Add MONITORX/MWAITX instruction support") Commit b466bd at tip ("x86/asm/delay: Introduce an MWAITX-based delay with a configurable timer") V1: https://lkml.kernel.org/r/1440662866-28716-1-git-send-email-ray.huang@amd.com V2: https://lkml.kernel.org/r/1445308109-17970-1-git-send-email-ray.huang@amd.com V3: https://lkml.kernel.org/r/1446199024-1896-1-git-send-email-ray.huang@amd.com V3 is blocked by the patch "x86, amd: add accessor for number of cores per compute unit", but now we can use smp_num_siblings instead of cores_per_cu accessor. So resend the V4 now, for detailed info, please check: https://lkml.kernel.org/r/1449719771-12837-1-git-send-email-ray.huang@amd.com Changes from v1 -> v2: - Move fam15h_power_groups and fam15h_power_group into fam15h_power_data to avoid overwrite on multi-CPU system. - Rename FAM15H_MIN_NUM_ATTRS macro and fix return error code. - Remove unnecessary warning print. - Adds do_read_registers_on_cu to do all the read to all MSRs and run it on one of the online cores on each compute unit with smp_call_function_many(). - Use power1_average and power1_average_interval standard entry instread of power1_acc - Fix the CPU-hotplug case. Changes from v2 -> v3: - As Guenter's suggestion, remove typecast, use &data->groups[0]. - Remove all "fam15_power_*" prefix at data. - Remove unnecessary ( ). - Fix the issue that is reported by build test robot, and add CPU_SUP_AMD as the dependence of fam15h_power - Remove the WARN_ON at do_read_registers_on_cu, because it must be behind CPUID check. The MSR must be available since CPUID.8000_0007H:EDX[12] is set - Add get_online_cpus()/put_online_cpus() functions. - Refine commments and the method which generate cpumask for cu. - Add the interval scope to make the value suitable for user experience - Remove the useless mutex. Changes from v3 -> v4: - Rebase the patches to latest groeck/hwmon-next. - Use smp_num_siblings instead of cores_per_cu accessor. - Refine the cpumask method which is inspired by perf solution. - Fix some typo and errors. A simple example: ray@hr-ub:~/tip$ sensors fam15h_power-pci-00c4 Adapter: PCI adapter power1: 19.58 mW (avg = 2.55 mW, interval = 0.01 s) (crit = 15.00 W) ... These patches are rebased on groeck/hwmon-next. Thanks, Rui Huang Rui (6): hwmon: (fam15h_power) Add CPU_SUP_AMD as the dependence hwmon: (fam15h_power) Add compute unit accumulated power hwmon: (fam15h_power) Add ptsc counter value for accumulated power hwmon: (fam15h_power) Introduce a cpu accumulated power reporting algorithm hwmon: (fam15h_power) Add documentation for TDP and accumulated power algorithm hwmon: (fam15h_power) Add platform check function Documentation/hwmon/fam15h_power | 57 +++++++++++- drivers/hwmon/Kconfig | 2 +- drivers/hwmon/fam15h_power.c | 191 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 244 insertions(+), 6 deletions(-) -- 1.9.1