[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 12/15] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op


  • To: Jason Andryuk <jandryuk@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 25 Jul 2023 16:45:43 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NShA3SFEHAfYIpgenBS7HX1XTNQCsojJTAq4Q24tiUs=; b=ONtgWt10pfA1F1tYUVINZxBH9WuY+Vq8uazkVzAWQ+vmM4s3z//JqKK6ParIdIFt68TE2DpCg22K+INj9wp1oMMJYgImgYB3x60DJAyhDzMDCr8RLYX6Hl3yvGfh9QvuDhFl1itHACKVfqGCKjI/ZzCxyW3pty3rAqxXZravFdW1utsIoZffAqEtlI2pL8KP8n1tDATkmTMO3tymF9hqdMXdnKCnLdXMneToQNm0t8td6WQyikK+bakIji2Js/VPhvDCBfFsjBZbnA0rqVBWlM+OW/Rw3/DNp5XOoubqnGq4gKocRvVOT+mrYPrnYnjofe5Ohe36VLYJDPUtBn7i7Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9TSnp9Ht3T0wdqnbKE80wbWO0pL8/Vo9kgTWbleW9WdVQgMe8c3Erm1PBEfSQ2rbyRa6eWm10YwY/2i8jJGJRi95whWr7fRLAuNIkojplWS7HkdyToBaqB5hG9KOPgrOCqvKVZCawOcIbTPhyqE9N/vqZ6p2UCprqWyGabhCRrYKf2wYenQBSuT5xTumpjVmErX9VxVSJ1G8a/B6e1zIavbnd39oBb+QRbFr8i/8C7NEh+oGJC8iRdbWL5E7ehJI0kRDfdSQElsqxF5fYjpEIOhACPF6gfaA7b2W/cD9h3KdVn+LpwEYACAisZCjuvrOgF4uV0z7q4Xorc8oaY6Ow==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 25 Jul 2023 14:46:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.07.2023 14:58, Jason Andryuk wrote:
> 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 <jandryuk@xxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
with one last nit taken care of:

> @@ -539,6 +543,103 @@ int get_hwp_para(unsigned int cpu,
>      return 0;
>  }
>  
> +int set_hwp_para(struct cpufreq_policy *policy,
> +                 struct xen_set_cppc_para *set_cppc)
> +{
> +    unsigned int cpu = policy->cpu;
> +    struct hwp_drv_data *data = per_cpu(hwp_drv_data, cpu);
> +    bool cleared_act_window = false;
> +
> +    if ( data == 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 ) {

Yet another misplaced brace.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.