From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391441; cv=none; d=zohomail.com; s=zohoarc; b=euXY6+Zl8PJbUsDvhpaQfrTwuBCESQLI62akhytzvbGhhzkaM/YDorEpXECT3DIgmpDzmrrn7t//Tji0uJ9TaiES0lh+8yniJmQ8p1QbVVkgjaR/aS9FA/m5Iv3YkQ0OqT8H9Bpek8Gq5s22cf3QRPhktMh5ztUCF3yQl2zeE7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391441; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=C4bQOqonwLq+dUY9pRXSFv40RmZwLnn4Ud/e2Ogl2sUk17BVhSQWC1ls9wXzQ9k6mbMAQJ/C/LklYhYQZl2X7CA1cFF11anYusgNip2y5+HgHg2JB4TRM4KU67stin2yYeLSTgN0q5Hldt20xM9ooVFaT86YbhD6+Ix5L1MRj5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391440952893.2141535074395; Wed, 26 Jul 2023 10:10:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570632.892600 (Exim 4.92) (envelope-from ) id 1qOi1m-00063M-T6; Wed, 26 Jul 2023 17:10:22 +0000 Received: by outflank-mailman (output) from mailman id 570632.892600; Wed, 26 Jul 2023 17:10:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1m-00063D-QO; Wed, 26 Jul 2023 17:10:22 +0000 Received: by outflank-mailman (input) for mailman id 570632; Wed, 26 Jul 2023 17:10:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1l-00062Z-Jb for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:21 +0000 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [2607:f8b0:4864:20::235]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4c9e991f-2bd7-11ee-b242-6b7b168915f2; Wed, 26 Jul 2023 19:10:20 +0200 (CEST) Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3a36b30aa7bso57651b6e.3 for ; Wed, 26 Jul 2023 10:10:20 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:18 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4c9e991f-2bd7-11ee-b242-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391419; x=1690996219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=krlaHJoIy3yBZiPoFJmrsH44untMDFcqlyD42tIv3J0pv1sayVDAZc3MYTKOUgkuGS QPdQK/0vaXkl655PX/IPtnDWBOgTDLQPo3kn2UstKajS8y+3wAyNEG+naNWGwMByi/lu wP14L80U5G0WULeBjTy3ECD/HyIkIYSshUjdMufVrdsSrtzB/nTD8VedVoUTd/Bi3Uv+ h6dWVD0sFSQirDp6RWdJlTjaaLdUayfHbsqYJJfqrLz+kMlJjQkoaW/fRPyWpNH/XDoy Vsc4pnaNr8JQGVkAd0AStuPZzKUgy8ZBY3AG81WtREZOKMckbgYm+CNad6fuzpxTsp8W c2MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391419; x=1690996219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vNQhWJqSLtysm6iaINr+s0i3gnrhiDBqgnXkQD6RBcM=; b=g+iUq6yMhpmwpJ8+MxQ/ZoJpY75xdHrsH4lP8OBwYCXhu/F/zLMxEQ87aJyqk6H9iq cTrGE8anW8Pp+UWzGOffcIftWaL5lRe97P1UUVTMytIb0UNwLOfXb9OMTF62SlFZQ6O4 9x0BdivppiP9pvLSUT/YVR+J83uqA+QxiWVb/EOcL5Irtss9cFQIbLFxIqiOYWyb8Fm6 rTB3FIfO6OpJhibmGHT7AgA8R0HEUTdUegR1+l44LRDW1QKRY+/nsaiI+62YNWd4drYR XsAGBJv68yEuJHOzEXR96x8vLVNIlH/5lPJnVBiyFv2NCavgve6nNEa10ETL1KVKk4+N /deQ== X-Gm-Message-State: ABy/qLYyrWhyhtoHIN/7PSkcC+Mtdjqoaos4AIy/jNCcdKnfPWLokDw6 iWpoIBowjAa7ZC6ykB+nfIbE4AhH+4U= X-Google-Smtp-Source: APBJJlFRa4l4v0YcVbLUCneCpGdNXFzCSJ8gSt8eoF0HC+kuPqGKrhColbbOUeFLOo40dYB+FiTYQA== X-Received: by 2002:a05:6808:2119:b0:3a4:25ab:eecb with SMTP id r25-20020a056808211900b003a425abeecbmr101465oiw.51.1690391418755; Wed, 26 Jul 2023 10:10:18 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich Subject: [PATCH v7 01/15] cpufreq: Allow restricting to internal governors only Date: Wed, 26 Jul 2023 13:09:31 -0400 Message-ID: <20230726170945.34961-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391443303100001 Content-Type: text/plain; charset="utf-8" For hwp, the standard governors are not usable, and only the internal one is applicable. Add the cpufreq_governor_internal boolean to indicate when an internal governor, like hwp, will be used. This is set during presmp_initcall, and governor registration can be skipped when called during initcall. This way unusable governors are not registered, and only compatible governors are advertised to userspace. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich --- v6: Add Jan's Ack v5: Check cpufreq_governor_internal and skip registration as applicable Remove internal flag v4: Rework to use an internal flag Removed Jan's Ack since the approach is different. v3: Switch to initdata Add Jan Acked-by Commit message s/they/the/ typo Don't register hwp-internal when running non-hwp - Marek v2: Switch to "-internal" Add blank line in header --- xen/drivers/cpufreq/cpufreq.c | 1 + xen/drivers/cpufreq/cpufreq_misc_governors.c | 9 +++++++++ xen/drivers/cpufreq/cpufreq_ondemand.c | 3 +++ xen/include/acpi/cpufreq/cpufreq.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index 2321c7dd07..67a58d409b 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -56,6 +56,7 @@ struct cpufreq_dom { }; static LIST_HEAD_READ_MOSTLY(cpufreq_dom_list_head); =20 +bool __initdata cpufreq_governor_internal; struct cpufreq_governor *__read_mostly cpufreq_opt_governor; LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); =20 diff --git a/xen/drivers/cpufreq/cpufreq_misc_governors.c b/xen/drivers/cpu= freq/cpufreq_misc_governors.c index f5571f5486..0327fad23b 100644 --- a/xen/drivers/cpufreq/cpufreq_misc_governors.c +++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c @@ -120,6 +120,9 @@ static int __init cf_check cpufreq_gov_userspace_init(v= oid) { unsigned int cpu; =20 + if ( cpufreq_governor_internal ) + return 0; + for_each_online_cpu(cpu) per_cpu(cpu_set_freq, cpu) =3D userspace_cmdline_freq; register_cpu_notifier(&cpufreq_userspace_cpu_nfb); @@ -162,6 +165,9 @@ struct cpufreq_governor cpufreq_gov_performance =3D { =20 static int __init cf_check cpufreq_gov_performance_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_performance); } __initcall(cpufreq_gov_performance_init); @@ -201,6 +207,9 @@ struct cpufreq_governor cpufreq_gov_powersave =3D { =20 static int __init cf_check cpufreq_gov_powersave_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_powersave); } __initcall(cpufreq_gov_powersave_init); diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/c= pufreq_ondemand.c index fbcd14d6c3..06cfc88d30 100644 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c @@ -360,6 +360,9 @@ struct cpufreq_governor cpufreq_gov_dbs =3D { =20 static int __init cf_check cpufreq_gov_dbs_init(void) { + if ( cpufreq_governor_internal ) + return 0; + return cpufreq_register_governor(&cpufreq_gov_dbs); } __initcall(cpufreq_gov_dbs_init); diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 35dcf21e8f..44fc4c58fc 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -116,6 +116,8 @@ extern struct cpufreq_governor cpufreq_gov_powersave; =20 extern struct list_head cpufreq_governor_list; =20 +extern bool cpufreq_governor_internal; + extern int cpufreq_register_governor(struct cpufreq_governor *governor); extern struct cpufreq_governor *__find_governor(const char *governor); #define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391456; cv=none; d=zohomail.com; s=zohoarc; b=EThnwpx0pKt+Sbd6alLuS+JDe/E1RplNR//YbxJtd55jOb+KpkGk+7tQdZtq5zCkK71xl8Htq4FjSa6EBs/n/uOcG/P1aTEEDlZyFi3GHfwsqWl3ygzkSNcSdL4Vbv9+4w3MJRJJUY/jvAIkyu3w7+dA+xD0ILWGecla5p4zcYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391456; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tj29XCVclI+6QGR1ahwKo+P0a4dIzt4OqPyhJ7hCJ/k=; b=is9TzirSjgJoP4M0rO3z+o3lxSK/7pRGJYmymZM1fjqQlfo64C0vMEV0/2eFItN9Juk7v727VWRcJ2hPMqAioFSDZEvzPRTjCo/Ylg+VX2naS037EmO8L8Ci7BKJxqJxDBX3hRw29cDtaL0SXuLUrDTecme3uIEe+kFsHFPvN+s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169039145649991.37361512827329; Wed, 26 Jul 2023 10:10:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570633.892611 (Exim 4.92) (envelope-from ) id 1qOi1q-0006LK-9v; Wed, 26 Jul 2023 17:10:26 +0000 Received: by outflank-mailman (output) from mailman id 570633.892611; Wed, 26 Jul 2023 17:10:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1q-0006L9-6n; Wed, 26 Jul 2023 17:10:26 +0000 Received: by outflank-mailman (input) for mailman id 570633; Wed, 26 Jul 2023 17:10:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1p-0005nP-2d for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:25 +0000 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [2607:f8b0:4864:20::72b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4e13bdb8-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:22 +0200 (CEST) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-76714caf466so3088285a.1 for ; Wed, 26 Jul 2023 10:10:23 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:21 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4e13bdb8-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391422; x=1690996222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tj29XCVclI+6QGR1ahwKo+P0a4dIzt4OqPyhJ7hCJ/k=; b=eiNoAZOOGxuceqVWp2ammLbsp+637AYhLdnzo/0ZgxzBvrtaq/7uczbqwToMHwCL9E oP32llNkDgxa8zP4LsbwJoqD16+zUHi78FHC9YjOSXyKZ5uxvGUOLg1nHOjC6wPD+zWi sYu5S4u6biDs31r7OwSU5St5l8xkNlmAUI/qPBnmWqh3lZzikIuv+yx1KV1zGv1tO3/9 fnrI4zs7ewI7Inv00OkJt0SxMICp3IxGFLEeRJZ74Z7gO3NQqLTmtkIh7mVao1N7DDUA RhoBzKygdg0ei/g21svSV5bhFi7J1W4MmMdIx+BlIOmk7ssiMESmezgf437BqkCeQFTV 0R+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391422; x=1690996222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tj29XCVclI+6QGR1ahwKo+P0a4dIzt4OqPyhJ7hCJ/k=; b=SPj/4Bd8rxqm+LULiosc7LsGRMJp6qIuStOoD/mOf0G73Zt/K3nhpVRWTVstH12GGn lq1YT4GVAIWahqv8NoHzySXRA5k5jsiCJOc8uLaX9aGZzsVSPTAjq0f4Ab5qk0eSts1c 9umej9Si+kYS5A8p1NgPVKQ7WLx7Ij3gjxx/3NkaObja1NhRvZNMOiRlufvPrzREBBPQ TRhw7IW6xg90vqC5D05aCdJKtWI42FurRyqf6lmYqMPxnQspAxVNq+BZJyW2uW1MRFeY cB9ZfZg11spYUSkCg/I59VAJVxK/iX2th3aGhKff7SRRKhgP4tZzGkEp4gSuNJasLAd3 xCdQ== X-Gm-Message-State: ABy/qLZTA7CmW33FaPhdklilMLFSEGEe0SOA0qcKvt+mIh9/JJuxhtfh Dst5MJqje9YWl5v4FV3urEmT7syTZi8= X-Google-Smtp-Source: APBJJlH48lxLuLRRThOdDWjI4a2VBOKN76LvDeNPxc5mjqX3/N56ultLiZRko5Yq4i6oiox/KX6AjQ== X-Received: by 2002:a05:6214:5294:b0:637:85e3:2a2d with SMTP id kj20-20020a056214529400b0063785e32a2dmr2779361qvb.58.1690391421785; Wed, 26 Jul 2023 10:10:21 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v7 02/15] cpufreq: Add perf_freq to cpuinfo Date: Wed, 26 Jul 2023 13:09:32 -0400 Message-ID: <20230726170945.34961-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391457089100001 Content-Type: text/plain; charset="utf-8" acpi-cpufreq scales the aperf/mperf measurements by max_freq, but HWP needs to scale by base frequency. Settings max_freq to base_freq "works" but the code is not obvious, and returning values to userspace is tricky. Add an additonal perf_freq member which is used for scaling aperf/mperf measurements. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich --- v3: Add Jan's Ack I don't like this, but it seems the best way to re-use the common aperf/mperf code. The other option would be to add wrappers that then do the acpi vs. hwp scaling. --- xen/arch/x86/acpi/cpufreq/cpufreq.c | 2 +- xen/drivers/cpufreq/utility.c | 1 + xen/include/acpi/cpufreq/cpufreq.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufre= q/cpufreq.c index 2e0067fbe5..6c70d04395 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -316,7 +316,7 @@ unsigned int get_measured_perf(unsigned int cpu, unsign= ed int flag) else perf_percent =3D 0; =20 - return policy->cpuinfo.max_freq * perf_percent / 100; + return policy->cpuinfo.perf_freq * perf_percent / 100; } =20 static unsigned int cf_check get_cur_freq_on_cpu(unsigned int cpu) diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c index 9eb7ecedcd..6831f62851 100644 --- a/xen/drivers/cpufreq/utility.c +++ b/xen/drivers/cpufreq/utility.c @@ -236,6 +236,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_poli= cy *policy, =20 policy->min =3D policy->cpuinfo.min_freq =3D min_freq; policy->max =3D policy->cpuinfo.max_freq =3D max_freq; + policy->cpuinfo.perf_freq =3D max_freq; policy->cpuinfo.second_max_freq =3D second_max_freq; =20 if (policy->min =3D=3D ~0) diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 44fc4c58fc..1f1898d811 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -37,6 +37,9 @@ extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS= ]; struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int second_max_freq; /* P1 if Turbo Mode is on */ + unsigned int perf_freq; /* Scaling freq for aperf/mpref. + acpi-cpufreq uses max_freq, but HWP = uses + base_freq.*/ unsigned int min_freq; unsigned int transition_latency; /* in 10^(-9) s =3D nanosecond= s */ }; --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391446; cv=none; d=zohomail.com; s=zohoarc; b=Pn3b5+wGdS0rBBzHuNYkvITIgr/jyU7B3glNUUShVBHhPXjjuybNZwcMXcMfGfjGoQ7GUvSoD8JMCoMiBAIz2K92nIfLth5dmA7sHyZ2bM7PgHshNgW2EizJrHC+h8I0vDue0cjNxZ4eG74rwD8iCZKtiOQLYm2P70k92ddPaiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391446; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6N7tHO/NpGPoNencisuqLlnFkoHrBAPddvPlzfIc1r8=; b=QWsZNhRyeOzKJbXwu9OWidcirLr2bfUHvep0tRq3PUuz2Y4jpma/W4FkfHjEgSb3wP5zpJfhlMve66LmIjte8SJEEQzeHy0hoc8n14n2Fc//oJgCEf7UVBM9hcdjKX6wTnJ68TskJt6LpoAakqX8ceWIfxM3Dlh5LbaZTRP+buA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391446289951.972581547992; Wed, 26 Jul 2023 10:10:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570634.892621 (Exim 4.92) (envelope-from ) id 1qOi1t-0006e9-Jx; Wed, 26 Jul 2023 17:10:29 +0000 Received: by outflank-mailman (output) from mailman id 570634.892621; Wed, 26 Jul 2023 17:10:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1t-0006du-Gn; Wed, 26 Jul 2023 17:10:29 +0000 Received: by outflank-mailman (input) for mailman id 570634; Wed, 26 Jul 2023 17:10:28 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1r-00062Z-Uu for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:27 +0000 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [2607:f8b0:4864:20::735]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 50c90e80-2bd7-11ee-b242-6b7b168915f2; Wed, 26 Jul 2023 19:10:27 +0200 (CEST) Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-76ae5b44426so2498385a.2 for ; Wed, 26 Jul 2023 10:10:27 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 50c90e80-2bd7-11ee-b242-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391425; x=1690996225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6N7tHO/NpGPoNencisuqLlnFkoHrBAPddvPlzfIc1r8=; b=CZom+YTmDnHiRp8FX7mQxKkFsjyAiG0xPZHEu7bkMTB673t77gvfq5VsZwXCsew/9w vidT6gQwl7G0G3a1iRR09VS5rr547Ztov18JL0StBbHpric4NvntKEpbV9k/Zr2BX7NX pzVN+3wQ1MrnlRgLsrjTidioCPwdL/ahTXW/lETGU8O1lUyQkl/Vp5xXpX5zMta3+qjP s9bRRlk3gtKw2HsHO7mJfCvH4JaENOMSqDYxoatmHWt38LtQ+CDYI/RTMiNdXoVbJUIh NSP3KYAIZyIJYyxSeX80IzJAlbqJgOGL0UXmE9wP/dxx4obr3KYrmV+RDgKiIUTgNn4D GTBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391425; x=1690996225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6N7tHO/NpGPoNencisuqLlnFkoHrBAPddvPlzfIc1r8=; b=k1VpMK4JIIjbDOSHMEZsL61ubNws6mKJ1EKNEN5xj5zGS/U1AUiCFr6PfTsGi+ON/1 tBwEQsovlKgmKibRRT/VBA7sf3gE1TU2HzMCkHctlFKgm2NjxUqc+vzrzkUMvYnE2q9L A/mTYn0Yp0IxvqrtiFNnTvfD3h0ABlS5iPn846dg/2knLdlI63XNakG+wEgUBbTtapmz c0Yc2HzBJq7a8pEStuujlA4gGpLVF49P9S5TopdC3oP9jwo61gcP2I2Iiu49dU1OwlHI 2SUOjoeY/eRw8Cd1tWFVOyj8WIP1F0//3A4b76YX19Xeshvlmhtkip2x9U4/nOKLQmSI fbyg== X-Gm-Message-State: ABy/qLYhTt41I2Ur/n3aTcYbjYZsvR5v4sGWBoFjjuq1JxLLpuRLqy7s HtQb90/Oa/if41K6dcg7hZuCFBXHWsM= X-Google-Smtp-Source: APBJJlHkSob2x7uUuh5jB8GE9zJTKb2Ot+bP8m9J4kEKe8C794coO7B/Sr8vfeQt0Ngm6wQ91Ljipg== X-Received: by 2002:a0c:e5ce:0:b0:635:f4e3:8842 with SMTP id u14-20020a0ce5ce000000b00635f4e38842mr2416231qvm.48.1690391425476; Wed, 26 Jul 2023 10:10:25 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v7 03/15] cpufreq: Export intel_feature_detect Date: Wed, 26 Jul 2023 13:09:33 -0400 Message-ID: <20230726170945.34961-4-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391447181100001 Content-Type: text/plain; charset="utf-8" Export feature_detect as intel_feature_detect so it can be re-used by HWP. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich --- v4: Add Jan's Ack v3: Remove void * cast when calling intel_feature_detect v2: export intel_feature_detect with typed pointer Move intel_feature_detect to acpi/cpufreq/cpufreq.h since the declaration now contains struct cpufreq_policy *. --- xen/arch/x86/acpi/cpufreq/cpufreq.c | 8 ++++++-- xen/include/acpi/cpufreq/cpufreq.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufre= q/cpufreq.c index 6c70d04395..f1cc473b4f 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -339,9 +339,8 @@ static unsigned int cf_check get_cur_freq_on_cpu(unsign= ed int cpu) return extract_freq(get_cur_val(cpumask_of(cpu)), data); } =20 -static void cf_check feature_detect(void *info) +void intel_feature_detect(struct cpufreq_policy *policy) { - struct cpufreq_policy *policy =3D info; unsigned int eax; =20 eax =3D cpuid_eax(6); @@ -353,6 +352,11 @@ static void cf_check feature_detect(void *info) } } =20 +static void cf_check feature_detect(void *info) +{ + intel_feature_detect(info); +} + static unsigned int check_freqs(const cpumask_t *mask, unsigned int freq, struct acpi_cpufreq_data *data) { diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 1f1898d811..482ea5b0de 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -243,4 +243,6 @@ int write_userspace_scaling_setspeed(unsigned int cpu, = unsigned int freq); void cpufreq_dbs_timer_suspend(void); void cpufreq_dbs_timer_resume(void); =20 +void intel_feature_detect(struct cpufreq_policy *policy); + #endif /* __XEN_CPUFREQ_PM_H__ */ --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391468; cv=none; d=zohomail.com; s=zohoarc; b=k5/iDUmNCqUjxTtEAwoCq6xTTaro4n7azs+UU3xiyVLB/S2jN+dol1WgWwtl9IfYTVT+JUNWJD15JNiwox5lmrGzlWz/Q5nvapGpzu7GpmmRITxcvX8GKNbMt4LctebWhxroHnjt+P4mscxDVslyNUsEoriBrcQMigv55EktHlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391468; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=htBvMGWbD3+u7hn1x0QKNR+1N7bjYI+3CVNCpwjhGVA=; b=NBrw7Q/uWLEt4hb5Bfl86A+ZzWD2GUOon9ksbVeK+kL58wDmEAK6lHQWVz2yIwEIkfbk1aIxTfGdeacwXhAt4vK580f0uoRKA3DAN9YohUKw8lT+BBk3uclPZc+qSfW7/So7st0pRz/gysHx22YoQbldreN07UKHMl6cj4+y+L4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391468620859.1406407061161; Wed, 26 Jul 2023 10:11:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570635.892631 (Exim 4.92) (envelope-from ) id 1qOi1y-00073u-Sj; Wed, 26 Jul 2023 17:10:34 +0000 Received: by outflank-mailman (output) from mailman id 570635.892631; Wed, 26 Jul 2023 17:10:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1y-00073n-PD; Wed, 26 Jul 2023 17:10:34 +0000 Received: by outflank-mailman (input) for mailman id 570635; Wed, 26 Jul 2023 17:10:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi1x-0005nP-NP for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:33 +0000 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [2607:f8b0:4864:20::f2c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 531ec029-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:31 +0200 (CEST) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-63d0bf91362so601996d6.0 for ; Wed, 26 Jul 2023 10:10:31 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:29 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 531ec029-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391430; x=1690996230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htBvMGWbD3+u7hn1x0QKNR+1N7bjYI+3CVNCpwjhGVA=; b=T831vii0YgY07Z83L01Nj+iwJhMaaz7XI15DD/yV3qoOJds9xxSNaNsCqjlrL43oCq 8tjSpqwX+QHZu1CG+QENU0kpzMfcgj4miZNkXbK6bP3W2yKpP16IdazuMPthLAc3jUFY YLE9EwjxaAU7PWVY6UFMenZiNDyfe9CkpUxji4dKUqXf0Efqq8IwCuI0qGYd76UH9bwf Vs+RxWaWld/Jakt8RxhMsUXC7jlGYsJUarxFRn3SnKQ2iwB45kIqOQHTHdrv3T7eBp6+ HbTZh2PtEo/923DvhctJGV0PmlDKDhyAO+t9kvakWD/lp7FKOpEZv6aJy/OzjhDC6Qq8 G2LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391430; x=1690996230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htBvMGWbD3+u7hn1x0QKNR+1N7bjYI+3CVNCpwjhGVA=; b=UoYoPGyG+OLEYXXK1HMxSYgOsQGoZihHrUr3KIvp6uvHG+4qcXGv65WIVx7rcJ16mr 5mX+1Mc3HiHQDp+gmEJdN8reL0mbzdl8SqMOMj/L5SN2dNpXUSuZIVZdIMkMDvXtm7ur Th02vLiHJ4PtVrO0z+cG9Xe3CReIC2+DnnNv3Spn1wefoYKG3DvfM0vHJEIoeRfIscP2 pfNWc90dxihXHGdxK5ZaRtFje8EaUQWkaJmnBA5/9KNa4XQoPgIV6YMzgqw5LqRCnlMt XWYhm42wKygPt1C9ibvSRf43SJIVFQbn+tYr3nxMGQhpJcyyIkxPCCNYWNhf5XLtMT6n wtXA== X-Gm-Message-State: ABy/qLZSckS7pPZ84YYKeXkRNr2UzU2d79Z3Y4i5hCTKIG7PWFzvNM3w dO1NOlK79L4S/7S5JYgiCXwESVijYro= X-Google-Smtp-Source: APBJJlEREOjNO2Sz+3O5ek1BYsZDupOCxHqMM3ho46YsPKPtLSo8vNBvKHt32oHt2UDSo7uGa9eDHg== X-Received: by 2002:a0c:d84c:0:b0:634:7c34:6c96 with SMTP id i12-20020a0cd84c000000b006347c346c96mr2056727qvj.7.1690391430198; Wed, 26 Jul 2023 10:10:30 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v7 04/15] xen/sysctl: Nest cpufreq scaling options Date: Wed, 26 Jul 2023 13:09:34 -0400 Message-ID: <20230726170945.34961-5-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391475930100001 Content-Type: text/plain; charset="utf-8" Add a union and struct so that most of the scaling variables of struct xen_get_cpufreq_para are within in a binary-compatible layout. This allows cppc_para to live in the larger union and use uint32_ts - struct xen_cppc_para will be 10 uint32_t's. The new scaling struct is 3 * uint32_t + 16 bytes CPUFREQ_NAME_LEN + 4 * uint32_t for xen_ondemand =3D 11 uint32_t. That means the old size is retained, int32_t turbo_enabled doesn't move and it's binary compatible. The out-of-context memcpy() in xc_get_cpufreq_para() now handles the copying of the fields removed there. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich Acked-by: Anthony PERARD --- NOTE: Jan would like a toolside review / ack because: Nevertheless I continue to be uncertain about all of this: Parts of the struct can apparently go out of sync with the sysctl struct, but other parts have to remain in sync without there being an appropriate build-time check (checking merely sizes clearly isn't enough). Therefore I'd really like to have a toolstack side review / ack here as well. v6: Add Jan's Reviewed-by v5: Expand commit message Change comment to driver/governor --- tools/include/xenctrl.h | 22 +++++++++++++--------- tools/libs/ctrl/xc_pm.c | 7 +------ tools/misc/xenpm.c | 24 ++++++++++++------------ xen/drivers/acpi/pmstat.c | 27 ++++++++++++++------------- xen/include/public/sysctl.h | 22 +++++++++++++--------- 5 files changed, 53 insertions(+), 49 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index dba33d5d0f..8aedb952a0 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1909,16 +1909,20 @@ struct xc_get_cpufreq_para { uint32_t cpuinfo_cur_freq; uint32_t cpuinfo_max_freq; uint32_t cpuinfo_min_freq; - uint32_t scaling_cur_freq; - - char scaling_governor[CPUFREQ_NAME_LEN]; - uint32_t scaling_max_freq; - uint32_t scaling_min_freq; - - /* for specific governor */ union { - xc_userspace_t userspace; - xc_ondemand_t ondemand; + struct { + uint32_t scaling_cur_freq; + + char scaling_governor[CPUFREQ_NAME_LEN]; + uint32_t scaling_max_freq; + uint32_t scaling_min_freq; + + /* for specific governor */ + union { + xc_userspace_t userspace; + xc_ondemand_t ondemand; + } u; + } s; } u; =20 int32_t turbo_enabled; diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index c3a9864bf7..6e751e242f 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -265,17 +265,12 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, user_para->cpuinfo_cur_freq =3D sys_para->cpuinfo_cur_freq; user_para->cpuinfo_max_freq =3D sys_para->cpuinfo_max_freq; user_para->cpuinfo_min_freq =3D sys_para->cpuinfo_min_freq; - user_para->scaling_cur_freq =3D sys_para->scaling_cur_freq; - user_para->scaling_max_freq =3D sys_para->scaling_max_freq; - user_para->scaling_min_freq =3D sys_para->scaling_min_freq; user_para->turbo_enabled =3D sys_para->turbo_enabled; =20 memcpy(user_para->scaling_driver, sys_para->scaling_driver, CPUFREQ_NAME_LEN); - memcpy(user_para->scaling_governor, - sys_para->scaling_governor, CPUFREQ_NAME_LEN); =20 - /* copy to user_para no matter what cpufreq governor */ + /* copy to user_para no matter what cpufreq driver/governor */ BUILD_BUG_ON(sizeof(((struct xc_get_cpufreq_para *)0)->u) !=3D sizeof(((struct xen_get_cpufreq_para *)0)->u)); =20 diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 1bb6187e56..ee8ce5d5f2 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -730,39 +730,39 @@ static void print_cpufreq_para(int cpuid, struct xc_g= et_cpufreq_para *p_cpufreq) printf("scaling_avail_gov : %s\n", p_cpufreq->scaling_available_governors); =20 - printf("current_governor : %s\n", p_cpufreq->scaling_governor); - if ( !strncmp(p_cpufreq->scaling_governor, + printf("current_governor : %s\n", p_cpufreq->u.s.scaling_governor); + if ( !strncmp(p_cpufreq->u.s.scaling_governor, "userspace", CPUFREQ_NAME_LEN) ) { printf(" userspace specific :\n"); printf(" scaling_setspeed : %u\n", - p_cpufreq->u.userspace.scaling_setspeed); + p_cpufreq->u.s.u.userspace.scaling_setspeed); } - else if ( !strncmp(p_cpufreq->scaling_governor, + else if ( !strncmp(p_cpufreq->u.s.scaling_governor, "ondemand", CPUFREQ_NAME_LEN) ) { printf(" ondemand specific :\n"); printf(" sampling_rate : max [%u] min [%u] cur [%u]\n", - p_cpufreq->u.ondemand.sampling_rate_max, - p_cpufreq->u.ondemand.sampling_rate_min, - p_cpufreq->u.ondemand.sampling_rate); + p_cpufreq->u.s.u.ondemand.sampling_rate_max, + p_cpufreq->u.s.u.ondemand.sampling_rate_min, + p_cpufreq->u.s.u.ondemand.sampling_rate); printf(" up_threshold : %u\n", - p_cpufreq->u.ondemand.up_threshold); + p_cpufreq->u.s.u.ondemand.up_threshold); } =20 printf("scaling_avail_freq :"); for ( i =3D 0; i < p_cpufreq->freq_num; i++ ) if ( p_cpufreq->scaling_available_frequencies[i] =3D=3D - p_cpufreq->scaling_cur_freq ) + p_cpufreq->u.s.scaling_cur_freq ) printf(" *%d", p_cpufreq->scaling_available_frequencies[i]); else printf(" %d", p_cpufreq->scaling_available_frequencies[i]); printf("\n"); =20 printf("scaling frequency : max [%u] min [%u] cur [%u]\n", - p_cpufreq->scaling_max_freq, - p_cpufreq->scaling_min_freq, - p_cpufreq->scaling_cur_freq); + p_cpufreq->u.s.scaling_max_freq, + p_cpufreq->u.s.scaling_min_freq, + p_cpufreq->u.s.scaling_cur_freq); =20 printf("turbo mode : %s\n", p_cpufreq->turbo_enabled ? "enabled" : "disabled or n/a"); diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index 1bae635101..f5a9ac3f1a 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -258,37 +258,38 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *= op) cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur; op->u.get_para.cpuinfo_max_freq =3D policy->cpuinfo.max_freq; op->u.get_para.cpuinfo_min_freq =3D policy->cpuinfo.min_freq; - op->u.get_para.scaling_cur_freq =3D policy->cur; - op->u.get_para.scaling_max_freq =3D policy->max; - op->u.get_para.scaling_min_freq =3D policy->min; + + op->u.get_para.u.s.scaling_cur_freq =3D policy->cur; + op->u.get_para.u.s.scaling_max_freq =3D policy->max; + op->u.get_para.u.s.scaling_min_freq =3D policy->min; =20 if ( cpufreq_driver.name[0] ) - strlcpy(op->u.get_para.scaling_driver,=20 + strlcpy(op->u.get_para.scaling_driver, cpufreq_driver.name, CPUFREQ_NAME_LEN); else strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN= ); =20 if ( policy->governor->name[0] ) - strlcpy(op->u.get_para.scaling_governor,=20 + strlcpy(op->u.get_para.u.s.scaling_governor, policy->governor->name, CPUFREQ_NAME_LEN); else - strlcpy(op->u.get_para.scaling_governor, "Unknown", CPUFREQ_NAME_L= EN); + strlcpy(op->u.get_para.u.s.scaling_governor, "Unknown", CPUFREQ_NA= ME_LEN); =20 /* governor specific para */ - if ( !strncasecmp(op->u.get_para.scaling_governor, + if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, "userspace", CPUFREQ_NAME_LEN) ) { - op->u.get_para.u.userspace.scaling_setspeed =3D policy->cur; + op->u.get_para.u.s.u.userspace.scaling_setspeed =3D policy->cur; } =20 - if ( !strncasecmp(op->u.get_para.scaling_governor, + if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, "ondemand", CPUFREQ_NAME_LEN) ) { ret =3D get_cpufreq_ondemand_para( - &op->u.get_para.u.ondemand.sampling_rate_max, - &op->u.get_para.u.ondemand.sampling_rate_min, - &op->u.get_para.u.ondemand.sampling_rate, - &op->u.get_para.u.ondemand.up_threshold); + &op->u.get_para.u.s.u.ondemand.sampling_rate_max, + &op->u.get_para.u.s.u.ondemand.sampling_rate_min, + &op->u.get_para.u.s.u.ondemand.sampling_rate, + &op->u.get_para.u.s.u.ondemand.up_threshold); } op->u.get_para.turbo_enabled =3D cpufreq_get_turbo_status(op->cpuid); =20 diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index fa7147de47..c11c0b1a6c 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -317,16 +317,20 @@ struct xen_get_cpufreq_para { uint32_t cpuinfo_cur_freq; uint32_t cpuinfo_max_freq; uint32_t cpuinfo_min_freq; - uint32_t scaling_cur_freq; - - char scaling_governor[CPUFREQ_NAME_LEN]; - uint32_t scaling_max_freq; - uint32_t scaling_min_freq; - - /* for specific governor */ union { - struct xen_userspace userspace; - struct xen_ondemand ondemand; + struct { + uint32_t scaling_cur_freq; + + char scaling_governor[CPUFREQ_NAME_LEN]; + uint32_t scaling_max_freq; + uint32_t scaling_min_freq; + + /* for specific governor */ + union { + struct xen_userspace userspace; + struct xen_ondemand ondemand; + } u; + } s; } u; =20 int32_t turbo_enabled; --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391455; cv=none; d=zohomail.com; s=zohoarc; b=Unj8OX7h9kMo6F9W5Ul/AL0VwvJjux7nGk4uXmSqiVC2fM2pP+3G921HX6H3+pRkRBp59+N6jzXwo4JneyQDLgjJqPR45eMC+aKyeznACD3Syi9H67zm0rD5F77TmPxNbpXA4+bBuULA0VKhiVO26jN+2CMg37UwXMTW8818VNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391455; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UU4SMiJdUktv8hEdzVKy8V3KsteeHcG1cOr0eV9yG8I=; b=SakGJpFW35zcpXKSbYPTGVDtv6AwXPCauQwO05NV4E6PWZyXKevq3JDS5pasow/hzCeYVIZoY4/G+ArpvMcgNIYE+Dk4JNdMsACWkjMp92DjdxIW/ZuHHlMzrIpaqCFXd53+ft1jjOmDGtJ5rff8I3VGXgRMrMXxgQbvgQkHx1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391455827815.0034535511217; Wed, 26 Jul 2023 10:10:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570636.892641 (Exim 4.92) (envelope-from ) id 1qOi23-0007WR-57; Wed, 26 Jul 2023 17:10:39 +0000 Received: by outflank-mailman (output) from mailman id 570636.892641; Wed, 26 Jul 2023 17:10:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi23-0007WE-1i; Wed, 26 Jul 2023 17:10:39 +0000 Received: by outflank-mailman (input) for mailman id 570636; Wed, 26 Jul 2023 17:10:37 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi21-0005nP-B8 for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:37 +0000 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [2607:f8b0:4864:20::936]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 555528b1-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:35 +0200 (CEST) Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-79a31d66002so35475241.3 for ; Wed, 26 Jul 2023 10:10:35 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:33 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 555528b1-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391434; x=1690996234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UU4SMiJdUktv8hEdzVKy8V3KsteeHcG1cOr0eV9yG8I=; b=XOqyjTz5zQOrBJP/LGz68gTg1LGP/fJzke5nj6V32BwrkjjGkdrqGEvc9Ns2WGnOjM 5WpEssIBKHG4tf1ksN9qHZitYzCtT2q6+DNwdJAH8eZikryEWrhIWjdnT75cS3irOWHT ANiIKUyqXLADUWxlQ2onn0tD6G43MwHYreR2PKu6TkK/JSjAJwsd5x6itWMXpqbWLQfA rG50cxhnbSsjiRQyFrKeXxEPEPwmrLS9lwTta3TAE5djgoeBkF3To/pujKGJ/hgRirtU SHAfKMiiA5kRPgGqGn0oM0o3eIPnZ9RmaeA1Z1/1tqDHvnCq1GmMXqa1h0NUi+m64o1a CwFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391434; x=1690996234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UU4SMiJdUktv8hEdzVKy8V3KsteeHcG1cOr0eV9yG8I=; b=J7v8LuZU7PNUS6fNDI/NL55qabg5SQTteZ0oSjsuwzjPnZBVf9dQ6xrQw2VjxxRCCY r331O59emvPoyeOY6uC46Jmli3bO6fT/KDrxM8zGrZcsTU80lWNuLSPIRQace3o46uTK sHGQ8pIC+Ch5fqB6tVvgmlgQKqZFcr4SqiA85mzXx+v85c64n6Rj6JhaP5hKaBIRFRfh v2ELFySINBhIEW4d3ImDYo0ckIVh6Rwqeumwv3FABGQDEZ8gegCctneymb6TpaYPPH0j Hb3inN6U2iTodHEp7j/GHIEE2lLmoJQdxX7S3D3hvH+GxSfFM0Lek248Z3ZuGAjjLMNm b7JQ== X-Gm-Message-State: ABy/qLblhdrz55DHh4Bpk1Flzgm9bcJEh9LJnVrxbXtiryGvnI03m3NP esOT5ZRS/5b7I0CnTHTuepXwgkIayco= X-Google-Smtp-Source: APBJJlEH0+eyDIoFFsLzRezURkNtZT+DVR/bZxbTmYOfS6ExuDSeLBjXTnQrRh5vLKasYHnXJoa4Hg== X-Received: by 2002:a1f:da05:0:b0:471:1785:e838 with SMTP id r5-20020a1fda05000000b004711785e838mr1872264vkg.2.1690391433942; Wed, 26 Jul 2023 10:10:33 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Juergen Gross , Jan Beulich Subject: [PATCH v7 05/15] pmstat&xenpm: Re-arrage for cpufreq union Date: Wed, 26 Jul 2023 13:09:35 -0400 Message-ID: <20230726170945.34961-6-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391457288100003 Content-Type: text/plain; charset="utf-8" Rearrange code now that xen_sysctl_pm_op's get_para fields has the nested union and struct. In particular, the scaling governor information like scaling_available_governors is inside the union, so it is not always available. Move those fields (op->u.get_para.u.s.u.*) together as well as the common fields (ones outside the union like op->u.get_para.turbo_enabled). With that, gov_num may be 0, so bounce buffer handling needs to be modified. scaling_governor and other fields inside op->u.get_para.u.s.u.* won't be used for hwp, so this will simplify the change when hwp support is introduced and re-indents these lines all together. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich Acked-by: Anthony PERARD --- v6: Add Jan's Ack v5: Remove some formatting changes Expand commit message --- tools/libs/ctrl/xc_pm.c | 12 ++++++++---- tools/misc/xenpm.c | 3 ++- xen/drivers/acpi/pmstat.c | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index 6e751e242f..cea3eab22e 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -221,7 +221,7 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, { if ( (!user_para->affected_cpus) || (!user_para->scaling_available_frequencies) || - (!user_para->scaling_available_governors) ) + (user_para->gov_num && !user_para->scaling_available_governor= s) ) { errno =3D EINVAL; return -1; @@ -230,12 +230,15 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, goto unlock_1; if ( xc_hypercall_bounce_pre(xch, scaling_available_frequencies) ) goto unlock_2; - if ( xc_hypercall_bounce_pre(xch, scaling_available_governors) ) + if ( user_para->gov_num && + xc_hypercall_bounce_pre(xch, scaling_available_governors) ) goto unlock_3; =20 set_xen_guest_handle(sys_para->affected_cpus, affected_cpus); set_xen_guest_handle(sys_para->scaling_available_frequencies, scal= ing_available_frequencies); - set_xen_guest_handle(sys_para->scaling_available_governors, scalin= g_available_governors); + if ( user_para->gov_num ) + set_xen_guest_handle(sys_para->scaling_available_governors, + scaling_available_governors); } =20 sysctl.cmd =3D XEN_SYSCTL_pm_op; @@ -278,7 +281,8 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, } =20 unlock_4: - xc_hypercall_bounce_post(xch, scaling_available_governors); + if ( user_para->gov_num ) + xc_hypercall_bounce_post(xch, scaling_available_governors); unlock_3: xc_hypercall_bounce_post(xch, scaling_available_frequencies); unlock_2: diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index ee8ce5d5f2..1c474c3b59 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -811,7 +811,8 @@ static int show_cpufreq_para_by_cpuid(xc_interface *xc_= handle, int cpuid) ret =3D -ENOMEM; goto out; } - if (!(p_cpufreq->scaling_available_governors =3D + if (p_cpufreq->gov_num && + !(p_cpufreq->scaling_available_governors =3D malloc(p_cpufreq->gov_num * CPUFREQ_NAME_LEN * sizeof(char))= )) { fprintf(stderr, diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index f5a9ac3f1a..d67d99e62f 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -239,6 +239,18 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *o= p) if ( ret ) return ret; =20 + op->u.get_para.cpuinfo_cur_freq =3D + cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur; + op->u.get_para.cpuinfo_max_freq =3D policy->cpuinfo.max_freq; + op->u.get_para.cpuinfo_min_freq =3D policy->cpuinfo.min_freq; + op->u.get_para.turbo_enabled =3D cpufreq_get_turbo_status(op->cpuid); + + if ( cpufreq_driver.name[0] ) + strlcpy(op->u.get_para.scaling_driver, + cpufreq_driver.name, CPUFREQ_NAME_LEN); + else + strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN= ); + if ( !(scaling_available_governors =3D xzalloc_array(char, gov_num * CPUFREQ_NAME_LEN)) ) return -ENOMEM; @@ -254,21 +266,10 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *= op) if ( ret ) return ret; =20 - op->u.get_para.cpuinfo_cur_freq =3D - cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur; - op->u.get_para.cpuinfo_max_freq =3D policy->cpuinfo.max_freq; - op->u.get_para.cpuinfo_min_freq =3D policy->cpuinfo.min_freq; - op->u.get_para.u.s.scaling_cur_freq =3D policy->cur; op->u.get_para.u.s.scaling_max_freq =3D policy->max; op->u.get_para.u.s.scaling_min_freq =3D policy->min; =20 - if ( cpufreq_driver.name[0] ) - strlcpy(op->u.get_para.scaling_driver, - cpufreq_driver.name, CPUFREQ_NAME_LEN); - else - strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN= ); - if ( policy->governor->name[0] ) strlcpy(op->u.get_para.u.s.scaling_governor, policy->governor->name, CPUFREQ_NAME_LEN); @@ -291,7 +292,6 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op) &op->u.get_para.u.s.u.ondemand.sampling_rate, &op->u.get_para.u.s.u.ondemand.up_threshold); } - op->u.get_para.turbo_enabled =3D cpufreq_get_turbo_status(op->cpuid); =20 return ret; } --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391477; cv=none; d=zohomail.com; s=zohoarc; b=ZB9/Hvhk5nZGpaOCtFP6bOW2p34aISSLHfZdzt9uDYPmhvpJlxhtNdmEmCDbSLH1u+wiSgBO9Per5V7cebPhyG2F245H0GaXiSdM23EwY2LHOQIeH8WrEKnTxdiEJYZaKQO32sV3qqCOgAFVXByveSAkHvtyxpHazfGU06D1J00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391477; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=931lREy3WYHGGnNULLLqvu6+U4HwFHYQvep3+EFccAk=; b=StZ9/Nrkt09x5REc6XRpDcNky7EeqHFzMdroHciUatogKrlRKVzI47WdodHElP8pwi85zjbw7pbwzQc0fwLj7P+4nBk9YyjVwJtWns6BTfpZvzuq4ErBKBr/85herx/mWR9l85Do5z8aqb7pEZwqrgWJrcCKd34vDx1maCcMXwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391477688543.7482450995803; Wed, 26 Jul 2023 10:11:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570639.892651 (Exim 4.92) (envelope-from ) id 1qOi28-000885-Ii; Wed, 26 Jul 2023 17:10:44 +0000 Received: by outflank-mailman (output) from mailman id 570639.892651; Wed, 26 Jul 2023 17:10:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi28-00087u-EU; Wed, 26 Jul 2023 17:10:44 +0000 Received: by outflank-mailman (input) for mailman id 570639; Wed, 26 Jul 2023 17:10:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi27-0005nP-6r for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:43 +0000 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [2607:f8b0:4864:20::f2e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5820708e-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:39 +0200 (CEST) Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-63cf28db24cso549936d6.2 for ; Wed, 26 Jul 2023 10:10:40 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:37 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5820708e-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391438; x=1690996238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=931lREy3WYHGGnNULLLqvu6+U4HwFHYQvep3+EFccAk=; b=GxfnGO60pXz951mCVf40puLkMdEuAIHbPaempxlLDrcxcMGFUca+fGOA7niRqMB4Za I/AikYX+OHKGH+lZR4Wp5T+QJ6sW/tp6dl/QLQHnyb/TtXygbx2lKQ09TQFr7rV1Lj7w ncNYD8HvaIL1pD0i+OdNLFug4jh+7EYQQ6u+Y9USpgXev0LdwplQyJx+Byw8SsvYQZfJ rtMb316lbwj8HNFJiPB7bK4Ne0AruvEfSr4Y+vmCcJQpXSjfqCCpnACdwjcexfsZ1nnw 5J5F5GaPB0xhRKcGS6Vudlo1fm8daPPIFh3+66ja2oZ0Gk4j63D3rWSf2HSEHDQ7Obn0 Dwvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391438; x=1690996238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=931lREy3WYHGGnNULLLqvu6+U4HwFHYQvep3+EFccAk=; b=WYTF/QaTmTHxLxDyV/2RI1SJOu9R6wiTYH5pXhsp14IicnUHASql8tzQPy9+amxonP VWayLjdxo7LEtkqYZPMoDMS5t68HXzKnZ14+kH7M8d2ECtrYf1hVzu6wtsoHMQDUUPlz i2LSFRbZLV3nHj20Ab4wpsfJoD7RT9NL9QJcxx/d5IgprATFU0GREWktZ+6RM1q3IXI9 pCSSWDsj1sOFbju6VdR9q2gegr0DnOVLXol98aCBlRsOPcIqy/kD2kRH1WsicF+/LHb6 sCmLk77hCxtun+ig+ZS8LT8WwXAUAVcrLuWa7N8Ts2gp7eg3ljBD/EycdXHEAzZMsyEY LLzQ== X-Gm-Message-State: ABy/qLZBBnUbRIVI5WIawN06/IvuQDt694NZL+8I4Qk+RCAtmPlpkY2m Bnqxwt5UDG7xn1WZFreU15XSARFyVvU= X-Google-Smtp-Source: APBJJlGcXA5gbr9U0src3LThnWV+X3z5WKxOO50NFNK+Jd8DiDaHMLFmuBTNN9/hbwTDGP4dca058A== X-Received: by 2002:a0c:e404:0:b0:63d:77d:be74 with SMTP id o4-20020a0ce404000000b0063d077dbe74mr2273875qvl.59.1690391438286; Wed, 26 Jul 2023 10:10:38 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v7 06/15] cpufreq: Add Hardware P-State (HWP) driver Date: Wed, 26 Jul 2023 13:09:36 -0400 Message-ID: <20230726170945.34961-7-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391478441100001 Content-Type: text/plain; charset="utf-8" From the Intel SDM: "Hardware-Controlled Performance States (HWP), which autonomously selects performance states while utilizing OS supplied performance guidance hints." Enable HWP to run in autonomous mode by poking the correct MSRs. HWP is disabled by default, and cpufreq=3Dhwp enables it. cpufreq=3D parsing is expanded to allow cpufreq=3Dhwp;xen. This allows trying HWP and falling back to xen if not available. Only hwp and xen are supported for this fallback feature. hdc is a sub-option under hwp (i.e. cpufreq=3Dhwp,hdc=3D0) as is verbose. There is no interface to configure - xen_sysctl_pm_op/xenpm will be extended to configure in subsequent patches. It will run with the default values, which should be the default 0x80 (out of 0x0-0xff) energy/performance preference. Unscientific powertop measurement of an mostly idle, customized OpenXT install: A 10th gen 6-core laptop showed battery discharge drop from ~9.x to ~7.x watts. A 8th gen 4-core laptop dropped from ~10 to ~9 Power usage depends on many factors, especially display brightness, but this does show a power saving in balanced mode when CPU utilization is low. HWP isn't compatible with an external governor - it doesn't take explicit frequency requests. Therefore a minimal internal governor, hwp, is also added as a placeholder. While adding to the xen-command-line.pandoc entry, un-nest verbose from minfreq. They are independent. With cpufreq=3Dhwp,verbose, HWP prints processor capabilities that are not used by the code, like HW_FEEDBACK. This is done because otherwise there isn't a convenient way to query the information. Xen doesn't use the HWP interrupt, so it is disabled like in the Linux pstate driver. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- We disable on cpuid_level < 0x16. cpuid(0x16) is used to get the cpu frequencies for calculating the APERF/MPERF. Without it, things would still work, but the average cpu frequency output would be wrong. My 8th & 10th gen test systems both report: (XEN) HWP: 1 notify: 1 act_window: 1 energy_perf: 1 pkg_level: 0 peci: 0 (XEN) HWP: Hardware Duty Cycling (HDC) supported (XEN) HWP: HW_FEEDBACK not supported We can't use parse_boolean() since it requires a single name=3Dval string and cpufreq_handle_common_option is provided two strings. Use parse_bool() and manual handle no-hwp. FAST_IA32_HWP_REQUEST was removed in v2. The check in v1 was wrong, it's a model specific feature and the CPUID bit is only available after enabling via the MSR. Support was untested since I don't have hardware with the feature. Writes are expected to be infrequent, so just leave it out. --- v2: Alphabetize headers Re-work driver registration name hwp_drv_data anonymous union "hw" Drop hwp_verbose_cont style cleanups Condense hwp_governor switch hwp_cpufreq_target remove .raw from hwp_req assignment Use typed-pointer in a few functions Pass type to xzalloc Add HWP_ENERGY_PERF_BALANCE/IA32_ENERGY_BIAS_BALANCE defines Add XEN_HWP_GOVERNOR define for "hwp-internal" Capitalize CPUID and MSR defines Change '_' to '-' for energy-perf & act-window Read-modify-write MSRs updates Use FAST_IA32_HWP_REQUEST_MSR_ENABLE define constify pointer in hwp_set_misc_turbo Add space after non-fallthrough break in governor switch Add IA32_ENERGY_BIAS_MASK define Check CPUID_PM_LEAK for energy bias when needed Fail initialization with curr_req =3D -1 Fold hwp_read_capabilities into hwp_init_msrs Add command line cpufreq=3Dxen:hwp Add command line cpufreq=3Dxen:hdc Use per_cpu for hwp_drv_data pointers Move hwp_energy_perf_bias call into hwp_write_request energy_perf 0 is valid, so hwp_energy_perf_bias cannot be skipped Ensure we don't generate interrupts Remove Fast Write of Uncore MSR Initialize hwp_drv_data from curr_req Use SPDX line instead of license text in hwp.c v3: Add cf_check to cpufreq_gov_hwp_init() - Marek Print cpuid_level with %#x - Marek v4: Use BIT() for CPUID and MSR bits Move __initdata after type Add __ro_after_init to feature_* Remove aperf/mperf comment Move feature_hwp_energy_perf { to newline Remove _IA32_ infix Use unsigned int & bool for bitfields Require energy perf pref (Remove ENERGY_PERF_BIAS support) Initialize activity_window Return errors on wrmsr failure Change command line to: cpufreq=3Dxen:hwp Move hdc into the hwp-specific handle_options Drop feature_hwp_energy_perf, feature_hwp_pkg_level_ctl & feature_hwp_peci Print features before exiting when energy/performance preference isn't avai= lable Disable HWP MSR on initialization error Change hwp_ print macros to add prefixes Disable HDC when hdc=3D0 - (opt_hdc no longer initdata) Mark hwp governor internal and use "hwp" name Add XEN_HWP_DRIVER Use top-level cpufreq=3Dhwp command line option Document that cpufreq=3Dhwp falls back to cpufreq=3Dxen without hardware Add SPDX suffix GPL-2.0-only v5: Use _AC() macro in MSR_IA32_MISC_ENABLE_TURBO_DISENGAGE definition hwp_err arg re-ordering Use XEN_HWP_DRIVER_NAME Use cpufreq.h for all declarations Clear feature_hdc on failure and print a message Use unnamed bitfields instead of reservered Remove asm/io.h include static DEFINE_PER_CPU_READ_MOSTLY(struct hwp_drv_data Remove some empty newlines Align feature_hdc assignment Remove feature_hwp Remove unnecesary return at end of void hwp_init_msrs() BUILD_BUG_ON member variable Reformat a compound if Clear pre_cpu hwp_drv_data before xfree() Only print HWP capabilities for CPU 0 Specify processor models in turbo comment Use arg[1] in setup_cpufreq_option() Remove some log messages Drop double newline Parse verbose as a boolean instead of the custom parsing. Support cpufreq=3Dhwp;xen fallback Call hwp_available() from hwp_register_driver() Move cpufreq_govenor_internal setting to hwp_register_driver v6: docs: mention verbose applies to both. Use cpufreq=3Dhwp;xen,verbose example with verbose at then end. Declare induction i inside for loop Add CPUFREQ_none Only call cpufreq fallback for -ENODEV Brace on newline fixes hdc_set_pkg_hdc_ctl()/hdc_set_pm_ctl1() return boolean Continue without hdc Consolidate hdc if statement Use hwp_req variable for BUILD_BUG_ON Newline between declarations and statement __initdata for cpufreq_xen_opts/cpufreq_xen_cnt Only print HWP_REQUEST when differing from BSP. Remove MSR_PM_ENABLE printing Move hdc_set_pkg_hdc_ctl(), hdc_set_pm_ctl1(), hwp_get_cpu_speeds(), and hwp_init_msrs() to before their sole caller, hwp_cpufreq_cpu_init() Fix cpufreq=3D parsing without options (set ret=3D0) Drop stray s NULL check Return -EINVAL from hwp_cmdline_parse() Latch first CPU HWP request and print differences Use strpbrk to split on ',' or ':' for arg in xen/hwp do..while Limit hwp parsing error to just current option with %.*s and (end ?: e) - s docs: Expand and clarify the handling of `verbose` with cpufreq fallbacks. v7: s/##_VA_ARGS/## args/ in macros Add __init to hwp_handle_option Add comment for 0 cpuid freqs Reword intel_feature_detect comment. Fix indent for HDC failure Make first_run static and use for first cpu latching hwp_set_misc_turbo() return -EACCES on error s/end/*end/ in setup_cpufreq_option() --- docs/misc/xen-command-line.pandoc | 20 +- xen/arch/x86/acpi/cpufreq/Makefile | 1 + xen/arch/x86/acpi/cpufreq/cpufreq.c | 21 +- xen/arch/x86/acpi/cpufreq/hwp.c | 524 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/cpufeature.h | 12 +- xen/arch/x86/include/asm/msr-index.h | 15 +- xen/drivers/cpufreq/cpufreq.c | 59 ++- xen/include/acpi/cpufreq/cpufreq.h | 10 + xen/include/public/sysctl.h | 2 + 9 files changed, 649 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/acpi/cpufreq/hwp.c diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 4060ebdc5d..f77542de47 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -499,7 +499,7 @@ If set, force use of the performance counters for oprof= ile, rather than detectin available support. =20 ### cpufreq -> `=3D none | {{ | xen } [:[powersave|performance|ondemand|users= pace][,][,[][,[verbose]]]]} | dom0-kernel` +> `=3D none | {{ | xen } { [:[powersave|performance|ondemand|use= rspace][,[]][,[]]] } [,verbose]} | dom0-kernel | hwp[:[][,verbose]]` =20 > Default: `xen` =20 @@ -510,6 +510,24 @@ choice of `dom0-kernel` is deprecated and not supporte= d by all Dom0 kernels. * `` and `` are integers which represent max and min pro= cessor frequencies respectively. * `verbose` option can be included as a string or also as `verbose=3D` + for `xen`. It is a boolean for `hwp`. +* `hwp` selects Hardware-Controlled Performance States (HWP) on supported = Intel + hardware. HWP is a Skylake+ feature which provides better CPU power + management. The default is disabled. If `hwp` is selected, but hardware + support is not available, Xen will fallback to cpufreq=3Dxen. +* `` is a boolean to enable Hardware Duty Cycling (HDC). HDC enables= the + processor to autonomously force physical package components into idle st= ate. + The default is enabled, but the option only applies when `hwp` is enable= d. + +There is also support for `;`-separated fallback options: +`cpufreq=3Dhwp;xen,verbose`. This first tries `hwp` and falls back to `xe= n` if +unavailable. Note: The `verbose` suboption is handled globally. Setting = it +for either the primary or fallback option applies to both irrespective of = where +it is specified. + +Note: grub2 requires to escape or quote ';', so `"cpufreq=3Dhwp;xen"` shou= ld be +specified within double quotes inside grub.cfg. Refer to the grub2 +documentation for more information. =20 ### cpuid (x86) > `=3D List of comma separated booleans` diff --git a/xen/arch/x86/acpi/cpufreq/Makefile b/xen/arch/x86/acpi/cpufreq= /Makefile index f75da9b9ca..db83aa6b14 100644 --- a/xen/arch/x86/acpi/cpufreq/Makefile +++ b/xen/arch/x86/acpi/cpufreq/Makefile @@ -1,2 +1,3 @@ obj-y +=3D cpufreq.o +obj-y +=3D hwp.o obj-y +=3D powernow.o diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufre= q/cpufreq.c index f1cc473b4f..61b62c370a 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -642,7 +642,26 @@ static int __init cf_check cpufreq_driver_init(void) switch ( boot_cpu_data.x86_vendor ) { case X86_VENDOR_INTEL: - ret =3D cpufreq_register_driver(&acpi_cpufreq_driver); + ret =3D -ENOENT; + + for ( unsigned int i =3D 0; i < cpufreq_xen_cnt; i++ ) + { + switch ( cpufreq_xen_opts[i] ) + { + case CPUFREQ_xen: + ret =3D cpufreq_register_driver(&acpi_cpufreq_driver); + break; + case CPUFREQ_hwp: + ret =3D hwp_register_driver(); + break; + case CPUFREQ_none: + ret =3D 0; + break; + } + + if ( ret !=3D -ENODEV ) + break; + } break; =20 case X86_VENDOR_AMD: diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hw= p.c new file mode 100644 index 0000000000..e9a6d23e38 --- /dev/null +++ b/xen/arch/x86/acpi/cpufreq/hwp.c @@ -0,0 +1,524 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * hwp.c cpufreq driver to run Intel Hardware P-States (HWP) + * + * Copyright (C) 2021 Jason Andryuk + */ + +#include +#include +#include +#include +#include +#include + +static bool __ro_after_init feature_hwp_notification; +static bool __ro_after_init feature_hwp_activity_window; + +static bool __ro_after_init feature_hdc; + +static bool __ro_after_init opt_cpufreq_hdc =3D true; + +union hwp_request +{ + struct + { + unsigned int min_perf:8; + unsigned int max_perf:8; + unsigned int desired:8; + unsigned int energy_perf:8; + unsigned int activity_window:10; + bool package_control:1; + unsigned int :16; + bool activity_window_valid:1; + bool energy_perf_valid:1; + bool desired_valid:1; + bool max_perf_valid:1; + bool min_perf_valid:1; + }; + uint64_t raw; +}; + +struct hwp_drv_data +{ + union + { + uint64_t hwp_caps; + struct + { + unsigned int highest:8; + unsigned int guaranteed:8; + unsigned int most_efficient:8; + unsigned int lowest:8; + unsigned int :32; + } hw; + }; + union hwp_request curr_req; + int ret; + uint16_t activity_window; + uint8_t minimum; + uint8_t maximum; + uint8_t desired; + uint8_t energy_perf; +}; +static DEFINE_PER_CPU_READ_MOSTLY(struct hwp_drv_data *, hwp_drv_data); + +#define hwp_err(cpu, fmt, args...) \ + printk(XENLOG_ERR "HWP: CPU%u error: " fmt, cpu, ## args) +#define hwp_info(fmt, args...) printk(XENLOG_INFO "HWP: " fmt, ## args) +#define hwp_verbose(fmt, args...) \ +({ \ + if ( cpufreq_verbose ) \ + printk(XENLOG_DEBUG "HWP: " fmt, ## args); \ +}) + +static int cf_check hwp_governor(struct cpufreq_policy *policy, + unsigned int event) +{ + int ret; + + if ( policy =3D=3D NULL ) + return -EINVAL; + + switch ( event ) + { + case CPUFREQ_GOV_START: + case CPUFREQ_GOV_LIMITS: + ret =3D 0; + break; + + case CPUFREQ_GOV_STOP: + default: + ret =3D -EINVAL; + break; + } + + return ret; +} + +static bool __init hwp_handle_option(const char *s, const char *end) +{ + int ret; + + ret =3D parse_boolean("verbose", s, end); + if ( ret >=3D 0 ) + { + cpufreq_verbose =3D ret; + return true; + } + + ret =3D parse_boolean("hdc", s, end); + if ( ret >=3D 0 ) + { + opt_cpufreq_hdc =3D ret; + return true; + } + + return false; +} + +int __init hwp_cmdline_parse(const char *s, const char *e) +{ + do + { + const char *end =3D strpbrk(s, ",;"); + + if ( !hwp_handle_option(s, end) ) + { + printk(XENLOG_WARNING "cpufreq/hwp: option '%.*s' not recogniz= ed\n", + (int)((end ?: e) - s), s); + + return -EINVAL; + } + + s =3D end ? ++end : end; + } while ( s && s < e ); + + return 0; +} + +static struct cpufreq_governor cpufreq_gov_hwp =3D +{ + .name =3D "hwp", + .governor =3D hwp_governor, +}; + +static int __init cf_check cpufreq_gov_hwp_init(void) +{ + if ( !cpufreq_governor_internal ) + return 0; + + return cpufreq_register_governor(&cpufreq_gov_hwp); +} +__initcall(cpufreq_gov_hwp_init); + +static bool __init hwp_available(void) +{ + unsigned int eax; + + if ( boot_cpu_data.cpuid_level < CPUID_PM_LEAF ) + { + hwp_verbose("cpuid_level (%#x) lacks HWP support\n", + boot_cpu_data.cpuid_level); + + return false; + } + + if ( boot_cpu_data.cpuid_level < 0x16 ) + { + hwp_info("HWP disabled: cpuid_level %#x < 0x16 lacks CPU freq info= \n", + boot_cpu_data.cpuid_level); + + return false; + } + + eax =3D cpuid_eax(CPUID_PM_LEAF); + + hwp_verbose("%d notify: %d act-window: %d energy-perf: %d pkg-level: %= d peci: %d\n", + !!(eax & CPUID6_EAX_HWP), + !!(eax & CPUID6_EAX_HWP_NOTIFICATION), + !!(eax & CPUID6_EAX_HWP_ACTIVITY_WINDOW), + !!(eax & CPUID6_EAX_HWP_ENERGY_PERFORMANCE_PREFERENCE), + !!(eax & CPUID6_EAX_HWP_PACKAGE_LEVEL_REQUEST), + !!(eax & CPUID6_EAX_HWP_PECI)); + + if ( !(eax & CPUID6_EAX_HWP) ) + return false; + + if ( !(eax & CPUID6_EAX_HWP_ENERGY_PERFORMANCE_PREFERENCE) ) + { + hwp_verbose("disabled: No energy/performance preference available"= ); + + return false; + } + + feature_hwp_notification =3D eax & CPUID6_EAX_HWP_NOTIFICATION; + feature_hwp_activity_window =3D eax & CPUID6_EAX_HWP_ACTIVITY_WINDOW; + feature_hdc =3D eax & CPUID6_EAX_HDC; + + hwp_verbose("Hardware Duty Cycling (HDC) %ssupported%s\n", + feature_hdc ? "" : "not ", + feature_hdc ? opt_cpufreq_hdc ? ", enabled" : ", disabled" + : ""); + + hwp_verbose("HW_FEEDBACK %ssupported\n", + (eax & CPUID6_EAX_HW_FEEDBACK) ? "" : "not "); + + hwp_info("Using HWP for cpufreq\n"); + + return true; +} + +static int cf_check hwp_cpufreq_verify(struct cpufreq_policy *policy) +{ + struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); + + if ( !feature_hwp_activity_window && data->activity_window ) + { + hwp_verbose("HWP activity window not supported\n"); + + return -EINVAL; + } + + return 0; +} + +static void cf_check hwp_write_request(void *info) +{ + const struct cpufreq_policy *policy =3D info; + struct hwp_drv_data *data =3D this_cpu(hwp_drv_data); + union hwp_request hwp_req =3D data->curr_req; + + data->ret =3D 0; + + BUILD_BUG_ON(sizeof(hwp_req) !=3D sizeof(hwp_req.raw)); + if ( wrmsr_safe(MSR_HWP_REQUEST, hwp_req.raw) ) + { + hwp_verbose("CPU%u: error wrmsr_safe(MSR_HWP_REQUEST, %lx)\n", + policy->cpu, hwp_req.raw); + rdmsr_safe(MSR_HWP_REQUEST, data->curr_req.raw); + data->ret =3D -EINVAL; + } +} + +static int cf_check hwp_cpufreq_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation) +{ + unsigned int cpu =3D policy->cpu; + struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + /* Zero everything to ensure reserved bits are zero... */ + union hwp_request hwp_req =3D { .raw =3D 0 }; + + /* .. and update from there */ + hwp_req.min_perf =3D data->minimum; + hwp_req.max_perf =3D data->maximum; + hwp_req.desired =3D data->desired; + hwp_req.energy_perf =3D data->energy_perf; + if ( feature_hwp_activity_window ) + hwp_req.activity_window =3D data->activity_window; + + if ( hwp_req.raw =3D=3D data->curr_req.raw ) + return 0; + + data->curr_req =3D hwp_req; + + on_selected_cpus(cpumask_of(cpu), hwp_write_request, policy, 1); + + return data->ret; +} + +static bool hdc_set_pkg_hdc_ctl(unsigned int cpu, bool val) +{ + uint64_t msr; + + if ( rdmsr_safe(MSR_PKG_HDC_CTL, msr) ) + { + hwp_err(cpu, "rdmsr_safe(MSR_PKG_HDC_CTL)\n"); + return false; + } + + if ( val ) + msr |=3D PKG_HDC_CTL_HDC_PKG_ENABLE; + else + msr &=3D ~PKG_HDC_CTL_HDC_PKG_ENABLE; + + if ( wrmsr_safe(MSR_PKG_HDC_CTL, msr) ) + { + hwp_err(cpu, "wrmsr_safe(MSR_PKG_HDC_CTL): %016lx\n", msr); + return false; + } + + return true; +} + +static bool hdc_set_pm_ctl1(unsigned int cpu, bool val) +{ + uint64_t msr; + + if ( rdmsr_safe(MSR_PM_CTL1, msr) ) + { + hwp_err(cpu, "rdmsr_safe(MSR_PM_CTL1)\n"); + return false; + } + + if ( val ) + msr |=3D PM_CTL1_HDC_ALLOW_BLOCK; + else + msr &=3D ~PM_CTL1_HDC_ALLOW_BLOCK; + + if ( wrmsr_safe(MSR_PM_CTL1, msr) ) + { + hwp_err(cpu, "wrmsr_safe(MSR_PM_CTL1): %016lx\n", msr); + return false; + } + + return true; +} + +static void hwp_get_cpu_speeds(struct cpufreq_policy *policy) +{ + uint32_t base_khz, max_khz, bus_khz, edx; + + cpuid(0x16, &base_khz, &max_khz, &bus_khz, &edx); + + /* + * Zero values are acceptable - they are not used for calculations + * and only returned to userspace. + */ + policy->cpuinfo.perf_freq =3D base_khz * 1000; + policy->cpuinfo.min_freq =3D base_khz * 1000; + policy->cpuinfo.max_freq =3D max_khz * 1000; + policy->min =3D base_khz * 1000; + policy->max =3D max_khz * 1000; + policy->cur =3D 0; +} + +static void cf_check hwp_init_msrs(void *info) +{ + struct cpufreq_policy *policy =3D info; + struct hwp_drv_data *data =3D this_cpu(hwp_drv_data); + uint64_t val; + + /* + * Package level MSR, but we don't have a good idea of packages here, = so + * just do it everytime. + */ + if ( rdmsr_safe(MSR_PM_ENABLE, val) ) + { + hwp_err(policy->cpu, "rdmsr_safe(MSR_PM_ENABLE)\n"); + data->curr_req.raw =3D -1; + return; + } + + /* Ensure we don't generate interrupts */ + if ( feature_hwp_notification ) + wrmsr_safe(MSR_HWP_INTERRUPT, 0); + + if ( !(val & PM_ENABLE_HWP_ENABLE) ) + { + val |=3D PM_ENABLE_HWP_ENABLE; + if ( wrmsr_safe(MSR_PM_ENABLE, val) ) + { + hwp_err(policy->cpu, "wrmsr_safe(MSR_PM_ENABLE, %lx)\n", val); + data->curr_req.raw =3D -1; + return; + } + } + + if ( rdmsr_safe(MSR_HWP_CAPABILITIES, data->hwp_caps) ) + { + hwp_err(policy->cpu, "rdmsr_safe(MSR_HWP_CAPABILITIES)\n"); + goto error; + } + + if ( rdmsr_safe(MSR_HWP_REQUEST, data->curr_req.raw) ) + { + hwp_err(policy->cpu, "rdmsr_safe(MSR_HWP_REQUEST)\n"); + goto error; + } + + /* Check for turbo support. */ + intel_feature_detect(policy); + + if ( feature_hdc && + (!hdc_set_pkg_hdc_ctl(policy->cpu, opt_cpufreq_hdc) || + !hdc_set_pm_ctl1(policy->cpu, opt_cpufreq_hdc)) ) + { + hwp_err(policy->cpu, "Disabling HDC support\n"); + feature_hdc =3D false; + } + + hwp_get_cpu_speeds(policy); + + return; + + error: + data->curr_req.raw =3D -1; + val &=3D ~PM_ENABLE_HWP_ENABLE; + if ( wrmsr_safe(MSR_PM_ENABLE, val) ) + hwp_err(policy->cpu, "wrmsr_safe(MSR_PM_ENABLE, %lx)\n", val); +} + +static int cf_check hwp_cpufreq_cpu_init(struct cpufreq_policy *policy) +{ + static union hwp_request initial_req; + unsigned int cpu =3D policy->cpu; + struct hwp_drv_data *data; + static bool first_run =3D true; + + data =3D xzalloc(struct hwp_drv_data); + if ( !data ) + return -ENOMEM; + + policy->governor =3D &cpufreq_gov_hwp; + + per_cpu(hwp_drv_data, cpu) =3D data; + + on_selected_cpus(cpumask_of(cpu), hwp_init_msrs, policy, 1); + + if ( data->curr_req.raw =3D=3D -1 ) + { + hwp_err(cpu, "Could not initialize HWP properly\n"); + per_cpu(hwp_drv_data, cpu) =3D NULL; + xfree(data); + return -ENODEV; + } + + data->minimum =3D data->curr_req.min_perf; + data->maximum =3D data->curr_req.max_perf; + data->desired =3D data->curr_req.desired; + data->energy_perf =3D data->curr_req.energy_perf; + data->activity_window =3D data->curr_req.activity_window; + + if ( first_run ) + { + hwp_verbose("CPU%u: HWP_CAPABILITIES: %016lx\n", cpu, data->hwp_ca= ps); + initial_req =3D data->curr_req; + } + + if ( first_run || data->curr_req.raw !=3D initial_req.raw ) + { + hwp_verbose("CPU%u: rdmsr HWP_REQUEST %016lx\n", cpu, + data->curr_req.raw); + first_run =3D false; + } + + return 0; +} + +static int cf_check hwp_cpufreq_cpu_exit(struct cpufreq_policy *policy) +{ + struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); + + per_cpu(hwp_drv_data, policy->cpu) =3D NULL; + xfree(data); + + return 0; +} + +/* + * The SDM reads like turbo should be disabled with MSR_IA32_PERF_CTL and + * PERF_CTL_TURBO_DISENGAGE, but that does not seem to actually work, at l= east + * with testing on i7-10810U and i7-8550U. MSR_MISC_ENABLE and + * MISC_ENABLE_TURBO_DISENGAGE is what Linux uses and seems to work. + */ +static void cf_check hwp_set_misc_turbo(void *info) +{ + const struct cpufreq_policy *policy =3D info; + struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); + uint64_t msr; + + data->ret =3D 0; + + if ( rdmsr_safe(MSR_IA32_MISC_ENABLE, msr) ) + { + hwp_verbose("CPU%u: error rdmsr_safe(MSR_IA32_MISC_ENABLE)\n", + policy->cpu); + data->ret =3D -EACCES; + + return; + } + + if ( policy->turbo =3D=3D CPUFREQ_TURBO_ENABLED ) + msr &=3D ~MSR_IA32_MISC_ENABLE_TURBO_DISENGAGE; + else + msr |=3D MSR_IA32_MISC_ENABLE_TURBO_DISENGAGE; + + if ( wrmsr_safe(MSR_IA32_MISC_ENABLE, msr) ) + { + hwp_verbose("CPU%u: error wrmsr_safe(MSR_IA32_MISC_ENABLE): %016lx= \n", + policy->cpu, msr); + data->ret =3D -EACCES; + } +} + +static int cf_check hwp_cpufreq_update(int cpuid, struct cpufreq_policy *p= olicy) +{ + on_selected_cpus(cpumask_of(cpuid), hwp_set_misc_turbo, policy, 1); + + return per_cpu(hwp_drv_data, cpuid)->ret; +} + +static const struct cpufreq_driver __initconstrel hwp_cpufreq_driver =3D +{ + .name =3D XEN_HWP_DRIVER_NAME, + .verify =3D hwp_cpufreq_verify, + .target =3D hwp_cpufreq_target, + .init =3D hwp_cpufreq_cpu_init, + .exit =3D hwp_cpufreq_cpu_exit, + .update =3D hwp_cpufreq_update, +}; + +int __init hwp_register_driver(void) +{ + int ret; + + if ( !hwp_available() ) + return -ENODEV; + + ret =3D cpufreq_register_driver(&hwp_cpufreq_driver); + cpufreq_governor_internal =3D (ret =3D=3D 0); + + return ret; +} diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/a= sm/cpufeature.h index 64e1dad225..93466441f5 100644 --- a/xen/arch/x86/include/asm/cpufeature.h +++ b/xen/arch/x86/include/asm/cpufeature.h @@ -52,8 +52,16 @@ static inline bool boot_cpu_has(unsigned int feat) return cpu_has(&boot_cpu_data, feat); } =20 -#define CPUID_PM_LEAF 6 -#define CPUID6_ECX_APERFMPERF_CAPABILITY 0x1 +#define CPUID_PM_LEAF 6 +#define CPUID6_EAX_HWP BIT(7, U) +#define CPUID6_EAX_HWP_NOTIFICATION BIT(8, U) +#define CPUID6_EAX_HWP_ACTIVITY_WINDOW BIT(9, U) +#define CPUID6_EAX_HWP_ENERGY_PERFORMANCE_PREFERENCE BIT(10, U) +#define CPUID6_EAX_HWP_PACKAGE_LEVEL_REQUEST BIT(11, U) +#define CPUID6_EAX_HDC BIT(13, U) +#define CPUID6_EAX_HWP_PECI BIT(16, U) +#define CPUID6_EAX_HW_FEEDBACK BIT(19, U) +#define CPUID6_ECX_APERFMPERF_CAPABILITY BIT(0, U) =20 /* CPUID level 0x00000001.edx */ #define cpu_has_fpu 1 diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/as= m/msr-index.h index 2382fc8e11..56f93cb8e2 100644 --- a/xen/arch/x86/include/asm/msr-index.h +++ b/xen/arch/x86/include/asm/msr-index.h @@ -151,6 +151,13 @@ =20 #define MSR_PKRS 0x000006e1 =20 +#define MSR_PM_ENABLE 0x00000770 +#define PM_ENABLE_HWP_ENABLE BIT(0, ULL) + +#define MSR_HWP_CAPABILITIES 0x00000771 +#define MSR_HWP_INTERRUPT 0x00000773 +#define MSR_HWP_REQUEST 0x00000774 + #define MSR_X2APIC_FIRST 0x00000800 #define MSR_X2APIC_LAST 0x000008ff =20 @@ -165,6 +172,11 @@ #define PASID_PASID_MASK 0x000fffff #define PASID_VALID (_AC(1, ULL) << 31) =20 +#define MSR_PKG_HDC_CTL 0x00000db0 +#define PKG_HDC_CTL_HDC_PKG_ENABLE BIT(0, ULL) +#define MSR_PM_CTL1 0x00000db1 +#define PM_CTL1_HDC_ALLOW_BLOCK BIT(0, ULL) + #define MSR_UARCH_MISC_CTRL 0x00001b01 #define UARCH_CTRL_DOITM (_AC(1, ULL) << 0) =20 @@ -466,7 +478,8 @@ #define MSR_IA32_MISC_ENABLE_MONITOR_ENABLE (1<<18) #define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1<<22) #define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1<<23) -#define MSR_IA32_MISC_ENABLE_XD_DISABLE (_AC(1, ULL) << 34) +#define MSR_IA32_MISC_ENABLE_XD_DISABLE (_AC(1, ULL) << 34) +#define MSR_IA32_MISC_ENABLE_TURBO_DISENGAGE (_AC(1, ULL) << 38) =20 #define MSR_IA32_TSC_DEADLINE 0x000006E0 #define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0 diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index 67a58d409b..81bda5df23 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -63,12 +63,19 @@ LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); /* set xen as default cpufreq */ enum cpufreq_controller cpufreq_controller =3D FREQCTL_xen; =20 -static int __init cpufreq_cmdline_parse(const char *s); +enum cpufreq_xen_opt __initdata cpufreq_xen_opts[2] =3D { CPUFREQ_xen, + CPUFREQ_none }; +unsigned int __initdata cpufreq_xen_cnt =3D 1; + +static int __init cpufreq_cmdline_parse(const char *s, const char *e); =20 static int __init cf_check setup_cpufreq_option(const char *str) { - const char *arg =3D strpbrk(str, ",:"); + const char *arg =3D strpbrk(str, ",:;"); int choice; + int ret =3D -EINVAL; + + cpufreq_xen_cnt =3D 0; =20 if ( !arg ) arg =3D strchr(str, '\0'); @@ -89,15 +96,45 @@ static int __init cf_check setup_cpufreq_option(const c= har *str) return 0; } =20 - if ( choice > 0 || !cmdline_strcmp(str, "xen") ) + do { - xen_processor_pmbits |=3D XEN_PROCESSOR_PM_PX; - cpufreq_controller =3D FREQCTL_xen; - if ( *arg && *(arg + 1) ) - return cpufreq_cmdline_parse(arg + 1); - } + const char *end =3D strchr(str, ';'); + + if ( end =3D=3D NULL ) + end =3D strchr(str, '\0'); + + arg =3D strpbrk(str, ",:"); + if ( !arg || arg > end ) + arg =3D strchr(str, '\0'); + + if ( cpufreq_xen_cnt =3D=3D ARRAY_SIZE(cpufreq_xen_opts) ) + return -E2BIG; + + if ( choice > 0 || !cmdline_strcmp(str, "xen") ) + { + xen_processor_pmbits |=3D XEN_PROCESSOR_PM_PX; + cpufreq_controller =3D FREQCTL_xen; + cpufreq_xen_opts[cpufreq_xen_cnt++] =3D CPUFREQ_xen; + ret =3D 0; + if ( arg[0] && arg[1] ) + ret =3D cpufreq_cmdline_parse(arg + 1, end); + } + else if ( choice < 0 && !cmdline_strcmp(str, "hwp") ) + { + xen_processor_pmbits |=3D XEN_PROCESSOR_PM_PX; + cpufreq_controller =3D FREQCTL_xen; + cpufreq_xen_opts[cpufreq_xen_cnt++] =3D CPUFREQ_hwp; + ret =3D 0; + if ( arg[0] && arg[1] ) + ret =3D hwp_cmdline_parse(arg + 1, end); + } + else + ret =3D -EINVAL; + + str =3D *end ? ++end : end; + } while ( choice < 0 && ret =3D=3D 0 && *str ); =20 - return (choice < 0) ? -EINVAL : 0; + return (choice < 0) ? ret : 0; } custom_param("cpufreq", setup_cpufreq_option); =20 @@ -576,7 +613,7 @@ static int __init cpufreq_handle_common_option(const ch= ar *name, const char *val return 0; } =20 -static int __init cpufreq_cmdline_parse(const char *s) +static int __init cpufreq_cmdline_parse(const char *s, const char *e) { static struct cpufreq_governor *__initdata cpufreq_governors[] =3D { @@ -592,6 +629,8 @@ static int __init cpufreq_cmdline_parse(const char *s) int rc =3D 0; =20 strlcpy(buf, s, sizeof(buf)); + if (e - s < sizeof(buf)) + buf[e - s] =3D '\0'; do { char *val, *end =3D strchr(str, ','); unsigned int i; diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 482ea5b0de..cfe975814e 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -24,6 +24,13 @@ DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock); =20 extern bool_t cpufreq_verbose; =20 +enum cpufreq_xen_opt { + CPUFREQ_none, + CPUFREQ_xen, + CPUFREQ_hwp, +}; +extern enum cpufreq_xen_opt cpufreq_xen_opts[2]; +extern unsigned int cpufreq_xen_cnt; struct cpufreq_governor; =20 struct acpi_cpufreq_data { @@ -245,4 +252,7 @@ void cpufreq_dbs_timer_resume(void); =20 void intel_feature_detect(struct cpufreq_policy *policy); =20 +int hwp_cmdline_parse(const char *s, const char *e); +int hwp_register_driver(void); + #endif /* __XEN_CPUFREQ_PM_H__ */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index c11c0b1a6c..5a30b16fcf 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -296,6 +296,8 @@ struct xen_ondemand { uint32_t up_threshold; }; =20 +#define XEN_HWP_DRIVER_NAME "hwp" + /* * cpufreq para name of this structure named * same as sysfs file name of native linux --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391464; cv=none; d=zohomail.com; s=zohoarc; b=Rdq2+HyU8turkEEYx2hdJAV9kZ9smcujYoi6iXi0mbybFFkLY5i3yyXYKz3D3d8hby4uowGzGnXAqSFLOoqF4sA1lt96jZqwE9Y4ElpBmLPUcZljjU/sOHqtGYul2KBJ7z4sW5u9T38nHxLGNrdkaUNwxCDxzKliT2HUS9+HLEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BC4KCbQaicpEfX3GeSqBCseD+2+53viJE6p7BIzEEpg=; b=CloYzCtgQ/WYcl7/fT2Go6Enh4SEzqRMC+jFKI4Q0Oln8KKRNk/AizBAXJuw1cl4QToqBrzmkaoLscVOIwEUaZ7NDTfuH0U14VI5AfhmIDTaPpMzkWVtOJ07UXxb7/ahZQo89cKYkuP8gKgFpgCKWaeBouTrgdt9MTEg/mG3zyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391464894210.12256508560768; Wed, 26 Jul 2023 10:11:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570642.892661 (Exim 4.92) (envelope-from ) id 1qOi2B-0008Vc-2q; Wed, 26 Jul 2023 17:10:47 +0000 Received: by outflank-mailman (output) from mailman id 570642.892661; Wed, 26 Jul 2023 17:10:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2A-0008VS-Uq; Wed, 26 Jul 2023 17:10:46 +0000 Received: by outflank-mailman (input) for mailman id 570642; Wed, 26 Jul 2023 17:10:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi29-0005nP-B2 for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:45 +0000 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [2607:f8b0:4864:20::f2e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5a23fe7f-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:43 +0200 (CEST) Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-63d03d3cac6so436136d6.2 for ; Wed, 26 Jul 2023 10:10:43 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5a23fe7f-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391442; x=1690996242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BC4KCbQaicpEfX3GeSqBCseD+2+53viJE6p7BIzEEpg=; b=ndtmflJBJ3YpsDmboHGO5jxzRiGA0QQkW8Kn9KHIuE5zXhNppgNSLsNw6L2zeewH47 L8JEoqYsnFRSSrvn4poHVvTDSH24PYG/rYF3E6nj53SUjPeQHQhSaP93ETMPIv2pHY6/ M5wtPzcvt4B8gKdf7iHJdsuR8r8qanLdcF14r1PwVHqNPSIBkcDeOCa/s8SXXpQyFDrp 6p+sTd5c2C2XJ/iKbSJBrzWyvvZm8uMKeUavnfRukNoIpTWR0uwOJ4g3Ba+sf6tW2G4n dESNKTi3FPvjHE3jLtHInGN97F1IjHHvtZ9bNBtd/xDPpaMfTLQ7NZVINqhhbn7q1bsL QdHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391442; x=1690996242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BC4KCbQaicpEfX3GeSqBCseD+2+53viJE6p7BIzEEpg=; b=dEqNGfaD5T9fGCje4NztSpEwe7Fi6kbLNPb92s0hIVrrf4EobhQFiyf+3BHDm+D8A3 8BWyCoy6uhsy4luNj4gcafVY725+k9lD6RDa68ZBwoxH30lX3QXsh7X8MZx9JFe7Cvin gIHnJewu7U18i4MCbmuPzLPk0fdQ2Gb2qYogrE32qj8uR2sNTOshVwgqbpcQKzrNaMTq APQ6b0q0HsLHA2zXd4IvfhpCk97wtjVPDiIhKY/ehnWXK30E9yj7MBGTQgu1YSpEV6TG g5W4K7MJ1v/UkgOOM079FGgMPyLDnA3EIq3rp1Br0GHU909WZ2SlZ3nkUMv5GvYXXyQM qMEQ== X-Gm-Message-State: ABy/qLZdKJhJ68XMb7uyoNyLf5bb4b172C+Qf9S2b6biP4dKz4xW7wHr 9Zc87rYHXzIJBho1LJQYKsdZSYyM2rw= X-Google-Smtp-Source: APBJJlETq+JdfQM6svwqAHt0eXz7N837lk5Ch/SoYIZabylFcWDTbaKfV8RLlJm3y3lVB5DJMJJmvw== X-Received: by 2002:a0c:f84b:0:b0:635:f3c2:e88f with SMTP id g11-20020a0cf84b000000b00635f3c2e88fmr2101475qvo.33.1690391441963; Wed, 26 Jul 2023 10:10:41 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v7 07/15] xen/x86: Tweak PDC bits when using HWP Date: Wed, 26 Jul 2023 13:09:37 -0400 Message-ID: <20230726170945.34961-8-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391465363100001 Content-Type: text/plain; charset="utf-8" Qubes testing of HWP support had a report of a laptop, Thinkpad X1 Carbon Gen 4 with a Skylake processor, locking up during boot when HWP is enabled. A user found a kernel bug that seems to be the same issue: https://bugzilla.kernel.org/show_bug.cgi?id=3D110941. That bug was fixed by Linux commit a21211672c9a ("ACPI / processor: Request native thermal interrupt handling via _OSC"). The tl;dr is SMM crashes when it receives thermal interrupts, so Linux calls the ACPI _OSC method to take over interrupt handling. The Linux fix looks at the CPU features to decide whether or not to call _OSC with bit 12 set to take over native interrupt handling. Xen needs some way to communicate HWP to Dom0 for making an equivalent call. Xen exposes modified PDC bits via the platform_op set_pminfo hypercall. Expand that to set bit 12 when HWP is present and in use. Any generated interrupt would be handled by Xen's thermal drive, which clears the status. Bit 12 isn't named in the linux header and is open coded in Linux's usage. Name it ACPI_PDC_CPPC_NATIVE_INTR. This will need a corresponding linux patch to pick up and apply the PDC bits. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v5: Minor fixup for feature_hwp removal Use cpurfreq.h for declaration v4: Added __ro_after_init s/ACPI_PDC_CPPC_NTV_INT/ACPI_PDC_CPPC_NATIVE_INTR/ Remove _IA32_ Fixup for opt_cpufreq_hwp removal Add Jan Reviewed-by v3: New --- xen/arch/x86/acpi/cpufreq/hwp.c | 9 +++++++++ xen/arch/x86/acpi/lib.c | 5 +++++ xen/arch/x86/cpu/mcheck/mce_intel.c | 6 ++++++ xen/arch/x86/include/asm/msr-index.h | 1 + xen/include/acpi/cpufreq/cpufreq.h | 1 + xen/include/acpi/pdc_intel.h | 1 + 6 files changed, 23 insertions(+) diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hw= p.c index e9a6d23e38..33039ad39e 100644 --- a/xen/arch/x86/acpi/cpufreq/hwp.c +++ b/xen/arch/x86/acpi/cpufreq/hwp.c @@ -12,6 +12,8 @@ #include #include =20 +static bool __ro_after_init hwp_in_use; + static bool __ro_after_init feature_hwp_notification; static bool __ro_after_init feature_hwp_activity_window; =20 @@ -152,6 +154,11 @@ static int __init cf_check cpufreq_gov_hwp_init(void) } __initcall(cpufreq_gov_hwp_init); =20 +bool hwp_active(void) +{ + return hwp_in_use; +} + static bool __init hwp_available(void) { unsigned int eax; @@ -204,6 +211,8 @@ static bool __init hwp_available(void) hwp_verbose("HW_FEEDBACK %ssupported\n", (eax & CPUID6_EAX_HW_FEEDBACK) ? "" : "not "); =20 + hwp_in_use =3D true; + hwp_info("Using HWP for cpufreq\n"); =20 return true; diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c index 43831b92d1..51cb082ca0 100644 --- a/xen/arch/x86/acpi/lib.c +++ b/xen/arch/x86/acpi/lib.c @@ -26,6 +26,8 @@ #include #include =20 +#include + u32 __read_mostly acpi_smi_cmd; u8 __read_mostly acpi_enable_value; u8 __read_mostly acpi_disable_value; @@ -140,5 +142,8 @@ int arch_acpi_set_pdc_bits(u32 acpi_id, u32 *pdc, u32 m= ask) !(ecx & CPUID5_ECX_INTERRUPT_BREAK)) pdc[2] &=3D ~(ACPI_PDC_C_C1_FFH | ACPI_PDC_C_C2C3_FFH); =20 + if (hwp_active()) + pdc[2] |=3D ACPI_PDC_CPPC_NATIVE_INTR; + return 0; } diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/= mce_intel.c index 2f23f02923..4045c6591d 100644 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c @@ -15,6 +15,9 @@ #include #include #include + +#include + #include "mce.h" #include "x86_mca.h" #include "barrier.h" @@ -64,6 +67,9 @@ static void cf_check intel_thermal_interrupt(struct cpu_u= ser_regs *regs) =20 ack_APIC_irq(); =20 + if ( hwp_active() ) + wrmsr_safe(MSR_HWP_STATUS, 0); + if ( NOW() < per_cpu(next, cpu) ) return; =20 diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/as= m/msr-index.h index 56f93cb8e2..f2410fc8c8 100644 --- a/xen/arch/x86/include/asm/msr-index.h +++ b/xen/arch/x86/include/asm/msr-index.h @@ -157,6 +157,7 @@ #define MSR_HWP_CAPABILITIES 0x00000771 #define MSR_HWP_INTERRUPT 0x00000773 #define MSR_HWP_REQUEST 0x00000774 +#define MSR_HWP_STATUS 0x00000777 =20 #define MSR_X2APIC_FIRST 0x00000800 #define MSR_X2APIC_LAST 0x000008ff diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index cfe975814e..6737798e25 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -254,5 +254,6 @@ void intel_feature_detect(struct cpufreq_policy *policy= ); =20 int hwp_cmdline_parse(const char *s, const char *e); int hwp_register_driver(void); +bool hwp_active(void); =20 #endif /* __XEN_CPUFREQ_PM_H__ */ diff --git a/xen/include/acpi/pdc_intel.h b/xen/include/acpi/pdc_intel.h index 4fb719d6f5..abaa098b51 100644 --- a/xen/include/acpi/pdc_intel.h +++ b/xen/include/acpi/pdc_intel.h @@ -17,6 +17,7 @@ #define ACPI_PDC_C_C1_FFH (0x0100) #define ACPI_PDC_C_C2C3_FFH (0x0200) #define ACPI_PDC_SMP_P_HWCOORD (0x0800) +#define ACPI_PDC_CPPC_NATIVE_INTR (0x1000) =20 #define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ ACPI_PDC_C_C1_HALT | \ --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391499; cv=none; d=zohomail.com; s=zohoarc; b=SwZ73bMrlbW/YglO0d93Z+iw9ok1Q5kkHnClYsVXa2aWE+YDRC+3ZkubERiZ9RxCac0raN1QYaIi0TpKyQ16Y7FP1F/K7RjHzjSzQacBp6+ZnJcAHPnaO3kCPC7xmNweH3liwbWG3i0Ars3rWJDA0q+F1Kt9EdgvGPTJSf+ZMCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391499; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aw1/CynLpBcgrYjNJfRHcPPsQKW2D4eyDyqElDmf4oI=; b=KB9Pjj0s1nDzuNYUkltnffrjDTCX7iajF2mYxskRw/JC+7fGj/x1/uY7jBEzEcs8w/NoZLWDMIDHCxOLULHf7X0rnfm0bYJ7Ih3yMKMBqh131u984lDFEU8iRCPasWGqzaLPsmxFGQohxNKSkh4OTYeek4Iq8a9ybWfna9vQyvk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391499407466.4009684361115; Wed, 26 Jul 2023 10:11:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570644.892671 (Exim 4.92) (envelope-from ) id 1qOi2D-0000Vl-Dl; Wed, 26 Jul 2023 17:10:49 +0000 Received: by outflank-mailman (output) from mailman id 570644.892671; Wed, 26 Jul 2023 17:10:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2D-0000VR-AG; Wed, 26 Jul 2023 17:10:49 +0000 Received: by outflank-mailman (input) for mailman id 570644; Wed, 26 Jul 2023 17:10:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2B-00062Z-Sq for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:47 +0000 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [2607:f8b0:4864:20::f2a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5ca9b2f5-2bd7-11ee-b242-6b7b168915f2; Wed, 26 Jul 2023 19:10:47 +0200 (CEST) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-63cf28db24cso550706d6.2 for ; Wed, 26 Jul 2023 10:10:47 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5ca9b2f5-2bd7-11ee-b242-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391446; x=1690996246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aw1/CynLpBcgrYjNJfRHcPPsQKW2D4eyDyqElDmf4oI=; b=XE+5H+/U1l/JxMKuf+cgNLruiSGEGVMAvoOMBIduVqTeAbDcyYvFLzfw7XfkhzDb+F e5XogSOT+akLkdYONu+p2x9Al7H/FAUj8r42z/WCULB2U4bwooNMS3EV+atuImiiixsp MIEDEQU7RpGKlZnEdcWh2XEN1pD2ubeFhqubBqa8Lp/YkctR+Ra4Y76Iuxily0No2Xk2 YiQOKjeLOg7SHQL9mtk2H5uxYaVtJmf1Tqhvgaq+RQm6E2u6qxZfj5Cklmx9YTvDVJ0J C25JIjzMVF/6KYeT63Q9/7uX0Y+fo5Tc+6vaQ8qVUmpkss0vr8t4lnh33YPMpiB/kITO b94Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391446; x=1690996246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aw1/CynLpBcgrYjNJfRHcPPsQKW2D4eyDyqElDmf4oI=; b=lIV3nftCHWfHUqFWaVZIybZITaD4P+5NnC8uQcF9OsZhSYY3g5EfyzOppmBpZn6PEK m/l8mzKBMrS79tFZO7qaZfJ9Pxpw4m5iyR9SmE+TGBahA/NXowkJbQMJDPybTY+6pDa4 TpFK0X4X/UUWCKomwr77w5Fvteus6W555PgL6GqAbC/1uWHRuQTanqsFirU/EceLlOsK d3HaCUzfQF07ep6liSunD1DvJt4CsfVYXSEY92+NixF0oY4lQ4ySDEYwnDP/qcAQgUk7 Wug2JdXNaikqW18IMzvqSvjf21AGU2BjpXU69jdYSw7Yx6+3a9W2qTgTYrkfsI11BZ2j /w4Q== X-Gm-Message-State: ABy/qLYAzhd/Rt6iPjIUysdB8n8xSdGVnNN5CqHT1mg8jgWuBH9fMfvw EqcyrY98wmdnChfvbalQ6wW14exIsQ8= X-Google-Smtp-Source: APBJJlEjSvs2/Oa0C32f1xVjEOrBadhDvwiyg6kw0oc7YfDXdb2ZE5QHS5PkoFLT/v054+G0w1pD0w== X-Received: by 2002:a0c:f4d1:0:b0:62d:f515:9320 with SMTP id o17-20020a0cf4d1000000b0062df5159320mr2319724qvm.28.1690391445720; Wed, 26 Jul 2023 10:10:45 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Jan Beulich Subject: [PATCH v7 08/15] xenpm: Change get-cpufreq-para output for hwp Date: Wed, 26 Jul 2023 13:09:38 -0400 Message-ID: <20230726170945.34961-9-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391501631100001 Content-Type: text/plain; charset="utf-8" When using HWP, some of the returned data is not applicable. In that case, we should just omit it to avoid confusing the user. So switch to printing the base and max frequencies since those are relevant to HWP. Similarly, stop printing the CPU frequencies since those do not apply. The scaling fields are also no longer printed. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich Acked-by: Anthony PERARD --- v5: Use XEN_HWP_DRIVER_NAME Add Jan's Ack v4: s/turbo/max/ Check for XEN_HWP_DRIVER driver instead of "-internal" v2: Use full governor name XEN_HWP_GOVERNOR to change output Style fixes --- tools/misc/xenpm.c | 83 +++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 1c474c3b59..21c93386de 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -711,6 +711,7 @@ void start_gather_func(int argc, char *argv[]) /* print out parameters about cpu frequency */ static void print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para *p_cp= ufreq) { + bool hwp =3D strcmp(p_cpufreq->scaling_driver, XEN_HWP_DRIVER_NAME) = =3D=3D 0; int i; =20 printf("cpu id : %d\n", cpuid); @@ -720,49 +721,57 @@ static void print_cpufreq_para(int cpuid, struct xc_g= et_cpufreq_para *p_cpufreq) printf(" %d", p_cpufreq->affected_cpus[i]); printf("\n"); =20 - printf("cpuinfo frequency : max [%u] min [%u] cur [%u]\n", - p_cpufreq->cpuinfo_max_freq, - p_cpufreq->cpuinfo_min_freq, - p_cpufreq->cpuinfo_cur_freq); + if ( hwp ) + printf("cpuinfo frequency : base [%u] max [%u]\n", + p_cpufreq->cpuinfo_min_freq, + p_cpufreq->cpuinfo_max_freq); + else + printf("cpuinfo frequency : max [%u] min [%u] cur [%u]\n", + p_cpufreq->cpuinfo_max_freq, + p_cpufreq->cpuinfo_min_freq, + p_cpufreq->cpuinfo_cur_freq); =20 printf("scaling_driver : %s\n", p_cpufreq->scaling_driver); =20 - printf("scaling_avail_gov : %s\n", - p_cpufreq->scaling_available_governors); - - printf("current_governor : %s\n", p_cpufreq->u.s.scaling_governor); - if ( !strncmp(p_cpufreq->u.s.scaling_governor, - "userspace", CPUFREQ_NAME_LEN) ) - { - printf(" userspace specific :\n"); - printf(" scaling_setspeed : %u\n", - p_cpufreq->u.s.u.userspace.scaling_setspeed); - } - else if ( !strncmp(p_cpufreq->u.s.scaling_governor, - "ondemand", CPUFREQ_NAME_LEN) ) + if ( !hwp ) { - printf(" ondemand specific :\n"); - printf(" sampling_rate : max [%u] min [%u] cur [%u]\n", - p_cpufreq->u.s.u.ondemand.sampling_rate_max, - p_cpufreq->u.s.u.ondemand.sampling_rate_min, - p_cpufreq->u.s.u.ondemand.sampling_rate); - printf(" up_threshold : %u\n", - p_cpufreq->u.s.u.ondemand.up_threshold); - } + printf("scaling_avail_gov : %s\n", + p_cpufreq->scaling_available_governors); =20 - printf("scaling_avail_freq :"); - for ( i =3D 0; i < p_cpufreq->freq_num; i++ ) - if ( p_cpufreq->scaling_available_frequencies[i] =3D=3D - p_cpufreq->u.s.scaling_cur_freq ) - printf(" *%d", p_cpufreq->scaling_available_frequencies[i]); - else - printf(" %d", p_cpufreq->scaling_available_frequencies[i]); - printf("\n"); + printf("current_governor : %s\n", p_cpufreq->u.s.scaling_gover= nor); + if ( !strncmp(p_cpufreq->u.s.scaling_governor, + "userspace", CPUFREQ_NAME_LEN) ) + { + printf(" userspace specific :\n"); + printf(" scaling_setspeed : %u\n", + p_cpufreq->u.s.u.userspace.scaling_setspeed); + } + else if ( !strncmp(p_cpufreq->u.s.scaling_governor, + "ondemand", CPUFREQ_NAME_LEN) ) + { + printf(" ondemand specific :\n"); + printf(" sampling_rate : max [%u] min [%u] cur [%u]\n", + p_cpufreq->u.s.u.ondemand.sampling_rate_max, + p_cpufreq->u.s.u.ondemand.sampling_rate_min, + p_cpufreq->u.s.u.ondemand.sampling_rate); + printf(" up_threshold : %u\n", + p_cpufreq->u.s.u.ondemand.up_threshold); + } + + printf("scaling_avail_freq :"); + for ( i =3D 0; i < p_cpufreq->freq_num; i++ ) + if ( p_cpufreq->scaling_available_frequencies[i] =3D=3D + p_cpufreq->u.s.scaling_cur_freq ) + printf(" *%d", p_cpufreq->scaling_available_frequencies[i]= ); + else + printf(" %d", p_cpufreq->scaling_available_frequencies[i]); + printf("\n"); =20 - printf("scaling frequency : max [%u] min [%u] cur [%u]\n", - p_cpufreq->u.s.scaling_max_freq, - p_cpufreq->u.s.scaling_min_freq, - p_cpufreq->u.s.scaling_cur_freq); + printf("scaling frequency : max [%u] min [%u] cur [%u]\n", + p_cpufreq->u.s.scaling_max_freq, + p_cpufreq->u.s.scaling_min_freq, + p_cpufreq->u.s.scaling_cur_freq); + } =20 printf("turbo mode : %s\n", p_cpufreq->turbo_enabled ? "enabled" : "disabled or n/a"); --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391480; cv=none; d=zohomail.com; s=zohoarc; b=kOmUKh+z1atiou3NyjCg7VBqz//agjX2+ICGOnUzP0HFvJQRxuFiaghhHfKbM9J/0IffM6Y6EhyMVaJWwXn8i8ULBRSKxcWubdLz9n1HqY6KbkSiUqt8tAadncNLdJXdR2tq04kog/fOIhTHvBxRVPyaBCa2LkwQm0l3wfgawb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391480; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K2sbheRINo4VFvlSN5rNXGSmFJJ8xrco/X7vhWz8eac=; b=dMxpgNFHqs35tR8+0M5vzYA1tLGATy+sp2YST8zixsOE2ZkJBniHbGpP3zBM2FNjlv0GfYRjksejP2J64yLSALsC6oieRVIkke/ORjuiwn7pSA/ji52dzvEXlPHNu+1fegL5cEAzDdHqBaqQghBs/z5dMD4WaJlIBhZ9Qp+qnOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169039148050533.13732845385266; Wed, 26 Jul 2023 10:11:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570646.892681 (Exim 4.92) (envelope-from ) id 1qOi2K-00016k-Ns; Wed, 26 Jul 2023 17:10:56 +0000 Received: by outflank-mailman (output) from mailman id 570646.892681; Wed, 26 Jul 2023 17:10:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2K-00016b-Jv; Wed, 26 Jul 2023 17:10:56 +0000 Received: by outflank-mailman (input) for mailman id 570646; Wed, 26 Jul 2023 17:10:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2J-0005nP-Vr for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:10:55 +0000 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [2607:f8b0:4864:20::f32]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 60510bed-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:53 +0200 (CEST) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-63cff46ddb8so5962326d6.1 for ; Wed, 26 Jul 2023 10:10:54 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:51 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 60510bed-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391452; x=1690996252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K2sbheRINo4VFvlSN5rNXGSmFJJ8xrco/X7vhWz8eac=; b=PUgtygZ2PxRMkOmMBkfTx5nM1kb06bcbsMZ2Q9iZC7AMrRAVFeIL96veVLFdL5gSdO Hn2w+pKfhxsBWWquodC0bkg0vxu0G8rMtR8Fq1O9Lf861QJxMSrQrVlgwa9hTsf0hAG5 5G6WBBI97u+NN+YDuOkCD9qpIoQ9yNIHOJGwvgY7c/NOSfrK8Js3ko6rh6/wU6bh+ZX8 2LU7Dh3WGMo/2nJ+Qsn6X19YMfOyNWGZeBVaAwtTXphR4BstTka5htVbN7agGCw8LiGW HkF5lVqZC1wN7gCOi/8Kv7qwxMCFTMKisutgpHeuyqLEkqotXmVXjPUZaIipn9SQon95 CkAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391452; x=1690996252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K2sbheRINo4VFvlSN5rNXGSmFJJ8xrco/X7vhWz8eac=; b=kYECaWh0/jcnlHmvSZDIYoY6OaE7vvw+VgFBNCaZMZ0JrqkqXXo3LLZ8A+brO044VW WD/+5CodUuSU5gDGbDtRTD/Q/L9lqlx3+UHFuKjw1MjkGEza1/dKoP/AJzRTDguartcj 4iz2T3YVvsGirnaogsK5hTo5BSBUal4jApl7zCru8zmmdq7W06BsieLPaQKNmNgKzFYE 2Q+jzR+oL2fYsrdXpq/glnGKT7U95AFNRAXYm0IFIqPj8S4l0XTx55TWiEK25G3l6Zmk D6c0u4XaIVugqbzwDBuXgVQCOhCCv5ftztV/khT0BoRMgcOFL2oEFC98Zy4oefXRUsEN DuoQ== X-Gm-Message-State: ABy/qLa/TSFRtVwk11euj1PEGhMemzky1EVH2z+QRgHN2LmsWuim2e4F Et737Kt0n48ebjg72bayoWWKrpF/ES8= X-Google-Smtp-Source: APBJJlE73X9ug3IokrAryclx1+D8g36w/zKCkqzGfvPPweuuNqfRWPweY/RmfK3IMYBkazq4v7/bPw== X-Received: by 2002:ad4:5c47:0:b0:635:f546:83d0 with SMTP id a7-20020ad45c47000000b00635f54683d0mr192322qva.11.1690391452343; Wed, 26 Jul 2023 10:10:52 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v7 09/15] cpufreq: Export HWP parameters to userspace as CPPC Date: Wed, 26 Jul 2023 13:09:39 -0400 Message-ID: <20230726170945.34961-10-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391482468100001 Content-Type: text/plain; charset="utf-8" Extend xen_get_cpufreq_para to return hwp parameters. HWP is an implementation of ACPI CPPC (Collaborative Processor Performance Control). Use the CPPC name since that might be useful in the future for AMD P-state. We need the features bitmask to indicate fields supported by the actual hardware - this only applies to activity window for the time being. The HWP most_efficient is mapped to CPPC lowest_nonlinear, and guaranteed is mapped to nominal. CPPC has a guaranteed that is optional while nominal is required. ACPI spec says "If this register is not implemented, OSPM assumes guaranteed performance is always equal to nominal performance." Signed-off-by: Jason Andryuk Acked-by: Jan Beulich --- v2: Style fixes Don't bump XEN_SYSCTL_INTERFACE_VERSION Drop cpufreq.h comment divider Expand xen_hwp_para comment Add HWP activity window mantissa/exponent defines Handle union rename Add const to get_hwp_para Remove hw_ prefix from xen_hwp_para members Use XEN_HWP_GOVERNOR Use per_cpu for hwp_drv_data v4: Fixup for opt_cpufreq_hwp/hdc removal get_hwp_para() takes cpu as arg XEN_ prefix HWP_ACT_WINDOW_* Drop HWP_ACT_WINDOW_EXPONENT_SHIFT - shift MASK Remove Energy Bias (0-15) EPP fallback Rename xen_hwp_para to xen_cppc_para s/hwp/cppc/ Use scaling driver to switch output v5: Use XEN_HWP_DRIVER_NAME Use cpufreq.h for declarations Fixup some comments Drop const from unsigned int cpu Drop some unnecessary { } Use strncmp Switch sizeof(char) to sizeof(*scaling_available_governors) Reindent copy_to_guest call Add "HWP: " prefix to sysctl comments for cppc->hwp mapping v6: Drop commit message uint8_t paragraph sysctl.h s/They/They're/ Fix indent and add parens for read_scaling_available_governors() args Add Jan's Ack --- xen/arch/x86/acpi/cpufreq/hwp.c | 23 ++++++++++ xen/drivers/acpi/pmstat.c | 74 ++++++++++++++++-------------- xen/include/acpi/cpufreq/cpufreq.h | 2 + xen/include/public/sysctl.h | 56 ++++++++++++++++++++++ 4 files changed, 121 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hw= p.c index 33039ad39e..2cbfa1ce33 100644 --- a/xen/arch/x86/acpi/cpufreq/hwp.c +++ b/xen/arch/x86/acpi/cpufreq/hwp.c @@ -519,6 +519,29 @@ static const struct cpufreq_driver __initconstrel hwp_= cpufreq_driver =3D .update =3D hwp_cpufreq_update, }; =20 +int get_hwp_para(unsigned int cpu, + struct xen_cppc_para *cppc_para) +{ + const struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + + if ( data =3D=3D NULL ) + return -ENODATA; + + cppc_para->features =3D + (feature_hwp_activity_window ? XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW : 0= ); + cppc_para->lowest =3D data->hw.lowest; + cppc_para->lowest_nonlinear =3D data->hw.most_efficient; + cppc_para->nominal =3D data->hw.guaranteed; + cppc_para->highest =3D data->hw.highest; + cppc_para->minimum =3D data->minimum; + cppc_para->maximum =3D data->maximum; + cppc_para->desired =3D data->desired; + cppc_para->energy_perf =3D data->energy_perf; + cppc_para->activity_window =3D data->activity_window; + + return 0; +} + int __init hwp_register_driver(void) { int ret; diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index d67d99e62f..e4e2df94a7 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -251,46 +251,52 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *= op) else strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN= ); =20 - if ( !(scaling_available_governors =3D - xzalloc_array(char, gov_num * CPUFREQ_NAME_LEN)) ) - return -ENOMEM; - if ( (ret =3D read_scaling_available_governors(scaling_available_gover= nors, - gov_num * CPUFREQ_NAME_LEN * sizeof(char))) ) + if ( !strncmp(op->u.get_para.scaling_driver, XEN_HWP_DRIVER_NAME, + CPUFREQ_NAME_LEN) ) + ret =3D get_hwp_para(policy->cpu, &op->u.get_para.u.cppc_para); + else { + if ( !(scaling_available_governors =3D + xzalloc_array(char, gov_num * CPUFREQ_NAME_LEN)) ) + return -ENOMEM; + if ( (ret =3D read_scaling_available_governors( + scaling_available_governors, + (gov_num * CPUFREQ_NAME_LEN * + sizeof(*scaling_available_governors)))) ) + { + xfree(scaling_available_governors); + return ret; + } + ret =3D copy_to_guest(op->u.get_para.scaling_available_governors, + scaling_available_governors, + gov_num * CPUFREQ_NAME_LEN); xfree(scaling_available_governors); - return ret; - } - ret =3D copy_to_guest(op->u.get_para.scaling_available_governors, - scaling_available_governors, gov_num * CPUFREQ_NAME_LEN); - xfree(scaling_available_governors); - if ( ret ) - return ret; + if ( ret ) + return ret; =20 - op->u.get_para.u.s.scaling_cur_freq =3D policy->cur; - op->u.get_para.u.s.scaling_max_freq =3D policy->max; - op->u.get_para.u.s.scaling_min_freq =3D policy->min; + op->u.get_para.u.s.scaling_cur_freq =3D policy->cur; + op->u.get_para.u.s.scaling_max_freq =3D policy->max; + op->u.get_para.u.s.scaling_min_freq =3D policy->min; =20 - if ( policy->governor->name[0] ) - strlcpy(op->u.get_para.u.s.scaling_governor, - policy->governor->name, CPUFREQ_NAME_LEN); - else - strlcpy(op->u.get_para.u.s.scaling_governor, "Unknown", CPUFREQ_NA= ME_LEN); + if ( policy->governor->name[0] ) + strlcpy(op->u.get_para.u.s.scaling_governor, + policy->governor->name, CPUFREQ_NAME_LEN); + else + strlcpy(op->u.get_para.u.s.scaling_governor, "Unknown", + CPUFREQ_NAME_LEN); =20 - /* governor specific para */ - if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, - "userspace", CPUFREQ_NAME_LEN) ) - { - op->u.get_para.u.s.u.userspace.scaling_setspeed =3D policy->cur; - } + /* governor specific para */ + if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, + "userspace", CPUFREQ_NAME_LEN) ) + op->u.get_para.u.s.u.userspace.scaling_setspeed =3D policy->cu= r; =20 - if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, - "ondemand", CPUFREQ_NAME_LEN) ) - { - ret =3D get_cpufreq_ondemand_para( - &op->u.get_para.u.s.u.ondemand.sampling_rate_max, - &op->u.get_para.u.s.u.ondemand.sampling_rate_min, - &op->u.get_para.u.s.u.ondemand.sampling_rate, - &op->u.get_para.u.s.u.ondemand.up_threshold); + if ( !strncasecmp(op->u.get_para.u.s.scaling_governor, + "ondemand", CPUFREQ_NAME_LEN) ) + ret =3D get_cpufreq_ondemand_para( + &op->u.get_para.u.s.u.ondemand.sampling_rate_max, + &op->u.get_para.u.s.u.ondemand.sampling_rate_min, + &op->u.get_para.u.s.u.ondemand.sampling_rate, + &op->u.get_para.u.s.u.ondemand.up_threshold); } =20 return ret; diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index 6737798e25..f90e9d3a6c 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -255,5 +255,7 @@ void intel_feature_detect(struct cpufreq_policy *policy= ); int hwp_cmdline_parse(const char *s, const char *e); int hwp_register_driver(void); bool hwp_active(void); +int get_hwp_para(unsigned int cpu, + struct xen_cppc_para *cppc_para); =20 #endif /* __XEN_CPUFREQ_PM_H__ */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 5a30b16fcf..cf27f8f2f9 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -296,6 +296,61 @@ struct xen_ondemand { uint32_t up_threshold; }; =20 +struct xen_cppc_para { + /* OUT */ + /* activity_window supported if set */ +#define XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW (1 << 0) + uint32_t features; /* bit flags for features */ + /* + * See Intel SDM: HWP Performance Range and Dynamic Capabilities + * + * These four are 0-255 hardware-provided values. They're "continuous, + * abstract unit-less, performance" values. Smaller numbers are slower + * and larger ones are faster. + */ + uint32_t lowest; + uint32_t lowest_nonlinear; /* HWP: most_efficient */ + uint32_t nominal; /* HWP: guaranteed */ + uint32_t highest; + /* + * See Intel SDM: IA32_HWP_REQUEST MSR (Address: 774H Logical Processor + * Scope) + * + * These are all hints, and the processor may deviate outside of them. + * Values below are 0-255. + * + * minimum and maximum can be set to the above hardware values to cons= train + * operation. The full range 0-255 is accepted and will be clipped by + * hardware. + */ + uint32_t minimum; + uint32_t maximum; + /* + * An explicit performance hint, disabling hardware selection. + * 0 lets the hardware decide. + */ + uint32_t desired; + /* + * Hint to hardware for energy/performance preference. + * 0: Performance + * 128: Balance (Default) + * 255: Powersaving + */ + uint32_t energy_perf; + /* + * Activity Window is a moving history window for the processor's oper= ation + * calculations, controlling responsiveness. Measured in microseconds + * encoded as: + * + * bits 6:0 - 7bit mantissa + * bits 9:7 - 3bit base-10 exponent + * btis 15:10 - Unused - must be 0 + */ +#define XEN_CPPC_ACT_WINDOW_MANTISSA_MASK 0x07f +#define XEN_CPPC_ACT_WINDOW_EXPONENT_MASK 0x380 + uint32_t activity_window; +}; + #define XEN_HWP_DRIVER_NAME "hwp" =20 /* @@ -333,6 +388,7 @@ struct xen_get_cpufreq_para { struct xen_ondemand ondemand; } u; } s; + struct xen_cppc_para cppc_para; } u; =20 int32_t turbo_enabled; --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391507; cv=none; d=zohomail.com; s=zohoarc; b=dOCLcDvdC28RhVSXQEp0mHgGPgVEDkamCAiFUgqSdlrIvsxFjtY2MsWAI+v3nFupAsx5LrManzjrsKG5LKOs6OW3a6/mPHzAE/sBauiUwQG6hPXiwAz6wBZMY0j6+isblGDD/xVfZ/eZoj0YuXmzoURl89owhJsZdC7Au959zSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5g90NEIr2gEQRrKv4KW4CuJMuwsS8xE3NxELsPnfYWs=; b=W/kxtU/kxUNH/8Q+q4Y0BbddSifeTg7r19br8Uq0Lw4tU4wbX0Xf3IKn+O+VErTfSs59URHXeI9l73kJDZry0aPhn3YF5VC1oiNMIhdaEY4F6mJaefJk0NaWSfEy5oRqCDPwWIHdSU6jznM0RuIUd19hOkjOm4w4nKNj1afXW/s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391507449624.158933672181; Wed, 26 Jul 2023 10:11:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570650.892690 (Exim 4.92) (envelope-from ) id 1qOi2Q-0001oy-71; Wed, 26 Jul 2023 17:11:02 +0000 Received: by outflank-mailman (output) from mailman id 570650.892690; Wed, 26 Jul 2023 17:11:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2Q-0001o2-3o; Wed, 26 Jul 2023 17:11:02 +0000 Received: by outflank-mailman (input) for mailman id 570650; Wed, 26 Jul 2023 17:11:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2O-0005nP-KU for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:00 +0000 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [2607:f8b0:4864:20::22f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 632e1871-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:10:58 +0200 (CEST) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a5ad44dc5aso59885b6e.3 for ; Wed, 26 Jul 2023 10:10:59 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:10:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 632e1871-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391457; x=1690996257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5g90NEIr2gEQRrKv4KW4CuJMuwsS8xE3NxELsPnfYWs=; b=ieIvb0nsEqn45EN9wBUG7zCS0ysQE3YMY/JPe3LBe5YSqZVCLms2wsrlKDh6wggile LjQT8tcD2aEifnw6oE7EsHtLIDhmp7BWcvmsdMDuO/aSvt/vaDLeG2TBTyZR37+paTRQ sMWBeoc2Z0OfMWHSnCHY4mUyv/VUEQcEEQ+MdT8n7g2XexZwKdoH62D7quutmw7KtcOD XjRSWq+4DFXTkz9Koj9b38WyPMtm8ZNYs4ZcUyGCCYC5n+gDehy+ctS8caP7/hNv/gFW unVctgbgLcORrCrEbED9R9Smopv+SNuog6F0XqCzAAL/vmiDz9eGHl+W8cNcwPwZb6fX gELg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391457; x=1690996257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5g90NEIr2gEQRrKv4KW4CuJMuwsS8xE3NxELsPnfYWs=; b=KSTiZew5Gsriszzvf4ff8HO1W8ceTcq+YMeKoVYeJ1aB16HkNRxHMMz9v9Mc/X3P1V tTqObSMl0R71JCWevdaE1B1fyttvN4BGNqgqREC7PCGB3W4JK+VFh5xEY6STwqV9O9Nw OFqEVNFwrOuUjKPMBAcvQXoSHrRrVRezmUaV1AcyyX/zPYVKSM+pwmlLSm4ORV3+MMfp vsemXZ5FisEAXdcgHv0zrPs6xF1feiuPDBASoLVzXTVpPzxVP9m62Sicq9TPPse8XBqH PF7tXz8s8Gl78Rbo5kSOGvVdaI+g+ytEF6LySjHSEFoBLQoiV1LOpGpjt7Af/p4TNpcQ 954Q== X-Gm-Message-State: ABy/qLas6AIG8varAeUWoYueVYmeskk/eLKGQU0rg/gH3ka4UWBc5nxk KsG1/Ux3EgCaJcvcRL0xnXPYnqTwREE= X-Google-Smtp-Source: APBJJlEupFohQgvxB5P2BCuegnEvzZJOKE+6E6RhSIp0mlGObHvccrBu5ABGhPxiXxPdStE3Xh90nQ== X-Received: by 2002:a05:6808:bc7:b0:3a3:eab8:8c40 with SMTP id o7-20020a0568080bc700b003a3eab88c40mr135683oik.54.1690391457086; Wed, 26 Jul 2023 10:10:57 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v7 10/15] libxc: Include cppc_para in definitions Date: Wed, 26 Jul 2023 13:09:40 -0400 Message-ID: <20230726170945.34961-11-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391509634100001 Content-Type: text/plain; charset="utf-8" Expose the cppc_para fields through libxc. Signed-off-by: Jason Andryuk Acked-by: Anthony PERARD --- v4: Rename hwp to cppc Add Anthony's Ack --- tools/include/xenctrl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 8aedb952a0..2092632296 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1892,6 +1892,7 @@ int xc_smt_disable(xc_interface *xch); */ typedef struct xen_userspace xc_userspace_t; typedef struct xen_ondemand xc_ondemand_t; +typedef struct xen_cppc_para xc_cppc_para_t; =20 struct xc_get_cpufreq_para { /* IN/OUT variable */ @@ -1923,6 +1924,7 @@ struct xc_get_cpufreq_para { xc_ondemand_t ondemand; } u; } s; + xc_cppc_para_t cppc_para; } u; =20 int32_t turbo_enabled; --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391877; cv=none; d=zohomail.com; s=zohoarc; b=HmKPa1Gd2U4Y0h0E7Gnt8wrMPe4q9xrkVsT/dDO1EFx+BRTIBwzlcP/rnzVqetWfa9Me/8IXzFThJenEEUoKp/nRknh1xmj86mdc3DhPRb1VqzR8pvH3CWHggpa8UJDhLJS6BcXii9pS+woKNkXNsMULRx0UIoaMqvwEfHsNWQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391877; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=imeu59UbyEmxk/60do4rzt8IPOfqsoGRviRd+fRZmSg=; b=Xg71UuBJQ7YSjdebGNpAE+zcWJ+9No34bUwGEB6UxPYXfAX47p8oYesa655E04SAk8gIA5WKZuHd6OY6YlupBJRfK7IffxzF1mTKcV4sM2W5o1QJQyuqMBryIIXTZ21CNos9WIFJZX40W31lS0VUT/0wUXXbQN+SYbZ0BGyF85o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391877809103.04855041480016; Wed, 26 Jul 2023 10:17:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570656.892701 (Exim 4.92) (envelope-from ) id 1qOi8Y-0003l6-Vj; Wed, 26 Jul 2023 17:17:22 +0000 Received: by outflank-mailman (output) from mailman id 570656.892701; Wed, 26 Jul 2023 17:17:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi8Y-0003kz-Ro; Wed, 26 Jul 2023 17:17:22 +0000 Received: by outflank-mailman (input) for mailman id 570656; Wed, 26 Jul 2023 17:17:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2S-0005nP-GG for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:04 +0000 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [2607:f8b0:4864:20::f2c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65880181-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:11:02 +0200 (CEST) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6378cec43ddso375246d6.2 for ; Wed, 26 Jul 2023 10:11:02 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:11:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 65880181-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391461; x=1690996261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=imeu59UbyEmxk/60do4rzt8IPOfqsoGRviRd+fRZmSg=; b=cfCWBHQN8Rx3skIwDb8tQKTb4yWLK4tNuauqP7/MkSC+Nyh3LyrBID5/Boz2Gx4Zwl KZxZirZdeRGoY15ZRY2G+pvyiZXofrEdvFGe+HJeHw13kfcszDjc4hL+p7J6SG8aZSEJ JyP8EtgLp1zRNihXxGq1XhJw2D205C8Fo2gr+u8BMiZUVdgg5DF3kjgA5x3MlZp/06LJ KmVbJ2f9CAJDW3JY3goGxrEyTyx6JDUQa/DByhUOl4Gx/7ZzqOWeBjYP0tEBkV9yqufn r6lDya10frr0lN54lmVKbYjpP3wtP9aj3BfpJbKocPFfcwiH12a10hAz22DUAeEI7/Zk boRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391461; x=1690996261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=imeu59UbyEmxk/60do4rzt8IPOfqsoGRviRd+fRZmSg=; b=NWCNpzIq0AdqzEat3spWQlSaS1s66TWf0CzEhCVOJzXQrEeoF34045YfwS7lI+L6Pb Jsp65jVdPj1Bn4qGhXj3W4rX9URjkNOqyNZ1w77Y66duzw/ANCYjWlovH45mo4klGPT+ R65hVukc07nrKiN5GAVNQ3/z/DjQfRsMrsFSixcspXJnhtbikrLhNarVfwak//aVV4Y1 0bxHbqQy+arzf6XU8/3pQZrH6wdvbQJbrBb1ns3ZMq6AGbJ53Rn0mHDAJnRIx5WA1crc GQR6Y6btqboQbiaSHN6tmMzl+WM+dbmr2FmjBEuUvc75CE+IC8DpjZuIIVs0GRlB4EKv 84iQ== X-Gm-Message-State: ABy/qLZtrCV8lJXPW/IvQ4w8sKyxhG72g8BWkhBfV4wzOxvGwsp2i4eZ Dq4Dr4k7nwqw0shwEh8uotaB+JQlgtU= X-Google-Smtp-Source: APBJJlE+vt1k5qigt2ot0tq2Cf86zCqHXL5I/dtYIhfnyiUGkSEF61FqmaMokrlG483z9w5brciStw== X-Received: by 2002:a0c:e305:0:b0:63c:fbd0:84a6 with SMTP id s5-20020a0ce305000000b0063cfbd084a6mr2839134qvl.5.1690391461166; Wed, 26 Jul 2023 10:11:01 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Jan Beulich Subject: [PATCH v7 11/15] xenpm: Print HWP/CPPC parameters Date: Wed, 26 Jul 2023 13:09:41 -0400 Message-ID: <20230726170945.34961-12-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391878590100001 Content-Type: text/plain; charset="utf-8" Print HWP-specific parameters. Some are always present, but others depend on hardware support. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v2: Style fixes Declare i outside loop Replace repearted hardware/configured limits with spaces Fixup for hw_ removal Use XEN_HWP_GOVERNOR Use HWP_ACT_WINDOW_EXPONENT_* Remove energy_perf hw autonomous - 0 doesn't mean autonomous v4: Return activity_window from calculate_hwp_activity_window Use blanks instead of _ in output Use MASK_EXTR Check XEN_HWP_DRIVER name since governor is no longer returned s/hwp/cppc v5: Add Jan's Reviewed-by --- tools/misc/xenpm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 21c93386de..3abd99fd20 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -708,6 +708,46 @@ void start_gather_func(int argc, char *argv[]) pause(); } =20 +static unsigned int calculate_activity_window(const xc_cppc_para_t *cppc, + const char **units) +{ + unsigned int mantissa =3D MASK_EXTR(cppc->activity_window, + XEN_CPPC_ACT_WINDOW_MANTISSA_MASK); + unsigned int exponent =3D MASK_EXTR(cppc->activity_window, + XEN_CPPC_ACT_WINDOW_EXPONENT_MASK); + unsigned int multiplier =3D 1; + unsigned int i; + + /* + * SDM only states a 0 register is hardware selected, and doesn't ment= ion + * a 0 mantissa with a non-0 exponent. Only special case a 0 register. + */ + if ( cppc->activity_window =3D=3D 0 ) + { + *units =3D "hardware selected"; + + return 0; + } + + if ( exponent >=3D 6 ) + { + *units =3D "s"; + exponent -=3D 6; + } + else if ( exponent >=3D 3 ) + { + *units =3D "ms"; + exponent -=3D 3; + } + else + *units =3D "us"; + + for ( i =3D 0; i < exponent; i++ ) + multiplier *=3D 10; + + return mantissa * multiplier; +} + /* print out parameters about cpu frequency */ static void print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para *p_cp= ufreq) { @@ -772,6 +812,32 @@ static void print_cpufreq_para(int cpuid, struct xc_ge= t_cpufreq_para *p_cpufreq) p_cpufreq->u.s.scaling_min_freq, p_cpufreq->u.s.scaling_cur_freq); } + else + { + const xc_cppc_para_t *cppc =3D &p_cpufreq->u.cppc_para; + + printf("cppc variables :\n"); + printf(" hardware limits : lowest [%u] lowest nonlinear [%u]\n= ", + cppc->lowest, cppc->lowest_nonlinear); + printf(" : nominal [%u] highest [%u]\n", + cppc->nominal, cppc->highest); + printf(" configured limits : min [%u] max [%u] energy perf [%u]\= n", + cppc->minimum, cppc->maximum, cppc->energy_perf); + + if ( cppc->features & XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW ) + { + unsigned int activity_window; + const char *units; + + activity_window =3D calculate_activity_window(cppc, &units); + printf(" : activity_window [%u %s]\n", + activity_window, units); + } + + printf(" : desired [%u%s]\n", + cppc->desired, + cppc->desired ? "" : " hw autonomous"); + } =20 printf("turbo mode : %s\n", p_cpufreq->turbo_enabled ? "enabled" : "disabled or n/a"); --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391919; cv=none; d=zohomail.com; s=zohoarc; b=fNoAXB4iaQbK3ZVAWG5S5YXbLCLInHIok3EtRehMvVGZsHc1VFr1ad4eilfJgeaNaQBiDyx8Hu9uUBfxCxj+cKQ+RoYQBfOB87IygDRvDMUwO57JV7u2d4MyVezwCEgaKLkyAsnJPW1Ct1tkRtB71KSAwQyCTFMfarou9DtoGLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391919; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JCi5HaPn3Xps1XhyXm+DfozNO0fjTdxPuxSUYqHSx3Q=; b=DmHgX1ax3TadkMFAdxbzcxXCxXQZr95SXyz5TDT7HPCaeBVpWCvhOzwl5S+V2c9HW/+XuqEc6KAxtq0er2qtmZtHes2Er8IWJOAmNU4tmgN1KBKvor+oV61ulVwmyduJrZyzMxMIZpqWEwMiFRIUrjGGLjopgFsDSv8P9SMxp94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391919967134.99922139835758; Wed, 26 Jul 2023 10:18:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570660.892705 (Exim 4.92) (envelope-from ) id 1qOi8Z-0003nW-7X; Wed, 26 Jul 2023 17:17:23 +0000 Received: by outflank-mailman (output) from mailman id 570660.892705; Wed, 26 Jul 2023 17:17:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi8Z-0003mI-23; Wed, 26 Jul 2023 17:17:23 +0000 Received: by outflank-mailman (input) for mailman id 570660; Wed, 26 Jul 2023 17:17:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2f-0005nP-Sk for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:17 +0000 Received: from mail-vk1-xa2d.google.com (mail-vk1-xa2d.google.com [2607:f8b0:4864:20::a2d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6d5bbe92-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:11:15 +0200 (CEST) Received: by mail-vk1-xa2d.google.com with SMTP id 71dfb90a1353d-460eb67244eso14761e0c.1 for ; Wed, 26 Jul 2023 10:11:15 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:11:13 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6d5bbe92-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391474; x=1690996274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JCi5HaPn3Xps1XhyXm+DfozNO0fjTdxPuxSUYqHSx3Q=; b=QKSBu0CJbw4jvtof2NIUzuQfKhuoB/4YB6+TugWvyYBDRWHt+O1mMl+L8IiFvwpoLw mSZti1m6z6FdywVdRvbtvjRZD5Yum0s1MjvNOo1Gd5MUHoKKBl70JF88WxhygHMFeqXO siPiTF7TAbLaoPT8FVCk1ao2SnSk5XzCGbu0SCmhe+GaNQQFaUblI3+AJrIi4ppdrLPu CjtuZMm4uYXuezyI8v1OMUb+LDnw/tPF9F6yPrd9U4SDl2pfilVnqflIbkZixzH6MHJ1 IegXcAT4+Q7L73dZPDMZY53VK4WR7fNmEpCqHCcBLsPEsqZmH+4/ZYPCnyrUDqHAWEML R/dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391474; x=1690996274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JCi5HaPn3Xps1XhyXm+DfozNO0fjTdxPuxSUYqHSx3Q=; b=WYn/274q0rrFPjIthE7BM4iEwgea3yTx9T+yAE6Ty9xx/eNdAYdKyDnmiJDQmP0/Oe MSazFOEmVTt+xjFSi7SIBpRZizkn4F6r/3d1g4vE7+qRpB2YpGXJ3/uoC77OYT17V5gX CeEwUSKNGSPiOfq1fM8Py+Jso+bFkQJXNtLQ4lFmUzl92bNdarijGXBFpS8/tXdSwOez tvnuE4PtMYzR0CfHasbMHJS9Z42PzuIEs/cgg4DtemYpnCfNsvEM6yNs6YOxVJ3pW0bh qAknW4r1vSNL2SX0/oslK+hpIYFw96C6vYQ4jM03WMIRhhqvBQWBvN8Bj5KlgNknx+pv GsIg== X-Gm-Message-State: ABy/qLaIXQXGDX11BIDB3fXJ+x/QvsHd5bbqn1RUBq4a79fz1hawuN8Y lATUHyzfgZFW25bS/S9jhhQPoXdvpmU= X-Google-Smtp-Source: APBJJlGuGAhlyw4qgQUlaL2FJdN0ZutGtZhpCc/OfEfdsDWNEVCdRD702YEb5ZdlnQ0J8ETF5Ax5tw== X-Received: by 2002:a1f:c402:0:b0:485:f674:dcea with SMTP id u2-20020a1fc402000000b00485f674dceamr1585279vkf.16.1690391474118; Wed, 26 Jul 2023 10:11:14 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v7 12/15] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op Date: Wed, 26 Jul 2023 13:09:42 -0400 Message-ID: <20230726170945.34961-13-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391921706100001 Content-Type: text/plain; charset="utf-8" Add SET_CPUFREQ_HWP xen_sysctl_pm_op to set HWP parameters. The sysctl supports setting multiple values simultaneously as indicated by the set_params bits. This allows atomically applying new HWP configuration via a single wrmsr. XEN_SYSCTL_HWP_SET_PRESET_BALANCE/PERFORMANCE/POWERSAVE provide three common presets. Setting them depends on hardware limits which the hypervisor is already caching. So using them allows skipping a hypercall to query the limits (lowest/highest) to then set those same values. The code is organized to allow a preset to be refined with additional parameters if desired. "most_efficient" and "guaranteed" could be additional presets in the future, but the are not added now. Those levels can change at runtime, but we don't have code in place to monitor and update for those events. Since activity window may not be supported by all hardware, omit writing it when not supported, and return that fact to userspace by updating set_params. CPPC parameter checking disallows setting reserved bytes and ensure values are only non-zero when the corresponding set_params bit is set. There is no range checking (0-255 is allowed) since hardware is documented to clip internally. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v7: Fix brace placement Add Jan's R-b v6: Add () around bit test Add U suffix to XEN_SYSCTL_ constants Change -EINVAL returns to -ENOENT/-EOPNOTSUPP Return success for no-op set_hwp_para() v5: Use cpufreq.h for include Add () around bit test Fix Configure typo Drop duplicated energy_perf comment Define XEN_SYSCTL_CPPC_ACT_WINDOW_MASK from *_MANTISSA_MASK and *_EXPONENT_= MASK Re-order XEN_SYSCTL_CPPC_SET_* flags to match field and hardware order. Remove const from set_cppc param to update set_params Skip Activity Window if not supported by hardware and clear set_params Make parameter parsing consistent Add an exit path when there are no parameters to write. Expand the header file to cover the IN/OUT set_params. Remove the "desired" lowest/highest checking as hardware clips internally v4: Remove IA32_ENERGY_BIAS support Validate parameters don't exceed 255 Use CPPC/cppc name set_cppc_para() add const set_cppc_para() return hwp_cpufreq_target() Expand sysctl comments v3: Remove cpufreq_governor_internal from set_cpufreq_hwp v2: Update for naming anonymous union Drop hwp_err for invalid input in set_hwp_para() Drop uint16_t cast in XEN_SYSCTL_HWP_SET_PARAM_MASK Drop parens for HWP_SET_PRESET defines Reference activity_window format comment Place SET_CPUFREQ_HWP after SET_CPUFREQ_PARA Add {HWP,IA32}_ENERGY_PERF_MAX_{PERFORMANCE,POWERSAVE} defines Order defines before fields in sysctl.h Use XEN_HWP_GOVERNOR Use per_cpu for hwp_drv_data --- xen/arch/x86/acpi/cpufreq/hwp.c | 102 +++++++++++++++++++++++++++++ xen/drivers/acpi/pmstat.c | 17 +++++ xen/include/acpi/cpufreq/cpufreq.h | 2 + xen/include/public/sysctl.h | 64 ++++++++++++++++++ 4 files changed, 185 insertions(+) diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hw= p.c index 2cbfa1ce33..f6d445a8eb 100644 --- a/xen/arch/x86/acpi/cpufreq/hwp.c +++ b/xen/arch/x86/acpi/cpufreq/hwp.c @@ -21,6 +21,10 @@ static bool __ro_after_init feature_hdc; =20 static bool __ro_after_init opt_cpufreq_hdc =3D true; =20 +#define HWP_ENERGY_PERF_MAX_PERFORMANCE 0 +#define HWP_ENERGY_PERF_BALANCE 0x80 +#define HWP_ENERGY_PERF_MAX_POWERSAVE 0xff + union hwp_request { struct @@ -542,6 +546,104 @@ int get_hwp_para(unsigned int cpu, return 0; } =20 +int set_hwp_para(struct cpufreq_policy *policy, + struct xen_set_cppc_para *set_cppc) +{ + unsigned int cpu =3D policy->cpu; + struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + bool cleared_act_window =3D false; + + if ( data =3D=3D NULL ) + return -ENOENT; + + /* Validate all parameters - Disallow reserved bits. */ + if ( set_cppc->minimum > 255 || + set_cppc->maximum > 255 || + set_cppc->desired > 255 || + set_cppc->energy_perf > 255 || + (set_cppc->set_params & ~XEN_SYSCTL_CPPC_SET_PARAM_MASK) || + (set_cppc->activity_window & ~XEN_SYSCTL_CPPC_ACT_WINDOW_MASK) ) + return -EINVAL; + + /* Only allow values if params bit is set. */ + if ( (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED) && + set_cppc->desired) || + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MINIMUM) && + set_cppc->minimum) || + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM) && + set_cppc->maximum) || + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ENERGY_PERF) && + set_cppc->energy_perf) || + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ACT_WINDOW) && + set_cppc->activity_window) ) + return -EINVAL; + + /* Clear out activity window if lacking HW supported. */ + if ( (set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ACT_WINDOW) && + !feature_hwp_activity_window ) + { + set_cppc->set_params &=3D ~XEN_SYSCTL_CPPC_SET_ACT_WINDOW; + cleared_act_window =3D true; + } + + /* Return if there is nothing to do. */ + if ( set_cppc->set_params =3D=3D 0 ) + return 0; + + /* Apply presets */ + switch ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_PRESET_MASK ) + { + case XEN_SYSCTL_CPPC_SET_PRESET_POWERSAVE: + data->minimum =3D data->hw.lowest; + data->maximum =3D data->hw.lowest; + data->activity_window =3D 0; + data->energy_perf =3D HWP_ENERGY_PERF_MAX_POWERSAVE; + data->desired =3D 0; + break; + + case XEN_SYSCTL_CPPC_SET_PRESET_PERFORMANCE: + data->minimum =3D data->hw.highest; + data->maximum =3D data->hw.highest; + data->activity_window =3D 0; + data->energy_perf =3D HWP_ENERGY_PERF_MAX_PERFORMANCE; + data->desired =3D 0; + break; + + case XEN_SYSCTL_CPPC_SET_PRESET_BALANCE: + data->minimum =3D data->hw.lowest; + data->maximum =3D data->hw.highest; + data->activity_window =3D 0; + data->energy_perf =3D HWP_ENERGY_PERF_BALANCE; + data->desired =3D 0; + break; + + case XEN_SYSCTL_CPPC_SET_PRESET_NONE: + break; + + default: + return -EINVAL; + } + + /* Further customize presets if needed */ + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MINIMUM ) + data->minimum =3D set_cppc->minimum; + + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM ) + data->maximum =3D set_cppc->maximum; + + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ENERGY_PERF ) + data->energy_perf =3D set_cppc->energy_perf; + + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED ) + data->desired =3D set_cppc->desired; + + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ACT_WINDOW ) + data->activity_window =3D set_cppc->activity_window & + XEN_SYSCTL_CPPC_ACT_WINDOW_MASK; + + return hwp_cpufreq_target(policy, 0, 0); +} + int __init hwp_register_driver(void) { int ret; diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index e4e2df94a7..85097d463c 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -400,6 +400,19 @@ static int set_cpufreq_para(struct xen_sysctl_pm_op *o= p) return ret; } =20 +static int set_cpufreq_cppc(struct xen_sysctl_pm_op *op) +{ + struct cpufreq_policy *policy =3D per_cpu(cpufreq_cpu_policy, op->cpui= d); + + if ( !policy || !policy->governor ) + return -ENOENT; + + if ( !hwp_active() ) + return -EOPNOTSUPP; + + return set_hwp_para(policy, &op->u.set_cppc); +} + int do_pm_op(struct xen_sysctl_pm_op *op) { int ret =3D 0; @@ -472,6 +485,10 @@ int do_pm_op(struct xen_sysctl_pm_op *op) break; } =20 + case SET_CPUFREQ_CPPC: + ret =3D set_cpufreq_cppc(op); + break; + case GET_CPUFREQ_AVGFREQ: { op->u.get_avgfreq =3D cpufreq_driver_getavg(op->cpuid, USR_GETAVG); diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/= cpufreq.h index f90e9d3a6c..281e3f513d 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -257,5 +257,7 @@ int hwp_register_driver(void); bool hwp_active(void); int get_hwp_para(unsigned int cpu, struct xen_cppc_para *cppc_para); +int set_hwp_para(struct cpufreq_policy *policy, + struct xen_set_cppc_para *set_cppc); =20 #endif /* __XEN_CPUFREQ_PM_H__ */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index cf27f8f2f9..3975050248 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -351,6 +351,68 @@ struct xen_cppc_para { uint32_t activity_window; }; =20 +/* + * Set CPPC values. + * + * Configure the parameters for CPPC. Set bits in set_params control which + * values are applied. If a bit is not set in set_params, the field must = be + * zero. + * + * For HWP specifically, values must be limited to 0-255 or within + * XEN_SYSCTL_CPPC_ACT_WINDOW_MASK for activity window. Set bits outside = the + * range will be returned as -EINVAL. + * + * Activity Window may not be supported by the hardware. In that case, the + * returned set_params will clear XEN_SYSCTL_CPPC_SET_ACT_WINDOW to indica= te + * that it was not applied - though the rest of the values will be applied. + * + * There are a set of presets along with individual fields. Presets are + * applied first, and then individual fields. This allows customizing + * a preset without having to specify every value. + * + * The preset options values are as follows: + * + * preset | minimum | maxium | energy_perf + * ------------+---------+---------+---------------- + * powersave | lowest | lowest | powersave (255) + * ------------+---------+---------+---------------- + * balance | lowest | highest | balance (128) + * ------------+---------+---------+---------------- + * performance | highest | highest | performance (0) + * + * desired and activity_window are set to 0, hardware selected. + */ +struct xen_set_cppc_para { +#define XEN_SYSCTL_CPPC_SET_MINIMUM (1U << 0) +#define XEN_SYSCTL_CPPC_SET_MAXIMUM (1U << 1) +#define XEN_SYSCTL_CPPC_SET_DESIRED (1U << 2) +#define XEN_SYSCTL_CPPC_SET_ENERGY_PERF (1U << 3) +#define XEN_SYSCTL_CPPC_SET_ACT_WINDOW (1U << 4) +#define XEN_SYSCTL_CPPC_SET_PRESET_MASK 0xf0000000U +#define XEN_SYSCTL_CPPC_SET_PRESET_NONE 0x00000000U +#define XEN_SYSCTL_CPPC_SET_PRESET_BALANCE 0x10000000U +#define XEN_SYSCTL_CPPC_SET_PRESET_POWERSAVE 0x20000000U +#define XEN_SYSCTL_CPPC_SET_PRESET_PERFORMANCE 0x30000000U +#define XEN_SYSCTL_CPPC_SET_PARAM_MASK \ + (XEN_SYSCTL_CPPC_SET_PRESET_MASK | \ + XEN_SYSCTL_CPPC_SET_MINIMUM | \ + XEN_SYSCTL_CPPC_SET_MAXIMUM | \ + XEN_SYSCTL_CPPC_SET_DESIRED | \ + XEN_SYSCTL_CPPC_SET_ENERGY_PERF | \ + XEN_SYSCTL_CPPC_SET_ACT_WINDOW ) + /* IN/OUT */ + uint32_t set_params; /* bitflags for valid values */ + /* See comments in struct xen_cppc_para. */ + /* IN */ + uint32_t minimum; + uint32_t maximum; + uint32_t desired; + uint32_t energy_perf; +#define XEN_SYSCTL_CPPC_ACT_WINDOW_MASK (XEN_CPPC_ACT_WINDOW_MANTISSA_MASK= | \ + XEN_CPPC_ACT_WINDOW_EXPONENT_MASK) + uint32_t activity_window; +}; + #define XEN_HWP_DRIVER_NAME "hwp" =20 /* @@ -418,6 +480,7 @@ struct xen_sysctl_pm_op { #define SET_CPUFREQ_GOV (CPUFREQ_PARA | 0x02) #define SET_CPUFREQ_PARA (CPUFREQ_PARA | 0x03) #define GET_CPUFREQ_AVGFREQ (CPUFREQ_PARA | 0x04) + #define SET_CPUFREQ_CPPC (CPUFREQ_PARA | 0x05) =20 /* set/reset scheduler power saving option */ #define XEN_SYSCTL_pm_op_set_sched_opt_smt 0x21 @@ -444,6 +507,7 @@ struct xen_sysctl_pm_op { struct xen_get_cpufreq_para get_para; struct xen_set_cpufreq_gov set_gov; struct xen_set_cpufreq_para set_para; + struct xen_set_cppc_para set_cppc; uint64_aligned_t get_avgfreq; uint32_t set_sched_opt_smt; #define XEN_SYSCTL_CX_UNLIMITED 0xffffffffU --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391871; cv=none; d=zohomail.com; s=zohoarc; b=VYBAuNIMzK/pXFcIeovsW8McWoA/2MxQ2x3wGC8J5S94kviNww5ddULDa/D37mNqw7zlsqS5MB+x79kHGBcvki9oAkNTaXRMKcP1As/EnkEoun4BCzfgUFmWrQnQQ0TT8ICcVTPJeCjbBRKPlZ60dNWR+lnDeDvtqeX4xakOROg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391871; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wIB5Z/ggG5eJ8M2F2JBMwNaYc9A5YlbhT5y/HdVUB7g=; b=Rkjwbbgvk4Ce7oz98HZrWlQyzqWyWkS7RIRQmkjip9R+B/rd//DaeCmJrFNomWrRhDOxAUFeZMdW5KhMjQAewYR7TAZKS7qIYRhInMkTT4ArfK4+GEGxX0d88sqBxq7q8cu5YA1xkgGSCSuvp1ReTqZuHjEQSX+pBwcboQdG5TE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391871527183.71665255780988; Wed, 26 Jul 2023 10:17:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570661.892713 (Exim 4.92) (envelope-from ) id 1qOi8Z-0003uN-GJ; Wed, 26 Jul 2023 17:17:23 +0000 Received: by outflank-mailman (output) from mailman id 570661.892713; Wed, 26 Jul 2023 17:17:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi8Z-0003tC-By; Wed, 26 Jul 2023 17:17:23 +0000 Received: by outflank-mailman (input) for mailman id 570661; Wed, 26 Jul 2023 17:17:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2j-0005nP-QP for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:21 +0000 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [2607:f8b0:4864:20::e34]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6fe5d449-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:11:19 +0200 (CEST) Received: by mail-vs1-xe34.google.com with SMTP id ada2fe7eead31-44757af136cso14433137.3 for ; Wed, 26 Jul 2023 10:11:20 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:11:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6fe5d449-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391478; x=1690996278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wIB5Z/ggG5eJ8M2F2JBMwNaYc9A5YlbhT5y/HdVUB7g=; b=i6jixsyaZ39eQkyDMG2g2c4UpEA1PEFFmE0zEADrlJ36oqzICRuU7Fv+UHs2lF03JB Q11hQjU2R46sWY4p2ZXIR2/GGnk/gWTpGKNp7gd0avUxUHA12sXjR3vE6Pw24ANzPiVx CptPVMLnfyF6QeHibjl8CcxI6HANdIZBAqXmLAxJRZjYBWCMBcwKO4qapxOOwPW3wD7K C4ijSLPdidWSj4qm/6UA1Gxnbq0+mULORy+T4RLqcGMdUaQXZvvMizEjTvGvFn0ly65X uflwgHV851IddZe2qkf6O4dDWUTJVm3UaeiNosjfVQARZtSQXk3DmvRD/yLeIwDYnVwC O6nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391478; x=1690996278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wIB5Z/ggG5eJ8M2F2JBMwNaYc9A5YlbhT5y/HdVUB7g=; b=T8zT6P/dyr4BH5hA1WGSdNNLhL0wXXqD7oUl4WTTsZMKnQUyfItQXA1AhpMWkDqZgG mX5D4gqcHjo17wSF1iBmQEBeN5BQcAZbsMGNEI/MPLmW/f4Nlg61H3+06PryJ9vYd1p2 MJDFF+dCmUkbfAYq1ss2JBueIcYiFuKwzpHMkWuaHwgLv+5NkkbhO7POuJwmZZLDP8Ye 8U/Km9fFfz4a9gqrSTAatKnw1djZtlFqXLgkmX1ZWPbTMT/N2nlmuWTN4tFCXfxRDLd6 CTvwCQbM7v/OMYWteFcLEx9ifJVRGULNk2YEkfvXSyElsAdJp6/qFysHEXb92Q73/Io/ VHmg== X-Gm-Message-State: ABy/qLaf1enoKvVi/Kkv8lIEbfj/tOvoz6Qv63lej9OjCY+8KUQOFdoR gB8XbfuuuYR4LgP2Dugdr9wrWBCYxhE= X-Google-Smtp-Source: APBJJlGbfOVaJ6JhFnY4cR2crCc3Eb+DisFFZbx74DJbPeLPPfwaRq2ZeagfuZLH46r4KPc7asidLg== X-Received: by 2002:a67:ef92:0:b0:443:66b9:b8f0 with SMTP id r18-20020a67ef92000000b0044366b9b8f0mr2027430vsp.10.1690391478530; Wed, 26 Jul 2023 10:11:18 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v7 13/15] libxc: Add xc_set_cpufreq_cppc Date: Wed, 26 Jul 2023 13:09:43 -0400 Message-ID: <20230726170945.34961-14-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391872639100001 Content-Type: text/plain; charset="utf-8" Add xc_set_cpufreq_cppc to allow calling xen_systctl_pm_op SET_CPUFREQ_CPPC. Signed-off-by: Jason Andryuk Acked-by: Anthony PERARD --- v2: Mark xc_set_hwp_para_t const v4: s/hwp/cppc/ Add Anthony's Ack v5: Remove const and copy back result --- tools/include/xenctrl.h | 4 ++++ tools/libs/ctrl/xc_pm.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 2092632296..52f42fb5b6 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1930,11 +1930,15 @@ struct xc_get_cpufreq_para { int32_t turbo_enabled; }; =20 +typedef struct xen_set_cppc_para xc_set_cppc_para_t; + int xc_get_cpufreq_para(xc_interface *xch, int cpuid, struct xc_get_cpufreq_para *user_para); int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname); int xc_set_cpufreq_para(xc_interface *xch, int cpuid, int ctrl_type, int ctrl_value); +int xc_set_cpufreq_cppc(xc_interface *xch, int cpuid, + xc_set_cppc_para_t *set_cppc); int xc_get_cpufreq_avgfreq(xc_interface *xch, int cpuid, int *avg_freq); =20 int xc_set_sched_opt_smt(xc_interface *xch, uint32_t value); diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index cea3eab22e..1f267147f6 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -329,6 +329,29 @@ int xc_set_cpufreq_para(xc_interface *xch, int cpuid, return xc_sysctl(xch, &sysctl); } =20 +int xc_set_cpufreq_cppc(xc_interface *xch, int cpuid, + xc_set_cppc_para_t *set_cppc) +{ + DECLARE_SYSCTL; + int ret; + + if ( !xch ) + { + errno =3D EINVAL; + return -1; + } + sysctl.cmd =3D XEN_SYSCTL_pm_op; + sysctl.u.pm_op.cmd =3D SET_CPUFREQ_CPPC; + sysctl.u.pm_op.cpuid =3D cpuid; + sysctl.u.pm_op.u.set_cppc =3D *set_cppc; + + ret =3D xc_sysctl(xch, &sysctl); + + *set_cppc =3D sysctl.u.pm_op.u.set_cppc; + + return ret; +} + int xc_get_cpufreq_avgfreq(xc_interface *xch, int cpuid, int *avg_freq) { int ret =3D 0; --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391915; cv=none; d=zohomail.com; s=zohoarc; b=J/D4FEqgK1v3PVn8LARxgugeLuGLHV5jF5C/TMxO/EF0j7a1oQQGiO3KmrULE3KsHfVIQV01L7L5xcOTp4sWoI6lbTH/SKoRnA0gOKXWa5oBXpRxZpsBH/+3fDZVa6FOn6TRKLgqjMUWWDUwsTzQ20HTFSTCopzsCwSsIhDNUaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391915; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gblVHwIRoZ9Cb4sFC+wqThP0YWJWsFM4Sph0J9w8nz0=; b=E7BKV7Wu5JbaA+0lHRWBVcOdk7nOc9yFgG2gGCD9pNqwONOJ0WIzjR7NSqj32BxDPmlQ/uNKD8dZ9RaAau/eaTLZDfOeG7mQyFIpTtOaFHdnxNmh23yfljOxhj2cquBuVeiFhYoD9Sqox58pFfksnj5TaqXlY74BKTBoBRL0N+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391915526553.0024339246244; Wed, 26 Jul 2023 10:18:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570663.892723 (Exim 4.92) (envelope-from ) id 1qOi8a-0004BH-3s; Wed, 26 Jul 2023 17:17:24 +0000 Received: by outflank-mailman (output) from mailman id 570663.892723; Wed, 26 Jul 2023 17:17:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi8Z-00047y-SP; Wed, 26 Jul 2023 17:17:23 +0000 Received: by outflank-mailman (input) for mailman id 570663; Wed, 26 Jul 2023 17:17:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2p-0005nP-6l for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:27 +0000 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [2607:f8b0:4864:20::f34]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72e669bf-2bd7-11ee-8613-37d641c3527e; Wed, 26 Jul 2023 19:11:24 +0200 (CEST) Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-63d1238c300so549856d6.0 for ; Wed, 26 Jul 2023 10:11:25 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:11:22 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 72e669bf-2bd7-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391483; x=1690996283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gblVHwIRoZ9Cb4sFC+wqThP0YWJWsFM4Sph0J9w8nz0=; b=D/SWrGlHIE6OS7AXo5KLJiE8Br+n1jnkH8WKomZZqlzMcviXZe6PTZcGcfUgKTxe8a 3oQErkwbUYqbAqDx+IRKwL9ga+YX3e8MxaMs0B4YsVQoC1T2oxa8J3HRtmkfiUB+4xZP 5VIymmdRpDDx0gvaY9XOJ4T9GmQQUgx8zAkcyRtvdLxgSUOY2vEtm10Ykbn/LP1ZWimu TUdZqItCoczrq8MuUswS+/7u/l1a+vyAt10dwfAr2T3NCubAUcEbh14PPHKjSmE6I7C9 dFaHM8B54aYbIOp2KnQeYBHxgvTPWIq9YKtQdJQAgsAxbCfFWKvts9rmz4jpfZt8ZBM8 vY/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391483; x=1690996283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gblVHwIRoZ9Cb4sFC+wqThP0YWJWsFM4Sph0J9w8nz0=; b=XnrtUUONlgl2sCOO+nRy9q+I15JJF5TFEd7hHBg4eY+/30jtS5NlcIngInUi+Of/2X MmHdBA+k3GqW1de8INNZaKobzWMf4VOK1VfWK/k37M/HvTI1jdUeCXQ03XKJUAe+QdpX PL8okvevPhcTDfm4OrpvBqKot+LJuTYeSIpBmEuz0xvwgvPfOPvgTLSOAnbZu4ZtHdzD Bt/dE/YzuLgdhAuCDlTrcxsHGUULiLertuodZmHhISb+YeNGJ64Bthz9OCAZ4bC1Tmp+ fu1aNWonT1tPrd419Gw9wDFp+GqkqNJr/JZzqe5tHYw80WQjdv/3xvEUBYEcW6jarD1/ Ok+g== X-Gm-Message-State: ABy/qLYY3Jrsk42sOJCbo/hiMmfbLAbYAJG7L2nFRk/2VU7mZLDpwN1O pw7GJ1d/hHogrzjNw+EMF3JQparLTn0= X-Google-Smtp-Source: APBJJlG2mAz/7i4T/ZOBnN5tJ9K+wAlzEb7gRCKFXz3COj83bkobJ2TfnYtmAcMUvOa/JCwPEV69zA== X-Received: by 2002:a05:6214:80b:b0:631:6eea:c4f0 with SMTP id df11-20020a056214080b00b006316eeac4f0mr2169372qvb.48.1690391483494; Wed, 26 Jul 2023 10:11:23 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , Jan Beulich Subject: [PATCH v7 14/15] xenpm: Add set-cpufreq-cppc subcommand Date: Wed, 26 Jul 2023 13:09:44 -0400 Message-ID: <20230726170945.34961-15-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391918570100001 Content-Type: text/plain; charset="utf-8" set-cpufreq-cppc allows setting the Hardware P-State (HWP) parameters. It can be run on all or just a single cpu. There are presets of balance, powersave & performance. Those can be further tweaked by param:val arguments as explained in the usage description. Parameter names are just checked to the first 3 characters to shorten typing. Some options are hardware dependent, and ranges can be found in get-cpufreq-para. Signed-off-by: Jason Andryuk Acked-by: Jan Beulich Acked-by: Anthony PERARD --- v5: Make i unsigned int Use local max_cpuid instead of max_cpu_nr Add Jan's Ack Check set_params and print a message if activity window wasn't set v4: Remove energy bias 0-15 & 7 references Use MASK_INSR Fixup { placement Drop extra case in parse_activity_window strcmp suffix Expand help text s/hwp/cppc/ Use isdigit() to check cpuid - otherwise run on all CPUs. v2: Compare provided parameter name and not just 3 characters. Use "-" in parameter names Remove hw_ Replace sscanf with strchr & strtoul. Remove toplevel error message with lower level ones. Help text s/127/128/ Help text mention truncation. Avoid some truncation rounding down by adding 5 before division. Help test mention default microseconds Also comment the limit check written to avoid overflow. --- tools/misc/xenpm.c | 244 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 3abd99fd20..0877f43946 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -16,6 +16,8 @@ */ #define MAX_NR_CPU 512 =20 +#include +#include #include #include #include @@ -67,6 +69,30 @@ void show_help(void) " set-max-cstate |'unlimited' [|'unlimited']= \n" " set the C-State limitati= on ( >=3D 0) and\n" " optionally the C-sub-sta= te limitation ( >=3D 0)\n" + " set-cpufreq-cppc [cpuid] [balance|performance|powersave= ] *\n" + " set Hardware P-State (HW= P) parameters\n" + " on CPU or all if= omitted.\n" + " optionally a preset of o= ne of:\n" + " balance|performance|po= wersave\n" + " an optional list of para= m:val arguments\n" + " minimum:N (0-255)\n" + " maximum:N (0-255)\n" + " get-cpufreq-para l= owest/highest\n" + " values are limits = for\n" + " minumum/maximum.\n" + " desired:N (0-255)\n" + " set explicit perfo= rmance target.\n" + " non-zero disables = auto-HWP mode.\n" + " energy-perf:N (0-255)\= n" + " energy/per= formance hint\n" + " lower - fa= vor performance\n" + " higher - f= avor powersave\n" + " 128 - bala= nce\n" + " act-window:N{,m,u}s ra= nge 1us-1270s\n" + " window for interna= l calculations.\n" + " units default to \= "us\" if unspecified.\n" + " truncates un-repre= sentable values.\n" + " 0 lets the hardwar= e decide.\n" " start [seconds] start collect Cx/Px stat= istics,\n" " output after CTRL-C or S= IGINT or several seconds.\n" " enable-turbo-mode [cpuid] enable Turbo Mode for pr= ocessors that support it.\n" @@ -1292,6 +1318,223 @@ void disable_turbo_mode(int argc, char *argv[]) errno, strerror(errno)); } =20 +/* + * Parse activity_window:NNN{us,ms,s} and validate range. + * + * Activity window is a 7bit mantissa (0-127) with a 3bit exponent (0-7) b= ase + * 10 in microseconds. So the range is 1 microsecond to 1270 seconds. A = value + * of 0 lets the hardware autonomously select the window. + * + * Return 0 on success + * -1 on error + */ +static int parse_activity_window(xc_set_cppc_para_t *set_cppc, unsigned lo= ng u, + const char *suffix) +{ + unsigned int exponent =3D 0; + unsigned int multiplier =3D 1; + + if ( suffix && suffix[0] ) + { + if ( strcmp(suffix, "s") =3D=3D 0 ) + { + multiplier =3D 1000 * 1000; + exponent =3D 6; + } + else if ( strcmp(suffix, "ms") =3D=3D 0 ) + { + multiplier =3D 1000; + exponent =3D 3; + } + else if ( strcmp(suffix, "us") !=3D 0 ) + { + fprintf(stderr, "invalid activity window units: \"%s\"\n", suf= fix); + + return -1; + } + } + + /* u * multipler > 1270 * 1000 * 1000 transformed to avoid overflow. */ + if ( u > 1270 * 1000 * 1000 / multiplier ) + { + fprintf(stderr, "activity window is too large\n"); + + return -1; + } + + /* looking for 7 bits of mantissa and 3 bits of exponent */ + while ( u > 127 ) + { + u +=3D 5; /* Round up to mitigate truncation rounding down + e.g. 128 -> 120 vs 128 -> 130. */ + u /=3D 10; + exponent +=3D 1; + } + + set_cppc->activity_window =3D + MASK_INSR(exponent, XEN_CPPC_ACT_WINDOW_EXPONENT_MASK) | + MASK_INSR(u, XEN_CPPC_ACT_WINDOW_MANTISSA_MASK); + set_cppc->set_params |=3D XEN_SYSCTL_CPPC_SET_ACT_WINDOW; + + return 0; +} + +static int parse_cppc_opts(xc_set_cppc_para_t *set_cppc, int *cpuid, + int argc, char *argv[]) +{ + int i =3D 0; + + if ( argc < 1 ) + { + fprintf(stderr, "Missing arguments\n"); + return -1; + } + + if ( isdigit(argv[i][0]) ) + { + if ( sscanf(argv[i], "%d", cpuid) !=3D 1 || *cpuid < 0 ) + { + fprintf(stderr, "Could not parse cpuid \"%s\"\n", argv[i]); + return -1; + } + + i++; + } + + if ( i =3D=3D argc ) + { + fprintf(stderr, "Missing arguments\n"); + return -1; + } + + if ( strcasecmp(argv[i], "powersave") =3D=3D 0 ) + { + set_cppc->set_params =3D XEN_SYSCTL_CPPC_SET_PRESET_POWERSAVE; + i++; + } + else if ( strcasecmp(argv[i], "performance") =3D=3D 0 ) + { + set_cppc->set_params =3D XEN_SYSCTL_CPPC_SET_PRESET_PERFORMANCE; + i++; + } + else if ( strcasecmp(argv[i], "balance") =3D=3D 0 ) + { + set_cppc->set_params =3D XEN_SYSCTL_CPPC_SET_PRESET_BALANCE; + i++; + } + + for ( ; i < argc; i++) + { + unsigned long val; + char *param =3D argv[i]; + char *value; + char *suffix; + int ret; + + value =3D strchr(param, ':'); + if ( value =3D=3D NULL ) + { + fprintf(stderr, "\"%s\" is an invalid cppc parameter\n", argv[= i]); + return -1; + } + + value[0] =3D '\0'; + value++; + + errno =3D 0; + val =3D strtoul(value, &suffix, 10); + if ( (errno && val =3D=3D ULONG_MAX) || value =3D=3D suffix ) + { + fprintf(stderr, "Could not parse number \"%s\"\n", value); + return -1; + } + + if ( strncasecmp(param, "act-window", strlen(param)) =3D=3D 0 ) + { + ret =3D parse_activity_window(set_cppc, val, suffix); + if (ret) + return -1; + + continue; + } + + if ( val > 255 ) + { + fprintf(stderr, "\"%s\" value \"%lu\" is out of range\n", para= m, + val); + return -1; + } + + if ( suffix && suffix[0] ) + { + fprintf(stderr, "Suffix \"%s\" is invalid\n", suffix); + return -1; + } + + if ( strncasecmp(param, "minimum", MAX(2, strlen(param))) =3D=3D 0= ) + { + set_cppc->minimum =3D val; + set_cppc->set_params |=3D XEN_SYSCTL_CPPC_SET_MINIMUM; + } + else if ( strncasecmp(param, "maximum", MAX(2, strlen(param))) =3D= =3D 0 ) + { + set_cppc->maximum =3D val; + set_cppc->set_params |=3D XEN_SYSCTL_CPPC_SET_MAXIMUM; + } + else if ( strncasecmp(param, "desired", strlen(param)) =3D=3D 0 ) + { + set_cppc->desired =3D val; + set_cppc->set_params |=3D XEN_SYSCTL_CPPC_SET_DESIRED; + } + else if ( strncasecmp(param, "energy-perf", strlen(param)) =3D=3D = 0 ) + { + set_cppc->energy_perf =3D val; + set_cppc->set_params |=3D XEN_SYSCTL_CPPC_SET_ENERGY_PERF; + } + else + { + fprintf(stderr, "\"%s\" is an invalid parameter\n", param); + return -1; + } + } + + if ( set_cppc->set_params =3D=3D 0 ) + { + fprintf(stderr, "No parameters set in request\n"); + return -1; + } + + return 0; +} + +static void cppc_set_func(int argc, char *argv[]) +{ + xc_set_cppc_para_t set_cppc =3D {}; + unsigned int max_cpuid =3D max_cpu_nr; + int cpuid =3D -1; + unsigned int i =3D 0; + uint32_t set_params; + + if ( parse_cppc_opts(&set_cppc, &cpuid, argc, argv) ) + exit(EINVAL); + + if ( cpuid !=3D -1 ) + { + i =3D cpuid; + max_cpuid =3D i + 1; + } + + set_params =3D set_cppc.set_params; + for ( ; i < max_cpuid; i++ ) { + if ( xc_set_cpufreq_cppc(xc_handle, i, &set_cppc) ) + fprintf(stderr, "[CPU%d] failed to set cppc params (%d - %s)\n= ", + i, errno, strerror(errno)); + } + + if ( (set_params ^ set_cppc.set_params) & XEN_SYSCTL_CPPC_SET_ACT_WIND= OW ) + printf("Activity window not supported and omitted\n"); +} + struct { const char *name; void (*function)(int argc, char *argv[]); @@ -1302,6 +1545,7 @@ struct { { "get-cpufreq-average", cpufreq_func }, { "start", start_gather_func }, { "get-cpufreq-para", cpufreq_para_func }, + { "set-cpufreq-cppc", cppc_set_func }, { "set-scaling-maxfreq", scaling_max_freq_func }, { "set-scaling-minfreq", scaling_min_freq_func }, { "set-scaling-governor", scaling_governor_func }, --=20 2.41.0 From nobody Wed Nov 27 18:45:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1690391881; cv=none; d=zohomail.com; s=zohoarc; b=lJQUWOWdlYmbzJ5vef4jdeS2ud7YJXRvUmAOMDE72vdOdULDDPqXVfwcAoqE0qxlU1c68XNfAYcmxNLhgGwBUtLWdae7SDSwoFMDoRZI+WovGqPt4qyKqI1C0EcgocxF50GeG8LHN9Rc+a4ItyajMoVKznzqsxSuZBmtnA6k1BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690391881; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7fKIbOA4RKJwyWZPk8ACAEU8hAgIi7aDz2OnDwWBK4c=; b=P60VvVpLDCX2QLhoN72M1Z8aSq6yPwwU6VfJXezogl6HqP5e/+KQT1k0wlI3Ty+iKJ9ThDOTiY61Gy048DfVgmA9eJHOaX5GOes2R+LmuZRlUfh6Uh+T7n73BdJ2/OFs3ipocDSQCAoMggzMdcmaAygmOC38vilMuCtdDdGLwfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690391881728908.0522628590761; Wed, 26 Jul 2023 10:18:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570665.892731 (Exim 4.92) (envelope-from ) id 1qOi8a-0004KJ-IK; Wed, 26 Jul 2023 17:17:24 +0000 Received: by outflank-mailman (output) from mailman id 570665.892731; Wed, 26 Jul 2023 17:17:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi8a-0004Hb-AF; Wed, 26 Jul 2023 17:17:24 +0000 Received: by outflank-mailman (input) for mailman id 570665; Wed, 26 Jul 2023 17:17:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOi2v-00062Z-3b for xen-devel@lists.xenproject.org; Wed, 26 Jul 2023 17:11:33 +0000 Received: from mail-vk1-xa29.google.com (mail-vk1-xa29.google.com [2607:f8b0:4864:20::a29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 77ad7ed3-2bd7-11ee-b242-6b7b168915f2; Wed, 26 Jul 2023 19:11:32 +0200 (CEST) Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-4864cc561aeso20610e0c.0 for ; Wed, 26 Jul 2023 10:11:32 -0700 (PDT) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id s17-20020a0ca611000000b0063d1aa446e2sm1248019qva.59.2023.07.26.10.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 10:11:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 77ad7ed3-2bd7-11ee-b242-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690391491; x=1690996291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7fKIbOA4RKJwyWZPk8ACAEU8hAgIi7aDz2OnDwWBK4c=; b=cEqPDTYN4jp1bM38ONyapZb5sjjHHtuoRMvn7/AOYco0cl9A39Uw+AeJ7Vx0yGadKh g+GryXW4l38nradggkyUGKrTGZSAG7a3yOXd9d2ULPO1TR39s115caF4uK5ZRZhuAcXI gbgcQh2kyRlTkSaolEQ5nKAk4nAykM2Ux5RQWAdkYUlw2+IDVv87ugyxd2PfoYuxQ95O yiYqzJzMOB/ATv6MHqkU0fiEVQzc7y9HNGXMj1oL1V7U281QwgPsGpeH6e4dXPj/yJbX GN7DPHi/8k4p2l3+MwtfPLtoB2u7hURT57nUzVmTvYW2HxEdxPkFskS0dW6A1gWzJM/U NKuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690391491; x=1690996291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7fKIbOA4RKJwyWZPk8ACAEU8hAgIi7aDz2OnDwWBK4c=; b=F5D5TdJIGrkJqXw92S0Z5HWRIv+4KFZjNYNL2Lcnav7AWo0dXdwvyeBsbzq09y0QUr uuYh7fEslSZCjbMA+bY15FW3sOLLPyHICbLU36tyukB53i4rqDaVw6s+KQaP6O5yYIbH ZKbIakxLrv6+f/jSnZB+v1Id0cFWvJwUiiSj0CCEJLdcOQXVMpPpPs5FcUdoY1/+vSKb owdSRa6CYPDhZHml58uFZc471GDoEN9UM3PVMs8YxhBKvASWEzNOtBO5RFA0GCRKHK7w S4WR79Jpe71XgRhMXQO0Lj3JrEFRZ3GaOr1FwjZj4FLARWtA4zgB7woX88Azdkv0Jh9+ KCeg== X-Gm-Message-State: ABy/qLax+V1rpxbqkgWNXryiWZMaViLqCYOCg4bVgtrA64y01sxMZd0t KSAdmrDGUZgkOTuPrvZ90j6qLPT0h9k= X-Google-Smtp-Source: APBJJlEWDBNLI3jM2iCnuUvrRJIpeItyiY4vKwD9Ygri4G5qaqR/i40OGmB/BoJ79bDVPyjBY8Tohw== X-Received: by 2002:a1f:dd44:0:b0:486:4c0e:9ae5 with SMTP id u65-20020a1fdd44000000b004864c0e9ae5mr1882323vkg.13.1690391490884; Wed, 26 Jul 2023 10:11:30 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Henry Wang , Community Manager Subject: [PATCH v7 15/15] CHANGELOG: Add Intel HWP entry Date: Wed, 26 Jul 2023 13:09:45 -0400 Message-ID: <20230726170945.34961-16-jandryuk@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726170945.34961-1-jandryuk@gmail.com> References: <20230726170945.34961-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1690391883842100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jason Andryuk Acked-by: Henry Wang --- v3: Position under existing Added section Add Henry's Ack v2: Add blank line --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d7e0590f8..8d6e6c3088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ The format is based on [Keep a Changelog](https://keepach= angelog.com/en/1.0.0/) - xl/libxl can customize SMBIOS strings for HVM guests. - Add support for AVX512-FP16 on x86. - On Arm, Xen supports guests running SVE/SVE2 instructions. (Tech Previe= w) - + - Add Intel Hardware P-States (HWP) cpufreq driver. =20 ## [4.17.0](https://xenbits.xen.org/gitweb/?p=3Dxen.git;a=3Dshortlog;h=3DR= ELEASE-4.17.0) - 2022-12-12 =20 --=20 2.41.0