From patchwork Thu Nov 10 17:58:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 1461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp293910wru; Thu, 10 Nov 2022 10:07:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM6qKdjwPt2zo2bb3fAfyYxI3oGvRAqVXd/QavuomJx67Iow5Kl4nkelpoL7dM8IyXG3wwiW X-Received: by 2002:a63:5045:0:b0:46f:1262:8df7 with SMTP id q5-20020a635045000000b0046f12628df7mr2984274pgl.39.1668103625800; Thu, 10 Nov 2022 10:07:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103625; cv=pass; d=google.com; s=arc-20160816; b=lkg1y6FC4CibsImNC0V4y9h/SHpFScnSqkqDVKvHndmOfVV743SDHdRTlAm2+fjnWd S205gHSXMNp+anFKgmK5h0i6+Gjkm7i57PWw+gQB1BipIMKlADmYjuoIcdswdT2DnNzL imfH6/HcxfeV6Y9LYLpCoNnk+YEdCP9Y3AjCTAEBhDN3vypx22PtQ1jzCHYSFgp8+6NN Qk6Lgu8Qgl5Hj2+n/69cIwosfDTFkza4HPpa1UbrjIivl7sHi9N8t5OPwCyq8xLV0RxB 2vJroE/WON6dHn+KO5eegDkQeVi1XC55O+o7nNFy37PVrOMujG3XK923kNOyRv9ICswl mISA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=s1JTAxhGtNO+x6+WsNiGRa+RFwBJ4pXb2dAn6UdsEjA=; b=rxabB+zaIIkplBYPP+D+BrPNaPFhfC4vg1Xr+nXH5l0jv5c2B/I8TgAwCdMCI93E6C hTMRaVufNjpxZGv36MrLj9rnAeNeiI7DDEhHx0z4efQpEvIrQ9NCv0fK8oqN8EQlCQCw A6Ao89/CSQE0e8LuIydbyrjmfdQcDhwJxjO8ZretkRlGblXLnUP5sAwEM8Zb+r72l7Gk ERkWV4mPkE/pXnlshOAG+IAzEOTxdhyqDkSMwkZ8Noei/JLy2MDUUcw/sKRcQ+AT1x+j TI2NWXvNpJkU2zQ2p1JxllulzMdFxnMDsXDvr8bCsID+lXYejs4ksz/hTV4Q12GXU5Pv 4Q1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ht6r6d37; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a17090a5a0300b0020a66fc1398si4915437pjd.91.2022.11.10.10.06.51; Thu, 10 Nov 2022 10:07:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ht6r6d37; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231559AbiKJR7Z (ORCPT + 99 others); Thu, 10 Nov 2022 12:59:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbiKJR7T (ORCPT ); Thu, 10 Nov 2022 12:59:19 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1232845EEF; Thu, 10 Nov 2022 09:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PWLlBoc6abZOfe1LAoxJnZwz/UccxTiyMCuX/bIWfLpfjwlixqq1piU4MwQcasfN62EH33k0qOlkZlT3wjyNkAsXlPxpq+oDj4C4O16xR7oMoNeJhb8mc0BTwvL2AECPKlBKfepdhfMoqJQRjCY/6ukZat/C3gqJFxsymKmVGKZGGRx2amAofMO097Ws+Hl2xxyPP+2optV/trafaQZaZbJjBCTks8p5MV4ZomnrLT8VrNUYs/DQsQyy6GzfIet5uVseMedFRHelCA39z+uZK4D7rzJrYCVBKZEgwtk1AkSN3rbFBfnUAB+KKETe0dNTQJeYJ/3HKrbKgPFLhVITHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s1JTAxhGtNO+x6+WsNiGRa+RFwBJ4pXb2dAn6UdsEjA=; b=XYB1OSVxYA6h2cqlONRtr01irJQXJ5KZhls7j7JXLhrlTmxQut9QfK1nMu53V5Pjc/YI7ApYD8LTzOgdl/PozWLxDvclxvQDGWMm9e0iMiCHcEi+F62D3KvN15XYuHxpdMQpt7AFiMXBCQijbihzEXFJE06yWD7P3eRl4XgIGI9jFqlj+GaLr6fgWlDPemFncqcRX+i+yNupBOh0fN3J7lt2rCqImPTKjccL9j9cM6PAjxFrGIcDnpe/j0+Z/0OAqVo1ZNAioXfvX6sIO6FGrDAm4xYNWUur4uAeanK8iq0wyhzfoLNK2ptV/SCozXj0DQoZQStuJatIZ/Eyv5fXXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s1JTAxhGtNO+x6+WsNiGRa+RFwBJ4pXb2dAn6UdsEjA=; b=ht6r6d37wNwAKW/Kq251ZB/rOhut8+1ASx1Qwv5+ROlsB4PjClp51AsbW69JjoEhNaBe9VWObsb8F3Gn79vnkLXe5qdsrzjITFSA5mWGrELcbfIckN7SLETWkCClZnMXmEtsra6Jjq7mgWGQZiCBQa0Lv6+QEtoMma7i1xe23hw= Received: from BN9PR03CA0254.namprd03.prod.outlook.com (2603:10b6:408:ff::19) by SA0PR12MB7003.namprd12.prod.outlook.com (2603:10b6:806:2c0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 17:59:12 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::8e) by BN9PR03CA0254.outlook.office365.com (2603:10b6:408:ff::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:12 +0000 Received: from pyuan-Cloudripper.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 11:59:08 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 0/9] Implement AMD Pstate EPP Driver Date: Fri, 11 Nov 2022 01:58:38 +0800 Message-ID: <20221110175847.3098728-1-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT029:EE_|SA0PR12MB7003:EE_ X-MS-Office365-Filtering-Correlation-Id: 403fb5c5-5907-4ab2-78bf-08dac3454637 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SkAv6B15poU5Zym0g+HZ5gGZMGl2dv6+dufn/a6RSuP9JYamja0QgbrefrabBRJ0GCtD/aWXVUB4t67qPb7fPq+apyNaHdAoJxSclB9cxPkxxE9AezFyhJal8cMFf/V4hecsA23XkyLzwCRbms0kRCZb3rujgWK9OLvks3eqMA8ssiu7+B9lXYHB4wOCvxpYrJtHV3Q1Z3cD7DHDrIxpUSlrGzmzJLsaAcAm29QYbUAUqyf9Q3KJAq+GsRzDHMxAHTl2bSFEvgvvRr0qtoiuEUYnWJVl9RFM1CwGjU0MQ6hhKgn4RUruAAHrYNjrLzrm9MdXa7d19z4+Ro9egsL4KCcr399Nmn1KWsLR+s6yU7M76KzCC3nmV7Dy8fdy+OWz7FJRiW5x2MvFJZTMtrsaU7L1JrCcdvscAKydlwLpZcQsAcHjZznFLNj1ZoE9IdgwXWIk459/2E7pbKA15L3eeDDoMK2MylFB4Wkx9w26jlyb5leWmJpERGUJHft2VGyFcF06wblFA/7E/g8QiJpqx2Fj4Hxljxgl2mDyd4QnJcZxdRzwK+p1SSBFgWuH8rdGd2M3BLcwViYpjRmsV+WztMEDLRs/EzHn4opaGROWKtZzQCE3Dv/QmIutLDvuOzA7NcO/uIYvusw+7U94zd9uUKr6/z37VWopzF8a1vrpchBGjPO85Mr9ldwOCtr5y0KclefaDQtqLdWt1VJ9C8tHeu0dZ5wxOAsV9CDvpyPSAQ5Ajh4duhQ7vsGEfWN+3ft5tuBHXhErrqa+oOhuq8aEWRap57xh6lnK9dB0u2bPwBJj1H/WbVzsoW5MA6GNUyawRMH5C3ZZyVOd7ALS317xEFzlfXJaZBY9xEOFnawfs2oNudECV4/v8FK9HxdGKzWG X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(7696005)(86362001)(41300700001)(2906002)(82740400003)(47076005)(426003)(40460700003)(82310400005)(356005)(36860700001)(81166007)(83380400001)(186003)(36756003)(2616005)(5660300002)(336012)(16526019)(8936002)(1076003)(966005)(40480700001)(478600001)(6666004)(70586007)(316002)(26005)(70206006)(4326008)(45080400002)(8676002)(110136005)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:12.4234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 403fb5c5-5907-4ab2-78bf-08dac3454637 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.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7003 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749133427461846077?= X-GMAIL-MSGID: =?utf-8?q?1749133427461846077?= Hi all, This patchset implements one new AMD CPU frequency driver "amd-pstate-epp” instance for better performance and power control. CPPC has a parameter called energy preference performance (EPP). The EPP is used in the CCLK DPM controller to drive the frequency that a core is going to operate during short periods of activity. EPP values will be utilized for different OS profiles (balanced, performance, power savings). AMD Energy Performance Preference (EPP) provides a hint to the hardware if software wants to bias toward performance (0x0) or energy efficiency (0xff) The lowlevel power firmware will calculate the runtime frequency according to the EPP preference value. So the EPP hint will impact the CPU cores frequency responsiveness. We use the RAPL interface with "perf" tool to get the energy data of the package power. Performance Per Watt (PPW) Calculation: The PPW calculation is referred by below paper: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsoftware.intel.com%2Fcontent%2Fdam%2Fdevelop%2Fexternal%2Fus%2Fen%2Fdocuments%2Fperformance-per-what-paper.pdf&data=04%7C01%7CPerry.Yuan%40amd.com%7Cac66e8ce98044e9b062708d9ab47c8d8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637729147708574423%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=TPOvCE%2Frbb0ptBreWNxHqOi9YnVhcHGKG88vviDLb00%3D&reserved=0 Below formula is referred from below spec to measure the PPW: (F / t) / P = F * t / (t * E) = F / E, "F" is the number of frames per second. "P" is power measured in watts. "E" is energy measured in joules. Gitsouce Benchmark Data on ROME Server CPU +------------------------------+------------------------------+------------+------------------+ | Kernel Module | PPW (1 / s * J) |Energy(J) | PPW Improvement (%)| +==============================+==============================+============+==================+ | acpi-cpufreq:schedutil | 5.85658E-05 | 17074.8 | base | +------------------------------+------------------------------+------------+------------------+ | acpi-cpufreq:ondemand | 5.03079E-05 | 19877.6 | -14.10% | +------------------------------+------------------------------+------------+------------------+ | acpi-cpufreq:performance | 5.88132E-05 | 17003 | 0.42% | +------------------------------+------------------------------+------------+------------------+ | amd-pstate:ondemand | 4.60295E-05 | 21725.2 | -21.41% | +------------------------------+------------------------------+------------+------------------+ | amd-pstate:schedutil | 4.70026E-05 | 21275.4 | -19.7% | +------------------------------+------------------------------+------------+------------------+ | amd-pstate:performance | 5.80094E-05 | 17238.6 | -0.95% | +------------------------------+------------------------------+------------+------------------+ | EPP:performance | 5.8292E-05 | 17155 | -0.47% | +------------------------------+------------------------------+------------+------------------+ | EPP: balance performance: | 6.71709E-05 | 14887.4 | 14.69% | +------------------------------+------------------------------+------------+------------------+ | EPP:power | 6.66951E-05 | 4993.6 | 13.88% | +------------------------------+------------------------------+------------+------------------+ Tbench Benchmark Data on ROME Server CPU +---------------------------------------------+-------------------+--------------+-------------+------------------+ | Kernel Module | PPW MB / (s * J) |Throughput(MB/s)| Energy (J)|PPW Improvement(%)| +=============================================+===================+==============+=============+==================+ | acpi_cpufreq: schedutil | 46.39 | 17191 | 37057.3 | base | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | acpi_cpufreq: ondemand | 51.51 | 19269.5 | 37406.5 | 11.04 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | acpi_cpufreq: performance | 45.96 | 17063.7 | 37123.7 | -0.74 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | EPP:powersave: performance(0) | 54.46 | 20263.1 | 37205 | 17.87 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | EPP:powersave: balance performance | 55.03 | 20481.9 | 37221.5 | 19.14 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | EPP:powersave: balance_power | 54.43 | 20245.9 | 37194.2 | 17.77 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | EPP:powersave: power(255) | 54.26 | 20181.7 | 37197.4 | 17.40 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | amd-pstate: schedutil | 48.22 | 17844.9 | 37006.6 | 3.80 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | amd-pstate: ondemand | 61.30 | 22988 | 37503.4 | 33.72 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ | amd-pstate: performance | 54.52 | 20252.6 | 37147.8 | 17.81 % | +---------------------------------------------+-------------------+--------------+-------------+------------------+ changes from v3: * add one more document update patch for the active and passive mode introducion. * drive most of the feedbacks from Mario * drive feedback from Rafael for the cppc_acpi driver. * remove the epp raw data set/get function * set the amd-pstate drive by passing kernel parameter * set amd-pstate driver disabled by default if no kernel parameter input from booting * get cppc_set_auto_epp and cppc_set_epp_perf combined * pick up reviewed by flag from Mario changes from v2: * change pstate driver as builtin type from module * drop patch "export cpufreq cpu release and acquire" * squash patch of shared mem into single patch of epp implementation * add one new patch to support frequency boost control * add patch to expose driver working status checking * rebase driver into v6.1-rc4 kernel release * move some declaration to amd-pstate.h * drive feedback from Mario for the online/offline patch * drive feedback from Mario for the suspend/resume patch * drive feedback from Ray for the cppc_acpi and some other patches * drive feedback from Nathan for the epp patch changes from v1: * rebased to v6.0 * drive feedbacks from Mario for the suspend/resume patch * drive feedbacks from Nathan for the EPP support on msr type * fix some typos and code style indent problems * update commit comments for patch 4/7 * change the `epp_enabled` module param name to `epp` * set the default epp mode to be false * add testing for the x86_energy_perf_policy utility patchset(will send that utility patchset with another thread) v3: https://lore.kernel.org/all/20221107175705.2207842-1-Perry.Yuan@amd.com/ v2: https://lore.kernel.org/all/20221010162248.348141-1-Perry.Yuan@amd.com/ v1: https://lore.kernel.org/all/20221009071033.21170-1-Perry.Yuan@amd.com/ *** BLURB HERE *** Perry Yuan (9): ACPI: CPPC: Add AMD pstate energy performance preference cppc control Documentation: amd-pstate: add EPP profiles introduction cpufreq: amd-pstate: change amd-pstate driver to be built-in type cpufreq: amd_pstate: implement Pstate EPP support for the AMD processors cpufreq: amd_pstate: implement amd pstate cpu online and offline callback cpufreq: amd-pstate: implement suspend and resume callbacks cpufreq: amd-pstate: add frequency dynamic boost sysfs control cpufreq: amd_pstate: add driver working mode status sysfs entry Documentation: amd-pstate: add amd pstate driver mode introduction Documentation/admin-guide/pm/amd-pstate.rst | 66 +- drivers/acpi/cppc_acpi.c | 114 ++- drivers/cpufreq/Kconfig.x86 | 2 +- drivers/cpufreq/amd-pstate.c | 912 +++++++++++++++++++- include/acpi/cppc_acpi.h | 12 + include/linux/amd-pstate.h | 82 ++ 6 files changed, 1161 insertions(+), 27 deletions(-)