From patchwork Mon Oct 9 02:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Li X-Patchwork-Id: 15073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1621728vqo; Sun, 8 Oct 2023 19:50:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkutE9PjQ2uGUw1HEEXEPdJMiAKsdEMxpusWqpspLp9LagSFln016WvoICqdkh5v0N7Wpc X-Received: by 2002:a05:6870:2315:b0:1bb:6485:7988 with SMTP id w21-20020a056870231500b001bb64857988mr17239603oao.35.1696819839973; Sun, 08 Oct 2023 19:50:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696819839; cv=pass; d=google.com; s=arc-20160816; b=083uqoSunkM6wFeGhG8UCwJ9X8CeuKAUa3LnBB7fCsjlUd53Mzfi3AGZ+9hzZzN2qO l5zV7d29Wdm3QKmatX2844kIf7ocRIacXH5lqhHsS3L3NwazK+8LhNbF/eRuGafhLkQy D8ysy/J0EbmZOrsKLVKnmfiHmVtVRvag/TeeoR22BC5SyfFYOJTw9LPsuKjRKALn+cvS v0AmYb4ijU+gfHpGKTRd5igoTqC9iDaeXXjIY6gtKRZWEu0ncKjuMKzySDsQoJrjNyfy Lp/Tkfw+R5T/idw+OiZCXfQwebHfm7Uevhed1XnIBR+MR2bV13QS8R626+BGcKp689IA n8/w== 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=F5Hayc1H1AKOfEqLFqaTG1oIViw83FqMWU0AywWnwG0=; fh=Ux3YgDYVPXDd/Bh2648Da5vJU6LEkGipfecwSr9Umfo=; b=OnIdQ/Y3AWB/P6Lc6Ve0ttz3gZxN2aWiQ/3RQ31SWY6T7uFfsURJGzLOwf0UH+C45u YdUza/RQJrR2yhYGJanigokYC7QaRURBip17XbSE4peP/2BuC5nrAraB5aOo76i70AV0 EXrzQdCdrYnpDfSX0lhvQasP2t8MCIpzz7XLLSDshZCmR5ynOJdX/KNZo3fRPVcO2cuh efc1q0yTHjb3VehGbt5xAypnqDQhLrNS9yX9eTBSqrqo62pU3TNSkbp7o0Dbr5vlfKu7 aswzN5MmBWU2EeM6YRohTTD7o6MGsnfa5Koq1QaeLR2R6QJBeLGIBjELxlTbR6Vg1XdV xvnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=IM4JVZL7; 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::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id v2-20020a056a00148200b0068fb5ca50cdsi6774776pfu.126.2023.10.08.19.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 19:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=IM4JVZL7; 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::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 320508099CDF; Sun, 8 Oct 2023 19:50:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345033AbjJICuA (ORCPT + 19 others); Sun, 8 Oct 2023 22:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbjJICt7 (ORCPT ); Sun, 8 Oct 2023 22:49:59 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2072.outbound.protection.outlook.com [40.107.96.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83173A4; Sun, 8 Oct 2023 19:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3GpHuGNqGcOAmSCkKi2BxQ+/82no7gMXl4e3eKsqfpGY/dj46n75j7HaP9BCJOJ1p9iTKx3bg20OTlwiZOlfN5L8U7MDfo4txpFWhYez0a9dOxp4p9BX+bwJvWe59o+Z8EdVAKxtAWKbS5JU9BNXUCsHneKHzg3MviZL5yOGcrcz+ekFZDL3tCwSUm0UxJc43MpC4OCJGHjh/HyEsltjCYS9tCXv89VBcgW102O2tYtGhb6AoaH37s14j/8C/XDuiJ3g8j3RkeVjvf1qKHJFRqve9V4mjmw4wNYYb747YUfynHB0X/EHmQygckhL5lTHDBzsAEynWDZMumTlW5jaw== 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=F5Hayc1H1AKOfEqLFqaTG1oIViw83FqMWU0AywWnwG0=; b=L6Bnh+N1vVzTTk1uJrvoSi5uLO2w1jj9D2+Ba9bo9jspi6SYn0C/JGXu30PtH/Fc9S5Pwy4eUY2Xa1ZpC+WKTBTJ9Q+rSXf7bVXHidpqogmeDifamNsPlV9GXqEvKgTSQIgpL6ax/US40238a8OKxex2ZX5TQ6WYTtizmF28GRrdDVSr8zi0nxklLzTFV9vxDWWZITNSpbUjlTZTe4Xy6G+0JYAW2lwvAXWwGDI1IR2QMerjK2SB5f4Hs9DMoIJEUV+X8+YzK36YLlEOYhsl4AdcurrQRF8fU8MwqrWyWD1oqBCIMS5/0KdFSpNUiC4u6hBY77wYsPp0I3iKbp10ow== 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=F5Hayc1H1AKOfEqLFqaTG1oIViw83FqMWU0AywWnwG0=; b=IM4JVZL7REZtSWw2wqiwX00XQUW0+ZqqKVdN5sjGdNaZlaZwE4//u6ZMmTftFV0ZiNSeKkdvyN6EehGmbPCUW56WCKEyZ1Qac4KdLEipuwOTUae0QT6XrekxCsuURowRdIjT02Uw12n7qiV9Dtlun579nKij9oX52ruVx0WeVkc= Received: from SA9PR13CA0082.namprd13.prod.outlook.com (2603:10b6:806:23::27) by DM4PR12MB5358.namprd12.prod.outlook.com (2603:10b6:5:39c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Mon, 9 Oct 2023 02:49:53 +0000 Received: from SN1PEPF000252A2.namprd05.prod.outlook.com (2603:10b6:806:23:cafe::a5) by SA9PR13CA0082.outlook.office365.com (2603:10b6:806:23::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.20 via Frontend Transport; Mon, 9 Oct 2023 02:49:53 +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 SN1PEPF000252A2.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Mon, 9 Oct 2023 02:49:53 +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; Sun, 8 Oct 2023 21:49:48 -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 V8 0/7] amd-pstate preferred core Date: Mon, 9 Oct 2023 10:49:25 +0800 Message-ID: <20231009024932.2563622-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: 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: SN1PEPF000252A2:EE_|DM4PR12MB5358:EE_ X-MS-Office365-Filtering-Correlation-Id: 16388e59-00c2-48c5-7e07-08dbc8726a19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vSFxi2BwewJlUS44reFMyEEu5+sm59hGGyAWw1Q2XCbtYzoL2lv94N7IrGgvvoBRDsJQYVt7wv6QDplc84fnIOGSXW0ukpsrLg2RVMiDl3oo4Tz1jDklm6zSvg9vNZMPDXAbu3tFeSTG5rI77ajTXFb77gvp6EPlQZOniiFxJJDqiZnVz85pkgf64rWq5qteAlKGawXIx0pcZn1WdjXbYqJoJXeG9ZJ12+8vt1QHl3q6Xlt/L4xm5n2sz+pled+wbju/G54hKRoAKvU39O7sW1io5kyPju7LMoaw2lGcKVDYL6Yc0Wl53KYrI/2OFUBhomaPIE5kh9+Ki9m+rs75yqoNljR1Bwb6JZ7/p4c21HK+g8WLXXMt+1mgsSLyzDIKYKABChoG3Wkd8lHwLK/GjDt/aSGUwoLa4iFzUIglmxTn4ssixH0ue19x6aR3Y8bvIVUQ8rdXdTlTvHLu/+DSArVOugG6usW1rC6KFoHEwiR9decSf45tAILX6F9SlGUEzoZIDCZhMqk0MrNyTdONpJIbAF3fi5tq+j6pfa4OQpvCTd4ssED/cbQGtGqq+qdb5zfrIkHWegY20L+fPEXeEwwxqQne9zscXey3F4DZYq7vUZrUmOzFtDl1HUs9QtfYcaPShbG6DKv5ZRXydbwe8syUT5F2DF9da1Kuef1AuEhJWg5rRnaita6al2ykvkMKFV0NAz2q+5dTKAxGXFM+xbNICYh1Gf1BqkNEIiuGgpt9mtjIxbGjXtnlZV9sJrlkXTtUEflwJ2H1T15XB5NB5Q== 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)(376002)(136003)(346002)(396003)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(82310400011)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(83380400001)(1076003)(2616005)(336012)(426003)(26005)(47076005)(16526019)(36860700001)(316002)(54906003)(70206006)(70586007)(110136005)(6636002)(8936002)(5660300002)(8676002)(4326008)(41300700001)(7696005)(6666004)(2906002)(82740400003)(478600001)(36756003)(356005)(81166007)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 02:49:53.4314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16388e59-00c2-48c5-7e07-08dbc8726a19 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: SN1PEPF000252A2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5358 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 08 Oct 2023 19:50:13 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779244560122891324 X-GMAIL-MSGID: 1779244560122891324 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 V7->V8: - all: - - pick up Review-By flag added by Mario and Ray. - cpufreq: amd-pstate: - - use hw_prefcore embeds into cpudata structure. - - delete preferred core init from cpu online/off. Changes form V6->V7: - x86: - - Modify kconfig about X86_AMD_PSTATE. - cpufreq: amd-pstate: - - modify incorrect comments about scheduler_work(). - - convert highest_perf data type. - - modify preferred core init when cpu init and online. - acpi: cppc: - - modify link of CPPC highest performance. - cpufreq: - - modify link of CPPC highest performance changed. 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 | 59 +++++- arch/x86/Kconfig | 5 +- drivers/acpi/cppc_acpi.c | 13 ++ drivers/acpi/processor_driver.c | 6 + drivers/cpufreq/amd-pstate.c | 186 ++++++++++++++++-- drivers/cpufreq/cpufreq.c | 13 ++ include/acpi/cppc_acpi.h | 5 + include/linux/amd-pstate.h | 10 + include/linux/cpufreq.h | 5 + 10 files changed, 285 insertions(+), 22 deletions(-) Tested-by: Oleksandr Natalenko