All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Andryuk <jandryuk@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Jason Andryuk <jandryuk@gmail.com>, Wei Liu <wl@xen.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v5 11/15] xenpm: Print HWP/CPPC parameters
Date: Thu,  6 Jul 2023 14:54:36 -0400	[thread overview]
Message-ID: <20230706185440.48333-12-jandryuk@gmail.com> (raw)
In-Reply-To: <20230706185440.48333-1-jandryuk@gmail.com>

Print HWP-specific parameters.  Some are always present, but others
depend on hardware support.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
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();
 }
 
+static unsigned int calculate_activity_window(const xc_cppc_para_t *cppc,
+                                              const char **units)
+{
+    unsigned int mantissa = MASK_EXTR(cppc->activity_window,
+                                      XEN_CPPC_ACT_WINDOW_MANTISSA_MASK);
+    unsigned int exponent = MASK_EXTR(cppc->activity_window,
+                                      XEN_CPPC_ACT_WINDOW_EXPONENT_MASK);
+    unsigned int multiplier = 1;
+    unsigned int i;
+
+    /*
+     * SDM only states a 0 register is hardware selected, and doesn't mention
+     * a 0 mantissa with a non-0 exponent.  Only special case a 0 register.
+     */
+    if ( cppc->activity_window == 0 )
+    {
+        *units = "hardware selected";
+
+        return 0;
+    }
+
+    if ( exponent >= 6 )
+    {
+        *units = "s";
+        exponent -= 6;
+    }
+    else if ( exponent >= 3 )
+    {
+        *units = "ms";
+        exponent -= 3;
+    }
+    else
+        *units = "us";
+
+    for ( i = 0; i < exponent; i++ )
+        multiplier *= 10;
+
+    return mantissa * multiplier;
+}
+
 /* print out parameters about cpu frequency */
 static void print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para *p_cpufreq)
 {
@@ -772,6 +812,32 @@ static void print_cpufreq_para(int cpuid, struct xc_get_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 = &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 = 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");
+    }
 
     printf("turbo mode           : %s\n",
            p_cpufreq->turbo_enabled ? "enabled" : "disabled or n/a");
-- 
2.41.0



  parent reply	other threads:[~2023-07-06 18:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 18:54 [PATCH v5 00/15] Intel Hardware P-States (HWP) support Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 01/15] cpufreq: Allow restricting to internal governors only Jason Andryuk
2023-07-10 11:41   ` Jan Beulich
2023-07-06 18:54 ` [PATCH v5 02/15] cpufreq: Add perf_freq to cpuinfo Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 03/15] cpufreq: Export intel_feature_detect Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 04/15] xen/sysctl: Nest cpufreq scaling options Jason Andryuk
2023-07-10 11:51   ` Jan Beulich
2023-07-06 18:54 ` [PATCH v5 05/15] pmstat&xenpm: Re-arrage for cpufreq union Jason Andryuk
2023-07-10 12:09   ` Jan Beulich
2023-07-06 18:54 ` [PATCH v5 06/15] cpufreq: Add Hardware P-State (HWP) driver Jason Andryuk
2023-07-10 13:13   ` Jan Beulich
2023-07-10 15:22     ` Jason Andryuk
2023-07-11  8:18       ` Jan Beulich
2023-07-11 14:16         ` Jason Andryuk
2023-07-11 14:40           ` Jan Beulich
2023-07-11 17:49             ` Jason Andryuk
2023-07-12  8:43               ` Jan Beulich
2023-07-12 19:38                 ` Jason Andryuk
2023-07-13  6:14                   ` Jan Beulich
2023-07-06 18:54 ` [PATCH v5 07/15] xen/x86: Tweak PDC bits when using HWP Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 08/15] xenpm: Change get-cpufreq-para output for hwp Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 09/15] cpufreq: Export HWP parameters to userspace as CPPC Jason Andryuk
2023-07-13 12:37   ` Jan Beulich
2023-07-13 16:11     ` Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 10/15] libxc: Include cppc_para in definitions Jason Andryuk
2023-07-06 18:54 ` Jason Andryuk [this message]
2023-07-06 18:54 ` [PATCH v5 12/15] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op Jason Andryuk
2023-07-13 13:02   ` Jan Beulich
2023-07-13 16:12     ` Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 13/15] libxc: Add xc_set_cpufreq_cppc Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 14/15] xenpm: Add set-cpufreq-cppc subcommand Jason Andryuk
2023-07-06 18:54 ` [PATCH v5 15/15] CHANGELOG: Add Intel HWP entry Jason Andryuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230706185440.48333-12-jandryuk@gmail.com \
    --to=jandryuk@gmail.com \
    --cc=anthony.perard@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.