From patchwork Sat Nov 30 14:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846298 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) (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 ACA3A1990C9; Sat, 30 Nov 2024 14:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975664; cv=fail; b=j2xprfgXULUyljn84BNVCF4wMJK1MrtWvOHyWVBrW8aE3jucXND6V68IATB15UdE1pelucpTa4zYpkPkkUqXP1FBOahRKtwj8wakOcw3tDT+U5JjQStjp52Vq1mFJu1nf6i81pVsm4647FzOV49YuaoSD21BJNMu3xLgeXwFyfQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975664; c=relaxed/simple; bh=htJ6C6iIe2+2xs2Lzih1UffueevFwc4+pCim2iuMfmM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sjNnbPXZKqZhu+AUpOAuW2DYaNc/qJlHKh8znu2HYDz9A8ZWtD0imMOdG81+qP+/A6FtHnpz8axlVKIm5Jr+nYp6kEduMsoSCqlls8YZPFiRKKH4Gle48uaRDHDuxzz90UShzlnljDSGFnvj8BJN23ShojzGX8DHKFOnOh6bLUY= 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=ss6z/XMQ; arc=fail smtp.client-ip=40.107.220.62 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="ss6z/XMQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nh2A5pCPcYlwgEtJlrR+9b2KYIqmO+lPHiH+Rf3NWudkzR+FtsIgUR0lkTEFIOa1gha3WzTm/v+MW4/FJCnzqoJ+wBstM9bEd3cPp8tGrHbu+f5eTusawzSIpuYCNBMdWOrElCwUVVJCWfPRkXgs49yZDpHpPBxPjJneaQivTSUUD0zV4z/JU0xEdDZE7YTTAZvDYAtYoJl3adaw6mlj3zx93+/LYekR2Nlk49RD+KrQn7cG16WMDE/6RqQ7pzYMxKjmJbk0tsDGZAZU/SDPt1+rSOvctzWfXKfIEfR/ZDv1M1VlVRzxfIUGX8l3dqIaL/UaVFD1TIq7/FN0gvLNCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Yiv2S/pAPwqqzxx8/Yz6mRECdy9CirrlQK1Tyf2MfV8=; b=bFv5nLk3XfGsVsxZN0Jkzc9rrtJ5qsbd1aV70sHzQkAuw6uliKaZ58bwvRB7jmcq30wSk5JSljCPQ1xMVuF7Qh/tGqrCIm4u5Ulwe6vCg2+VWlnXFNEbxudiNf/xjbWUoIqR004TaJkKMpHtA+Wc1dcWH987p5nc6BpLr5yMo19hv+iCQEEumsXoAWOcc2ZmpAyYKybwv4Ns2X8XaNJ+7TbZgqlDJQEBemJbwHBPeWwWecOO16b2KYrGW4d9dtMJIGuhsUCp3owHsM8emLo22s2bn15Hf9Kyna+JqCl6M10Gxgq78lmqybayYlgXFd/eGzBhwAGudX+HYPvWeXm7vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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=Yiv2S/pAPwqqzxx8/Yz6mRECdy9CirrlQK1Tyf2MfV8=; b=ss6z/XMQlejpliwggwDUz2p1J4n9fX9vsqNKoRwwFZIiOZ0LHCcleuyfkkRUSB7NKyl49mBwyvkve780eRT9iqH1zo0sAaLEWyNKzgkzAx42fdyJJp1/iL9GxkPUXN7jaUAFwR5B5qt8aQ+Eksb9jXwgaeRwnerbXWEIUq/uAUw= Received: from SA0PR11CA0052.namprd11.prod.outlook.com (2603:10b6:806:d0::27) by SA3PR12MB7901.namprd12.prod.outlook.com (2603:10b6:806:306::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:07:39 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:806:d0:cafe::30) by SA0PR11CA0052.outlook.office365.com (2603:10b6:806:d0::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.14 via Frontend Transport; Sat, 30 Nov 2024 14:07:39 +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 SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:07:38 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sat, 30 Nov 2024 08:07:35 -0600 From: Mario Limonciello To: Borislav Petkov CC: Thomas Gleixner , Ingo Molnar , "Dave Hansen" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H . Peter Anvin" , "Rafael J . Wysocki" , "Gautham R . Shenoy" , Mario Limonciello , Perry Yuan , Brijesh Singh , Peter Zijlstra , Li RongQing , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:ACPI" , "open list:AMD PSTATE DRIVER" , Pawan Gupta Subject: [PATCH v7 00/12] Add support for AMD hardware feedback interface Date: Sat, 30 Nov 2024 08:06:51 -0600 Message-ID: <20241130140703.557-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C9:EE_|SA3PR12MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c241329-0c62-44c2-a88d-08dd11485956 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?yXawcpIffjKuu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Rz8?= =?utf-8?q?TYnWSRRboJ1GvfWS5yHJNTIcWpehWUWt8k2lGLtyTcOlV5UpfcsQ2+3W33yQpq/mV?= =?utf-8?q?6/rqBIz5pTEb/SDd5gz3UgWqu5cytr9pEAsivLk4C4sarHO9mmGHfE1tla9DVhCmY?= =?utf-8?q?hGMpEMrMMbURxzNwLBVKppNB1DHSyGhMvFVWMEfC7ayIulPR6nY0voiX8/otJmzPh?= =?utf-8?q?1G/fyjhNvzrvcLMaXtTcNPfNIhPMWicN/DPrnKCJbBVTSO2051pUnvrOIaJlFzgw7?= =?utf-8?q?HcUieQYMRb69E7Paxu+qsPJaqVw9xihyc9nk3RduuOspxY4qubPcF6T19qTvzvZso?= =?utf-8?q?aa2vfTQ9W0HUZKtCsQWLLcUCJztTzo4zjSDVyELxJeQvzzu666CayNAIi/UO9KKoP?= =?utf-8?q?Jo+3DR1h7PQgPYW68hC4IoVGY/tVKdnsOJDWTjBvcYA2aauA/yMl9csYt0S6oglNX?= =?utf-8?q?c0yhfX0pUkx5Rl0GyZPYH6EyU6eid2vcA4LzpMSUwdrlx1KA8jaQ21HoG3G7i4vlg?= =?utf-8?q?JgPN+c1/mRg?= 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:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:07:38.8772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c241329-0c62-44c2-a88d-08dd11485956 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: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7901 The AMD Heterogeneous core design and Hardware Feedback Interface (HFI) provide behavioral classification and a dynamically updated ranking table for the scheduler to use when choosing cores for tasks. Threads are classified during runtime into enumerated classes. Currently, the driver supports 3 classes (0 through 2). These classes represent thread performance/power characteristics that may benefit from special scheduling behaviors. The real-time thread classification is consumed by the operating system and is used to inform the scheduler of where the thread should be placed for optimal performance or energy efficiency. The thread classification helps to select CPU from a ranking table that describes an efficiency and performance ranking for each classification from two dimensions. The ranking data provided by the ranking table are numbers ranging from 0 to 255, where a higher performance value indicates higher performance capability and a higher efficiency value indicates greater efficiency. All the CPU cores are ranked into different class IDs. Within each class ranking, the cores may have different ranking values. Therefore, picking from each classification ID will later allow the scheduler to select the best core while threads are classified into the specified workload class. This series was originally submitted by Perry Yuan [1] but he is now doing a different role and he asked me to take over. Link: https://lore.kernel.org/all/cover.1724748733.git.perry.yuan@amd.com/ On applicable hardware this series has between a 2% and 5% improvement across various benchmarks. There is however a cost associated with clearing history on the process context switch. On average it increases the delay by 119ns, and also has a wider range in delays (the standard deviation is 25% greater). Mario Limonciello (4): MAINTAINERS: Add maintainer entry for AMD Hardware Feedback Driver cpufreq/amd-pstate: Disable preferred cores on designs with workload classification platform/x86/amd: hfi: Set ITMT priority from ranking data platform/x86/amd: hfi: Add debugfs support Perry Yuan (8): Documentation: x86: Add AMD Hardware Feedback Interface documentation x86/msr-index: define AMD heterogeneous CPU related MSR platform/x86: hfi: Introduce AMD Hardware Feedback Interface Driver platform/x86: hfi: parse CPU core ranking data from shared memory platform/x86: hfi: init per-cpu scores for each class platform/x86: hfi: add online and offline callback support platform/x86: hfi: add power management callback x86/process: Clear hardware feedback history for AMD processors Documentation/arch/x86/amd-hfi.rst | 127 ++++++ Documentation/arch/x86/index.rst | 1 + MAINTAINERS | 9 + arch/x86/include/asm/msr-index.h | 5 + arch/x86/kernel/process_32.c | 4 + arch/x86/kernel/process_64.c | 4 + drivers/cpufreq/amd-pstate.c | 6 + drivers/platform/x86/amd/Kconfig | 1 + drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/hfi/Kconfig | 21 + drivers/platform/x86/amd/hfi/Makefile | 7 + drivers/platform/x86/amd/hfi/hfi.c | 546 ++++++++++++++++++++++++++ 12 files changed, 732 insertions(+) create mode 100644 Documentation/arch/x86/amd-hfi.rst create mode 100644 drivers/platform/x86/amd/hfi/Kconfig create mode 100644 drivers/platform/x86/amd/hfi/Makefile create mode 100644 drivers/platform/x86/amd/hfi/hfi.c