Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2249156rwb; Mon, 7 Nov 2022 10:56:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM62rzKBGwUbA2j3uOKpxneA+pRSUn3j5e8NZ54eLpMDS7aI0B7Fa0e2vMb3/RV+KNPn2N+5 X-Received: by 2002:a17:902:e54f:b0:187:2e45:e190 with SMTP id n15-20020a170902e54f00b001872e45e190mr39884648plf.173.1667847419011; Mon, 07 Nov 2022 10:56:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667847419; cv=pass; d=google.com; s=arc-20160816; b=YQhVJsSdUrxEbUJG8HJsWxgcKOJQa03VpuzEcTvQu+bYgihUMsbfvPMxo3Jk2G2VIm KE93pvEUH4iLsVP+Au0FVVuJ07TcH400HUcJHFTU0puDaudOMy3EEJMoyU/2Ur05/uMn cIMIuf9U3cenNhcckwKYRcJMPl7Jd0kb4KboR3bxAOzHHpdxy4amCdg2bfqlVAT2KntS FQbiPIcae1NkBGDvNDOdTWL3LhKpIaH7SA2+zS//RME44PT+m9YMNOLsyWNyHnGbwpj1 0Xif0BWF7hBuUyq/yzXuDSnkl/qmcka8bIYo0GGBRPYNrHKqovAJyyrwppWgcTm5wP56 HvWg== 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=opm2FfIiUGw3NKGHHDxime4xsrF42yyrGk/B0QtrlYg=; b=c+dJvnWrmzyA9/QhRkgRSE9rMy+A+OvwzsaHJR+1QyXyfwHk0jM17GE8sRib7YHRse NBUrIkr3gU19SCq5KyFls4Owg74LZB3PlvNz5Pfdonm6Zis/DcnH3wI8VPA91wemGSsM WsE2hEawHimLWaRKjfLBpHEXUqVeatqZ/66z72ZVIP2PVpuGKi/PTgdCM28FWyw8REWf TK1vFNzJ4ThRsM3QqN+agsgUf7ZrL/i2NeFTzHMfcofT5zWl3/IUOvxcjoegNiWfOA+8 WMPLIHB6S9YkxlpfLAlLBI06z+EMF6/2ikkQcEqwl+eaKxD+Rsn6uHCB+XFwV3g73/k4 9l3Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=GLz4ihl8; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638b49000000b0046fabcda4easi11561714pge.555.2022.11.07.10.56.46; Mon, 07 Nov 2022 10:56:58 -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=GLz4ihl8; 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 S232788AbiKGSCp (ORCPT + 92 others); Mon, 7 Nov 2022 13:02:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233112AbiKGSB5 (ORCPT ); Mon, 7 Nov 2022 13:01:57 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2050.outbound.protection.outlook.com [40.107.220.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FC727162; Mon, 7 Nov 2022 09:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFaKKXXP42Tx8gUA1BXVTK+0qPtC1DGb+bZqJgPWco8LF4mD+8bcfkAkbatjhb4T4RAtruc7P+GpDDKNgqfqqKkhihHcEVK6FP8M/IQOtmGOzvam25MHF80g5u4RZ2FmAtNbcUD8+uXcAzm+yr9GifYXGYHPgGgvDvzde/tJWJ7E17KT01Y5t4kWwmjXgK01JVp9DvQ30AwsfiUDswFAZ6WvwQvl4M4mBkkR4CnutMCXbykPBFUKDgQrtuALyomKxu+VkBOBTBZvPOFUVKiXb3dIFAY3egHFaL0RWifZGOd1eVEANRY9stiyMeDLQZD3Vt21Y1sXOMouyE7HI5jy4w== 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=opm2FfIiUGw3NKGHHDxime4xsrF42yyrGk/B0QtrlYg=; b=PbBNwId9luciiqvYustlw+j9H1UWwcaQqXx7Lb5i0ncW886zvcGVsupEpFCxSBKAomwG9M0mRsaJkjUfes8DTrjBfPM/Pa/A+sDkFtNrAQYRQlnkSViIguOBYV4rGnRG1BOYCivpEwUrIFqNvvdwIvvASezzDWtiYWqVZ+AO9hhaCZBW1UAPftUQYk62G8TPOJchZ3QuD2MTG1S0bFpJgEjweipR92Oagd+v+cRAowVzvHfpJiTrUtt1nZZ6yiMlu/cwem3aZhiK8I9HY2j09ph+Jk5jmaa2nnogfhK3nLby9w6eqz0kh76QNA7VpJD9iILQpo/IaazS0HunbJnOtw== 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=opm2FfIiUGw3NKGHHDxime4xsrF42yyrGk/B0QtrlYg=; b=GLz4ihl8A7duLbSw2bZOkHrkFnacFDipxn0+FPqDl3a4CO9WXg/1OZ1suEiRzkWoNgYrhOW8tXO4HKaK7z5jHA/L0Oapj0RN59jtVrugndJr35oF1RffFS48LqlbXoFq244jIJcqaQG69WRvA+u36qJC+pcELJv6fjw0mDI6Diw= Received: from DM6PR02CA0119.namprd02.prod.outlook.com (2603:10b6:5:1b4::21) by MW4PR12MB5668.namprd12.prod.outlook.com (2603:10b6:303:16b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Mon, 7 Nov 2022 17:57:56 +0000 Received: from DM6NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::ad) by DM6PR02CA0119.outlook.office365.com (2603:10b6:5:1b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26 via Frontend Transport; Mon, 7 Nov 2022 17:57:56 +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 DM6NAM11FT041.mail.protection.outlook.com (10.13.172.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Mon, 7 Nov 2022 17:57:56 +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; Mon, 7 Nov 2022 11:57:26 -0600 From: Perry Yuan To: , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v3 0/8] Implement AMD Pstate EPP Driver Date: Tue, 8 Nov 2022 01:56:57 +0800 Message-ID: <20221107175705.2207842-1-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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: DM6NAM11FT041:EE_|MW4PR12MB5668:EE_ X-MS-Office365-Filtering-Correlation-Id: aa279a3d-2527-490c-00c8-08dac0e99997 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TLxhGrVEwxud0zSxv2BCHkvEB+BL4QgKPwQ0OiL8UcEi/HuiT6Ii9V+CpuoXeaTutnGPOM7O9mmh2SZcJKFEBhhNrdbVtqI1ru2BU1/Yv7EqBOP5txXZkhuAmf5JBPTccIa3hS38ndTrUgaiF1ekHl0ldYwIcMz/3BQ0WdHZIA+7LjRMNC1dQZkdCAymD+FQGSH+3W9q6ukSpUtgYNMHqet1j1Ry9yBfmWZ6wyoL0XdCn4aHKYoG7gQMnIQs6CYcZYBvP88QJWuC7r3avNL4PZJ+kMo4GomF96Ii+RON8yuG+IXDnsJ46K6gtpnomPLmmwOfJa4r3/BOc3JgEX+OGWsvu8DrBIK6N+gWN2NMSrDT1dsKtA0CuTBus1P45ITimYvkm9gP34t/tLEdDLiX2mVDdnkK/b385KEv4np6PZsGSlhlCahv4vcPDGB72nyQPmrAm6JPBfYCTfdwdMEO7LgXQMZN382zr1U2020r8PaslUPz3mjPsag2MwHu5FObQqQ73htk/AIceca6ptX82oFY1pWGMU/Ewhf/986j0erfR6WiowiOFJrJ4/B/qtP7nvaWRG4UP4ANDzr45e273bm31OhEkFccL6+leyihu3MAfutznVJ7LGwuncIwlusSxdXYhLkkGA/xnV8UxiYSHc5OnbTB9tEjci/6eNoB0UXFcEi3sF9ghJl0swpXd3wRMba66PflMdLFlIpmmZ+OCGacapPovVZxnPjlVlmCYadmzRN1hMEe4ScJhUu+P/hF8c1e6DXB3WXrwQgdrqsfr4dVGOMf72H76V5EBRA33XYV2eIzO10Kdi7vL2Z0ld+E6Xdi4Sfr7oKJRSCkqbsd+hdEQ3ZV5fu4LCMrK9yzaJj8Tvrsgu/8jboKs3eq8GfO0HFO8eP8ycbp9xGSXDeBpw== 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)(39860400002)(346002)(376002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(86362001)(83380400001)(426003)(47076005)(2906002)(36756003)(40460700003)(81166007)(41300700001)(70206006)(8676002)(4326008)(40480700001)(70586007)(356005)(26005)(82310400005)(110136005)(186003)(6666004)(82740400003)(316002)(8936002)(54906003)(2616005)(36860700001)(16526019)(5660300002)(478600001)(1076003)(45080400002)(336012)(7696005)(966005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2022 17:57:56.2288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa279a3d-2527-490c-00c8-08dac0e99997 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: DM6NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5668 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 From: Perry Yuan 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 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) 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/ Perry Yuan (8): ACPI: CPPC: Add AMD pstate energy performance preference cppc control Documentation: amd-pstate: add EPP profiles introduction cpufreq: amd-pstate: change driver to be built-in type cpufreq: amd_pstate: add AMD Pstate EPP support for the MSR based 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/admin-guide/pm/amd-pstate.rst | 19 + drivers/acpi/cppc_acpi.c | 126 +++ drivers/cpufreq/amd-pstate.c | 905 +++++++++++++++++++- include/acpi/cppc_acpi.h | 17 + include/linux/amd-pstate.h | 82 ++ 5 files changed, 1135 insertions(+), 14 deletions(-) -- 2.34.1