From patchwork Sat May 25 15:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Du, Xiaojian" X-Patchwork-Id: 13674038 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2074.outbound.protection.outlook.com [40.107.212.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7223263511; Sat, 25 May 2024 15:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716649753; cv=fail; b=Z4Fr61+7V4ngVYz1YOqObNTeaezm3HQ0dHFCQfkvv4V4kH8uyJjtg3goepOJ8fOcSrskj36Xk5o16IKRIxv+gZmnUWPTk+/OmX36FVS5Mf7Q0LDqrwZYt3PnZ1+LraaazgG2OQAbECJtaUndEpOZxOd7+5PDKI5WxrBawA0sNt8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716649753; c=relaxed/simple; bh=z42PCPTgR6kkZwq3AIfc2sdgterATTz3rS7NmCSy6GQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=CVrFyL5uoHocoqMcXEkF02gzg88VUA8kuzEnElz1y5SzvwWuJ74MvPV27/FIwa9soMcn6mkOJMkyTJ+bwCpzeJBfAkxLzAr86DtxB0916HBMeKQXL0sPaXdOTLf54wg4DY/N9zeVYhhQYoQ04CHPT1o8wwX+8sF5A1bp7jmMVe8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=xQlt1QYz; arc=fail smtp.client-ip=40.107.212.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="xQlt1QYz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i2Fl3ZpsV0b772D4PB3nsY0T7LOAkvCSga/GQRyInV3N2OHrhjqC/R0GJvXdzwS5acaXb1Z2/ahWpU4kAbYcBDF/VFBTCz9miGsuovCIVptvCa6R461Yzb/gvq2DbO1cEW6xYmeW3DwJlYuU/sTQE7dHq6QrCKVlpzY6kbLs3m5AO5+qJYHt1XzpzNxi+wSOe7OyDk0a2PDV/2+n6TOUPnztF2HpKPZsove4VECTag2LhWTxAlhBJof2HrfOoq+k/q6uG3Owvlx6nnbNcytkrkvMsst1ZR/m+00uKUeY6L5hiMfspcd2EtXpmMFrgAu/TXq7KaFfXIvPjXLaluQmKw== 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=XjfupuBqvThwqT60Ng7knWgnSbYK1tIFFdheAfpv7u0=; b=Aa836QOIWOsZgVjPMBiwQ8tNOy3O5fH7CJaxEML27lVWLcp/dp/cWuSDYYwc3N9qf39irmJGd9K78Oru0DwisW/Ce4SO3vtKJE+AKS4lB20VyN+FlGiu3lESj4A1w3W+div1iX5OR2HU1QjRfY6loiMT13cFyDAVDD7CNfmXGXkksuhdavJCtzgxaxBtpTWS42X98sws1JvTUe1qtf6VyeftKGJNLaafiEW/pSVEzKYWZafRkDKvT7790w0zKKKQ5vLFSo1LKdyK/sVGBC1ycEfKu9CTVEL+d7IkKeTFGHb46WPyGKbryCpfY1bOrZas+JWTNiJxFgeMjszp6EHqug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=XjfupuBqvThwqT60Ng7knWgnSbYK1tIFFdheAfpv7u0=; b=xQlt1QYzPYIi+KfrKk/LSSs6ggNm37YzKpJ1gaPFmicVDtaYkuWgZRxUF5WBA4w7SIAoB+LqNGaoL7i3ZFJ90zfRc8NOeDbXJC7X+o8U6GH0GkZog/gYjDG3lXI0w16bKdz6lYACjbmWLO5tD+4IiCjgGcY0H/nrU9ofSeqnhWU= Received: from CH0PR03CA0283.namprd03.prod.outlook.com (2603:10b6:610:e6::18) by MW4PR12MB7336.namprd12.prod.outlook.com (2603:10b6:303:21a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.28; Sat, 25 May 2024 15:09:07 +0000 Received: from DS3PEPF000099D3.namprd04.prod.outlook.com (2603:10b6:610:e6:cafe::74) by CH0PR03CA0283.outlook.office365.com (2603:10b6:610:e6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19 via Frontend Transport; Sat, 25 May 2024 15:09:07 +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 DS3PEPF000099D3.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Sat, 25 May 2024 15:09:07 +0000 Received: from jenkins-amdgpu-chagall.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.2507.35; Sat, 25 May 2024 10:09:02 -0500 From: Xiaojian Du To: , , CC: , , , , , , , , , , , , , , , , Perry Yuan , Xiaojian Du Subject: [PATCH v4 1/2] x86/cpufeatures: Add AMD FAST CPPC feature flag Date: Sat, 25 May 2024 23:08:43 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS3PEPF000099D3:EE_|MW4PR12MB7336:EE_ X-MS-Office365-Filtering-Correlation-Id: bd23b300-d8f9-4b39-a1e3-08dc7ccc9fbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|7416005|1800799015|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: lw+f7ByiyX1jFbL+GpsO0cfHUua3Gg/z07Rj1bBKELB1KhQMSh1WeeBwJzYzaZvr4dF0wgknwT0eTLeO3QoJpQ6F6hI352YlrqhVdQRJoDEM3VSrk7jMErHC8ocl0PSD6IOTh9CPaqieaFHq6KqWSWWMC0xwg1nosm+ZMHq6HP/LrVwDBehWjJ5naOu/n6ycsbylXZTMI18/1/yBrMdg5+QQig14flaQ+3RUk0sYO1UkKtDrKSsqFn1vFSWrQKWxYLo/UYgRgiS+u5ElRgggiFUfg7M/k7yNsGdUYpZ5N2FPxeR/JBAUfFiihNQAmD3AH5mYROPta+QrseJJwRzeOEGogJNeV5aj/GegFSNeT42uTNqgvtG0hxgb395njFEyXq/H1MhxAL/G4zdhgLjA0cLqzoHM0IH6Aug/+AzU66ksbjB6EQk70QndG7asfhyN3pdCqGFAi9+NQJNb6OOqopCeSZcJxQr18vpjG/PBXTPjNp9tjf8EUrLZnn42Vt1KsoCF5vH5TYF2uMPaG2ue1QJnOAlDD6Ih8x9N/45aV5DwBYfFA3yrQNQnxVanvMwBNVHnk5u1I5s7MPpu/v0LD3/l7KT6CDrCZaLYQzYZ7UnD6fT86X3rkZA3cEYgkDNe9xCS8zEM1zKm2RVegu0rK426cvOh2APHibBzP2eX2FjVNAaEMeyXdURCWlsYbJB9QwQiHi5demn+bmFNvFpTImt+mD20QQA8Fkzp7J/FZIx9Y2PqBZhDvEyYAlcMuiNiS2NuVYVxO8myIZnHghZFNX1pAPIZwLRypSzi7KfbJ/GjH5o43t37APnYWs9p+c5f6hVou8z3wb63EGEDMMed7zwguDXMpcYyoj+FMnuKWRdibddcPNGGSJLpTSFaf4+tmDouIk6LMfNHgMVPQqpcKhUWg98R2GFa/IYmA6tVbC3Oz+guS3MTU1zd6pLo/XjnEVBvdUYYgs0BqeyZAqqZEBCui4IVsAwa0367x4WZI0AOPxsf0R62zrfVlCrA1TSJBriHatbpTcTzIq3+cHzDq5h6BIT/Xsgd9j+xOeU4FaNWuYLluMjF26coK8QbYL3a6prXx3NRuDcZo6qFbvg45Di2KlcZGbVHpxkq3X2FiHs3z6hoO7irxFrdUCmZ+lN02IoVx8d/IQrFTl7wqFcm3bIW3tIHNFzzxPFlnnDzWj5I+uN3+t4eBbBkr7HUHLFjkY0FxNVZqcspxvIbj45TYTcB2zhrkNEvLyJgQ/0g6oRPAZCQ3hcguP5dJbcLuDBCXkTdTRpdPZUvWbVAmEhZW5Z5WT/I8eYOwbBhcaAmBJpO1/sFnYUzE8WZ299FQZ+GdZ2XB+bQOcdgzXNwmzb67LaDHKCz8EUzZfSdhgFyvzpRwZiFvTW71z1yTjMBBPdo 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:(13230031)(376005)(7416005)(1800799015)(82310400017)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2024 15:09:07.3942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd23b300-d8f9-4b39-a1e3-08dc7ccc9fbc 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: DS3PEPF000099D3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7336 From: Perry Yuan Some AMD Zen 4 processors support a new feature FAST CPPC which allows for a faster CPPC loop due to internal architectural enhancements. The goal of this faster loop is higher performance at the same power consumption. Reference: See the page 99 of PPR for AMD Family 19h Model 61h rev.B1, docID 56713 Signed-off-by: Perry Yuan Signed-off-by: Xiaojian Du Reviewed-by: Borislav Petkov (AMD) --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 3c7434329661..6c128d463a14 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -470,6 +470,7 @@ #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* "" BHI_DIS_S HW control available */ #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* "" BHI_DIS_S HW control enabled */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* "" Clear branch history at vmexit using SW loop */ +#define X86_FEATURE_FAST_CPPC (21*32 + 5) /* "" AMD Fast CPPC */ /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index af5aa2c754c2..c84c30188fdf 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -45,6 +45,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, + { X86_FEATURE_FAST_CPPC, CPUID_EDX, 15, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, From patchwork Sat May 25 15:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Du, Xiaojian" X-Patchwork-Id: 13674039 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1D1963511; Sat, 25 May 2024 15:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716649761; cv=fail; b=C2gHgDYNDf1+SJOwWKhXGRtvS9UuC6FJmR14GRlDhkk+lI0O1ql8QbXiRKl+qpxfADFmzWZTw2KRPv3Rgw+7iA8Uyz0NPoSAlcyLKmNpn6BG0kNMdzT/m718gbQu32rjWJ9R8+D4IQv5vGYfV5rPWvB5IfajYzi40ED+XH+Fp1Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716649761; c=relaxed/simple; bh=5W450A4OA/tDPi8v3Hq/hsuNj6aqeScgGT/+R0I2qe4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pJqzqp6Avez/EJc413EOxZ0CaufNmArOJJvHSgpR4gVcRKYR2Hv+pPLNmWWdaGvjHSOYe8PbKdyM0enEbdIX5FfBRkwS3tkfBQG9VO1aMSwTPbBejJvJ1N37hF5X5AJBHAyya8VwCRcaI1hksbnySE/dmUzMrXNDc+1feHQiXd0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=jm5/bV6X; arc=fail smtp.client-ip=40.107.94.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="jm5/bV6X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+tAq8wEMpAGFBSguXaRXAevNQXZ3K2+9Uaij/PHxZUb3AWxji/xb5il3hDImhgAbrBHA22njtLFoOuAlyUgTSQZ9aH844PV1STc+XsxNj7G44kuwwU7qVD2nk8vMHXDuYpIIVDIUEjH1DjS4zhX3dOXySqkNZ9sxVOME1/lkv/ws9ygHbUrVIj7AIqAfI4fHFa8sFooCtxr1j/+IAItFEFtSzatp53pKHd2y2fDLGO6/wL1+9kb2q2PTMTEC6lUgkj8TPFgrT0kkg1t+k8KNoxiw2Tkvh5Q5Bh6LM51bkWxunyfaBUNOcGekkyxso1J2g6cCgM8daVhANZ+wcxa4A== 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=sYADc4a0EGMHe4KFR/rNv9z2oEHxbArNMIpqnfe4MIM=; b=JlQzNIt/qcFt3w2KGTzgGt7NE44sLlckbw4sl11x0UMs+AY3Totj9uzy2343d162Xh1NnzAy1h/s1F1gj7XDLqltc0sYH1JJYjA/ODJhB5RdxRbJID3YN0StgDjSlAkQBZnzcItMqFIuVuOpnKWdETtg6IDdj8VCuZeZv+uzFpdsXYZ9zclV7jBy8Hu3zyBkMKgWDF2BrpIDklD2AL7ETUKT6CPN31r0cLbZpg2Zsgn26OuDnz5v5aI8cBwjzemEniI9F6aBzDURgcizpwAR2DtSD8legwcdNKwclQ9cB07scIS2XzcJM4AqeZWyi2mLeb6Ov6kDP3pzOOcnNWCW+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=sYADc4a0EGMHe4KFR/rNv9z2oEHxbArNMIpqnfe4MIM=; b=jm5/bV6X+cEDQDUeDqc2K5N3OGaUb3lvT0ZWRB0yYu0UxK/cQsNxbe2pqj55/k0lD3Bp585dNXeEODwVUjml4iqXVa2mtK1Tu+ZS8TRwAm/eaElZmNeU/shRFAKpQgkjk/4SkX9qE13fPiQmCym0SCO50NNld4nUXgDn3XKaEQM= Received: from DM6PR01CA0030.prod.exchangelabs.com (2603:10b6:5:296::35) by PH0PR12MB8125.namprd12.prod.outlook.com (2603:10b6:510:293::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.27; Sat, 25 May 2024 15:09:12 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:5:296:cafe::5e) by DM6PR01CA0030.outlook.office365.com (2603:10b6:5:296::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.27 via Frontend Transport; Sat, 25 May 2024 15:09: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 DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Sat, 25 May 2024 15:09:12 +0000 Received: from jenkins-amdgpu-chagall.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.2507.35; Sat, 25 May 2024 10:09:07 -0500 From: Xiaojian Du To: , , CC: , , , , , , , , , , , , , , , , Xiaojian Du , Perry Yuan Subject: [PATCH v4 2/2] cpufreq: amd-pstate: change cpu freq transition delay for some models Date: Sat, 25 May 2024 23:08:44 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS3PEPF000099D7:EE_|PH0PR12MB8125:EE_ X-MS-Office365-Filtering-Correlation-Id: 63ce6790-8223-427e-1482-08dc7ccca2c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|7416005|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: PAHShkiOQMfngff6UMaEI1UF3Fun8GGxAl1kM6VcolDtxRzU+o5iPkopR6FfDZBn3WNuAkDIPRdkVj8gnUXQNYIFWE7UUfHuH+ZzY1QgamN/iUaCJUIjgvupzFZ0mHnCsPmjSCxUWszhFaKIpLaGW9NdDzkunMkK+0ZNpheQ5xrXYorc7SogCS2Mc4MOIkh3ZP+ENORS+f4ok1RpG6zKLne9CHZR1MR9FmHGSM/Ch7taPO8kq3uCGdDGDZMFVXbaFi4wlJsrzRxyx5O7sgeHwBzkFeCHi2dlZNZ/rzbaLc+NGnBxKU5nO2lj7CsV2fYZjhsUFreTQCqajzOpieobfXXrhdDAMr1FICAgr7kBksiqaLgK/rxuM+u5ARdpGp/9pkWN2dkzzKoTNnRNP6YqVtf65oIQh/WYdboEpBMWqduBgxhEF3Y+QNwbaU3cu7Ocx1h6jYFCIZrp8yqeQj0Ue+A6MQbUZHNZ9iGY9h1KtVjnM/sOQkU5Mtz2ESRMa08fsKAOx0kjHzF/OvRyVi3+CU5qv2C4BfHHzYnNXcWNoztzdQxqvObwCHDut+H751lEAS0uxTGGQZuEJ66AUUss5zfz9q8TVFVBQhZFLc21Po2TZyk8ljgh+/BlcTJ3UTCFw/ChWb6WpqvIypIq7MtTfHYxSHLNrmgVSsIqsiDwjjgnN8Vp9ReGpl3h+vMxAHRlEwIHGrtYOUoyr6+snnOR4X4aQswYNdh92PqQ+IdSsTtihk99vNuVrxM0IeI06o+hG8U9hJfV0AwIPY2SRzcjRu1WGKgZ4to8fP0A6m9K/5Vhakxj1SO9Nzp8+IKR6dcjsQlBTAawrXjoCUwAiBKEFRLp3GEtI2ziLb4n/VLpGW7UAt7bGPtY+8Yav25LXDRkXyZ5s6w0Z635yOJk5EK+dBy3DjrzZlMEziUs8WkFX2u35JF1ITmpNghLUbCZhCjYEVaAtqRtb7Y7cIMRcPWxe2dkn5BhPwX1SkC6RYrMX/bmMqCvcQECKl6uO5gmzc830wkhsLq7t7TkyQBMsm2B/4YmIFA7mOKM56F66iaQqkMXYZ0HPFOYpgsSa334HGwo1et1Q14ksqhhjk0pqFUK0xA0+XAoyn36DtVEJp7i3Ha4To8hHDXV5tT0GEv/Ckhj9U7o5wnGUjXuyiC2+z3k58vLrkkIwmb05/UObk4WE2cgXeQVhaPV15cY77zx+xiQMQ2CqLnkUirvhAf7JNfMbDwSFSoPCSVsBVBX++wBs4MFV3QPA4RUf/9kSk9RSXkA6k8etEjCeX3AepkbvsC4QKD+EFhPrw24C/AHPAgGGp9EOOWG1aE33fczMuSV1A83R+DCJ3Zvs0fZFvkxYmBYXnEM03tPWIDJ1OjjMrMBCGk= 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:(13230031)(1800799015)(7416005)(376005)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2024 15:09:12.4787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63ce6790-8223-427e-1482-08dc7ccca2c2 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: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8125 Some of AMD ZEN4 APU/CPU have support for adjusting the CPU core clock more quickly and presicely according to CPU work loading. This is advertised by the Fast CPPC x86 feature. This change will only be effective in the *passive mode* of AMD pstate driver. From the test results of different transition delay values, 600us is chosen to make a balance between performance and power consumption. Some test results on AMD Ryzen 7840HS(Phoenix) APU: 1. Tbench (Energy less is better, Throughput more is better, PPW--Performance per Watt more is better) ============= =================== ============== =============== ============== =============== ============== =============== =============== Trans Delay Tbench governor:schedutil, 3-iterations average ============= =================== ============== =============== ============== =============== ============== =============== =============== 1000us Clients 1 2 4 8 12 16 32 Energy/Joules 2010 2804 8768 17171 16170 15132 15027 Throughput/(MB/s) 114 259 1041 3010 3135 4851 4605 PPW 0.0567 0.0923 0.1187 0.1752 0.1938 0.3205 0.3064 600us Clients 1 2 4 8 12 16 32 Energy/Joules 2115 (5.22%) 2388 (-14.84%) 10700(22.03%) 16716 (-2.65%) 15939 (-1.43%) 15053 (-0.52%) 15083 (0.37% ) Throughput/(MB/s) 122 (7.02%) 234 (-9.65% ) 1188 (14.12%) 3003 (-0.23%) 3143 (0.26% ) 4842 (-0.19%) 4603 (-0.04%) PPW 0.0576(1.59%) 0.0979(6.07% ) 0.111(-6.49%) 0.1796(2.51% ) 0.1971(1.70% ) 0.3216(0.34% ) 0.3051(-0.42%) ============= =================== ============== ================ ============= =============== ============== =============== =============== 2.Dbench (Energy less is better, Throughput more is better, PPW--Performance per Watt more is better) ============= =================== ============== =============== ============== =============== ============== =============== =============== Trans Delay Dbench governor:schedutil, 3-iterations average ============= =================== ============== =============== ============== =============== ============== =============== =============== 1000us Clients 1 2 4 8 12 16 32 Energy/Joules 4890 3779 3567 5157 5611 6500 8163 Throughput/(MB/s) 327 167 220 577 775 938 1397 PPW 0.0668 0.0441 0.0616 0.1118 0.1381 0.1443 0.1711 600us Clients 1 2 4 8 12 16 32 Energy/Joules 4915 (0.51%) 4912 (29.98%) 3506 (-1.71%) 4907 (-4.85% ) 5011 (-10.69%) 5672 (-12.74%) 8141 (-0.27%) Throughput/(MB/s) 348 (6.42%) 284 (70.06%) 220 (0.00% ) 518 (-10.23%) 712 (-8.13% ) 854 (-8.96% ) 1475 (5.58% ) PPW 0.0708(5.99%) 0.0578(31.07%) 0.0627(1.79% ) 0.1055(-5.64% ) 0.142(2.82% ) 0.1505(4.30% ) 0.1811(5.84% ) ============= =================== ============== =============== ============== =============== ============== =============== =============== 3.Hackbench(less time is better) ============= =========================== ========================== hackbench governor:schedutil ============= =========================== ========================== Trans Delay Process Mode Ave time(s) Thread Mode Ave time(s) 1000us 14.484 14.484 600us 14.418(-0.46%) 15.41(+6.39%) ============= =========================== ========================== 4.Perf_sched_bench(less time is better) ============= =================== ============== ============== ============== =============== =============== ============= Trans Delay perf_sched_bench governor:schedutil ============= =================== ============== ============== ============== =============== =============== ============= 1000us Groups 1 2 4 8 12 24 AveTime(s) 1.64 2.851 5.878 11.636 16.093 26.395 600us Groups 1 2 4 8 12 24 AveTime(s) 1.69(3.05%) 2.845(-0.21%) 5.843(-0.60%) 11.576(-0.52%) 16.092(-0.01%) 26.32(-0.28%) ============= ================== ============== ============== ============== =============== =============== ============== 5.Sysbench(higher is better) ============= ================== ============== ================= ============== ================ =============== ================= Sysbench governor:schedutil ============= ================== ============== ================= ============== ================ =============== ================= 1000us Thread 1 2 4 8 12 24 Ave events 6020.98 12273.39 24119.82 46171.57 47074.37 47831.72 600us Thread 1 2 4 8 12 24 Ave events 6154.82(2.22%) 12271.63(-0.01%) 24392.5(1.13%) 46117.64(-0.12%) 46852.19(-0.47%) 47678.92(-0.32%) ============= ================== ============== ================= ============== ================ =============== ================= In conclusion, a shorter transition delay of cpu clock will make a quite positive effect to improve PPW on Dbench test, in the meanwhile, keep stable performance on Tbench, Hackbench, Perf_sched_bench and Sysbench. Signed-off-by: Xiaojian Du Reviewed-by: Perry Yuan Acked-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 6a342b0c0140..aa157c2b8ba2 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -50,6 +50,7 @@ #define AMD_PSTATE_TRANSITION_LATENCY 20000 #define AMD_PSTATE_TRANSITION_DELAY 1000 +#define AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY 600 #define CPPC_HIGHEST_PERF_PERFORMANCE 196 #define CPPC_HIGHEST_PERF_DEFAULT 166 @@ -817,8 +818,12 @@ static u32 amd_pstate_get_transition_delay_us(unsigned int cpu) u32 transition_delay_ns; transition_delay_ns = cppc_get_transition_latency(cpu); - if (transition_delay_ns == CPUFREQ_ETERNAL) - return AMD_PSTATE_TRANSITION_DELAY; + if (transition_delay_ns == CPUFREQ_ETERNAL) { + if (cpu_feature_enabled(X86_FEATURE_FAST_CPPC)) + return AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY; + else + return AMD_PSTATE_TRANSITION_DELAY; + } return transition_delay_ns / NSEC_PER_USEC; }