From patchwork Fri Sep 8 07:46:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 720865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DF62EE57E0 for ; Fri, 8 Sep 2023 07:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237895AbjIHHrt (ORCPT ); Fri, 8 Sep 2023 03:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242250AbjIHHrp (ORCPT ); Fri, 8 Sep 2023 03:47:45 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2089.outbound.protection.outlook.com [40.107.244.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1479F19A6; Fri, 8 Sep 2023 00:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kXbVyz3M2Dn8jAW6NuaMZnqVk6T0/JS00c7LM8XMcs1j4CSkzUZTguRnHuTpMP6MGemF/og1ap1ElJdXzWUdjB7GyW/opczSPJLqQPaBqWKQPttGyU+03Y5NUHPPsajrxzUtOvFw5j7bJVu3FxdHJCv4kPA2D5tV32qGOXc+fsNjc7806qsZcvwxy10mfVSRPf3klBDBRjXErjuv1aPgpxNYH5pa9b3/yLtj0BCbSFMsq5k1/0EdXgYPXaXR4QfpFUpdhJ/prlFllArmQlOEGxgK8w956Yd3yZHop+7RIxOQSgHOC3Cqj1v3ZPSuayYtRT2xB4ZbD1ZP0l9brv6VUw== 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=IZo+3MpUdGdrltoHi0afN3O1C3raEb2dQB4PeFw/oTM=; b=Rs1FsWcoV2/bHk4U8oRokjNx6bGKa+zq7HMfIWplhrGhIfHI1OJGpFGf2Ec3gvHdOPXxILqImBL3IDrywOthRY7aI0XdcvXmJkG4uGS6iy96vK1B76HHWfA0MZj3g8I62B9HiCqL/hBj/y2xYQJUKsUFkxs/gPmrdRg29/uvmw9DQ3AjHCTkc7unPIkSeed4v3BFkc4diNel/wG5t8zG6JL+cj9WUbvjM6t4Zbcv+duTHPd/RMHWXFd5d6hngBOyi57/FIDMI4r/Qrl08RHb2S5Q4z4EzdRuRRrXd3WDQppZhFQI7D/RdMa8XqqhfWLVTFbB/zB7BYC9P79MmuD8FA== 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=IZo+3MpUdGdrltoHi0afN3O1C3raEb2dQB4PeFw/oTM=; b=wNuMOAA3ONOwv7lMyIhdRv4v+l8BuMGy55gAGLBHk4qu9FAQdHdwERMyLOn3lYC8ki4LNwxjkLp/uNxHTcqBxkzyLMALgnDcCt5/C/DYxmjmOsf4qB3q+Bik/QK2VztcWTOxEN5KWTgOsmCve48QDYNJxci977w+GB4E/GpdIqo= Received: from MW4PR04CA0194.namprd04.prod.outlook.com (2603:10b6:303:86::19) by SA3PR12MB7858.namprd12.prod.outlook.com (2603:10b6:806:306::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 07:47:38 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:86:cafe::7d) by MW4PR04CA0194.outlook.office365.com (2603:10b6:303:86::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30 via Frontend Transport; Fri, 8 Sep 2023 07:47:37 +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 CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.1 via Frontend Transport; Fri, 8 Sep 2023 07:47:37 +0000 Received: from jasmine-meng.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.27; Fri, 8 Sep 2023 02:47:31 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , Meng Li Subject: [PATCH V6 0/7] amd-pstate preferred core Date: Fri, 8 Sep 2023 15:46:46 +0800 Message-ID: <20230908074653.2799055-1-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000044FD:EE_|SA3PR12MB7858:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f4b033a-a363-4151-3e38-08dbb03fdf53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 41t+aL4hnl/CBK6XV/4GWuc/quu3yswXw6jbKWfm+Mvu91v6pplwulbEFrfZEifcwfbsUbNJQvpWNRWFFohdNo0pZ382LUrY31nfUTOU14/WLOe2dbFT/k2AfJKwXvYcFiVisXnQIvNrk1+8jSgMPgbxLJ/DvD+Kj3Nfvv+x1zGOABf0Bskh23O6wSie8sVSfJgzLUKH/Ve6xtk/jQNLu8tjcROky4snRK5C+mOHoEs5SH8duNwWiE72kvlBqYdituZbN4LhCy5SE5euBMRbR4UUn3Nnh3QNzyIY4GoL+/5yQQEsZkaHnf6catomuv+ju7IypCjWYdWu5mA9fEeJvf18q6tOXCDElHOmb4Ql6qTi+n4iwnj3YZdZ7CCvbAir6FjOhIEQe9QXWJ6/CqxJ2gbmzWti6ajbGZCbSdv94CVqPD/Kyvvj5FwZX72/HIE3MfTjpF6PU1VmRkqVHXlFYAyFgk6om48Qd8/NE9fvF7CFPKo8hlo0WGiv/I/RbKqfHInVT/NJJHcoSwSkbkBjTDuNoESZGArnQ6FsLDzHMCcQk2z8nLYvwJUn4t4XGGyEINiywz4zHwExmpwfupYxhEXarU3jhwci39pcwNbCLzZVP9apngAH+XI+erjLQYlsjn09kZ+p0ByICvOE2YXdmbqC7RCqRfqISlV2+dM7I6LhTZsDY8Z1r4g06y271higtBasOsMby5pUbOBIldW0fokV/Hmo6ny+pmzyB208+KftZaOYYWy9TItJIWh5oCTzXpVXmv5suabzMkzdiosRmg== 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)(4636009)(39860400002)(136003)(346002)(376002)(396003)(82310400011)(1800799009)(451199024)(186009)(40470700004)(36840700001)(46966006)(7696005)(6666004)(478600001)(83380400001)(1076003)(2616005)(26005)(426003)(336012)(16526019)(2906002)(54906003)(6636002)(316002)(70586007)(70206006)(110136005)(41300700001)(5660300002)(4326008)(8676002)(8936002)(40460700003)(40480700001)(47076005)(36860700001)(86362001)(36756003)(82740400003)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 07:47:37.7697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f4b033a-a363-4151-3e38-08dbb03fdf53 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: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7858 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Hi all: The core frequency is subjected to the process variation in semiconductors. Not all cores are able to reach the maximum frequency respecting the infrastructure limits. Consequently, AMD has redefined the concept of maximum frequency of a part. This means that a fraction of cores can reach maximum frequency. To find the best process scheduling policy for a given scenario, OS needs to know the core ordering informed by the platform through highest performance capability register of the CPPC interface. Earlier implementations of amd-pstate preferred core only support a static core ranking and targeted performance. Now it has the ability to dynamically change the preferred core based on the workload and platform conditions and accounting for thermals and aging. Amd-pstate driver utilizes the functions and data structures provided by the ITMT architecture to enable the scheduler to favor scheduling on cores which can be get a higher frequency with lower voltage. We call it amd-pstate preferred core. Here sched_set_itmt_core_prio() is called to set priorities and sched_set_itmt_support() is called to enable ITMT feature. Amd-pstate driver uses the highest performance value to indicate the priority of CPU. The higher value has a higher priority. Amd-pstate driver will provide an initial core ordering at boot time. It relies on the CPPC interface to communicate the core ranking to the operating system and scheduler to make sure that OS is choosing the cores with highest performance firstly for scheduling the process. When amd-pstate driver receives a message with the highest performance change, it will update the core ranking. Changes form V5->V6: - cpufreq: amd-pstate: - - modify the wrong tag order. - - modify warning about hw_prefcore sysfs attribute. - - delete duplicate comments. - - modify the variable name cppc_highest_perf to prefcore_ranking. - - modify judgment conditions for setting highest_perf. - - modify sysfs attribute for CPPC highest perf to pr_debug message. - Documentation: amd-pstate: - - modify warning: title underline too short. Changes form V4->V5: - cpufreq: amd-pstate: - - modify sysfs attribute for CPPC highest perf. - - modify warning about comments - - rebase linux-next - cpufreq: - - Moidfy warning about function declarations. - Documentation: amd-pstate: - - align with ``amd-pstat`` Changes form V3->V4: - Documentation: amd-pstate: - - Modify inappropriate descriptions. Changes form V2->V3: - x86: - - Modify kconfig and description. - cpufreq: amd-pstate: - - Add Co-developed-by tag in commit message. - cpufreq: - - Modify commit message. - Documentation: amd-pstate: - - Modify inappropriate descriptions. Changes form V1->V2: - acpi: cppc: - - Add reference link. - cpufreq: - - Moidfy link error. - cpufreq: amd-pstate: - - Init the priorities of all online CPUs - - Use a single variable to represent the status of preferred core. - Documentation: - - Default enabled preferred core. - Documentation: amd-pstate: - - Modify inappropriate descriptions. - - Default enabled preferred core. - - Use a single variable to represent the status of preferred core. Meng Li (7): x86: Drop CPU_SUP_INTEL from SCHED_MC_PRIO for the expansion. acpi: cppc: Add get the highest performance cppc control cpufreq: amd-pstate: Enable amd-pstate preferred core supporting. cpufreq: Add a notification message that the highest perf has changed cpufreq: amd-pstate: Update amd-pstate preferred core ranking dynamically Documentation: amd-pstate: introduce amd-pstate preferred core Documentation: introduce amd-pstate preferrd core mode kernel command line options .../admin-guide/kernel-parameters.txt | 5 + Documentation/admin-guide/pm/amd-pstate.rst | 58 ++++++- arch/x86/Kconfig | 5 +- drivers/acpi/cppc_acpi.c | 13 ++ drivers/acpi/processor_driver.c | 6 + drivers/cpufreq/amd-pstate.c | 161 ++++++++++++++++-- drivers/cpufreq/cpufreq.c | 13 ++ include/acpi/cppc_acpi.h | 5 + include/linux/amd-pstate.h | 6 + include/linux/cpufreq.h | 5 + 10 files changed, 255 insertions(+), 22 deletions(-)