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

RE: [PATCH v7 11/13] tools/cpufreq: extract CPPC para from cpufreq para


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Tue, 26 Aug 2025 09:12:42 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IxKFLY33cxkPuswlPGM8nkHT3cPorvHDMOTlzE3i4rA=; b=LEvHHlhtCmDTebo3vjkEgMRq/ASK0ItzYDVbyMU2MiPu1Grr/xu0drX6oOaspaYav5/9m3dazIe9H24o5J7KhdoKo6e3/Wb5HqPkdOcV+9+pILDwRQpexc+OWKzld7kaskqwYvrgyzmzv0TWp+ju4PrXnuqdHaukqudlO/Hli5UdKyzEoMEC/hl2P7ZTK0qVz6f3qsNlBWwU3iLpNl6mI27EYYMIiQyqw97sTW0H2oG0wGzDpAri3FTlDobX0X//DE9D7rLO3/UqyostKn8TI2yXdrauSccNHnH+C+T7Bs94KDEcZxfmViJY/jY1Xfigr+DoMviWL8TnFvfjGCUBfg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tc/ms7H9b2xikJu+V+Qy5pKzqtzFk8U2v68sfR2R6XoiflQc1TFpvPhdokVLC/+Vy4N07IFW2lDvyrfTXmU2CtR32xfzmDQzr0cH2hckYDD+cDW+t2Lwbc5xOh6VQZyUZq7K7z119aLsJ0dnk1PJ1ZhQwMZkHEpLn8Bu2YvXfgA8ei9g8enyfoOh2vkj0WwOvE91tCGXPRPZS1vuLBEIbFRzgmxoeW1if3Hq+ZcEVBTXaHd9DiVzEAqY6q10f0S/mpkwZjBLtdmWU+x6JW3Of7LVceYv+rotkpbE4O7FU/XxwEn3WfVdxn5xlhE/PtxVu6W64Nva42yeJP8i+iC9xA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Orzel, Michal" <Michal.Orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 26 Aug 2025 09:12:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Enabled=True;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SetDate=2025-08-26T09:10:20.0000000Z;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Name=Open Source;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_ContentBits=3;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Method=Privileged
  • Thread-index: AQHcE1LyQ0lYyaNtv02FRdV+NHpcFrRzhX0AgAESjyCAAAlHgIAACnwg
  • Thread-topic: [PATCH v7 11/13] tools/cpufreq: extract CPPC para from cpufreq para

[Public]

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Tuesday, August 26, 2025 4:33 PM
> To: Penny, Zheng <penny.zheng@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Anthony PERARD
> <anthony.perard@xxxxxxxxxx>; Juergen Gross <jgross@xxxxxxxx>; Andrew
> Cooper <andrew.cooper3@xxxxxxxxxx>; Orzel, Michal <Michal.Orzel@xxxxxxx>;
> Julien Grall <julien@xxxxxxx>; Roger Pau Monné <roger.pau@xxxxxxxxxx>; Stefano
> Stabellini <sstabellini@xxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v7 11/13] tools/cpufreq: extract CPPC para from cpufreq 
> para
>
> On 26.08.2025 10:21, Penny, Zheng wrote:
> >> -----Original Message-----
> >> From: Jan Beulich <jbeulich@xxxxxxxx>
> >> Sent: Monday, August 25, 2025 11:37 PM
> >>
> >> On 22.08.2025 12:52, Penny Zheng wrote:
> >>> --- a/tools/libs/ctrl/xc_pm.c
> >>> +++ b/tools/libs/ctrl/xc_pm.c
> >>> @@ -288,7 +288,6 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
> >>>          CHK_FIELD(s.scaling_min_freq);
> >>>          CHK_FIELD(s.u.userspace);
> >>>          CHK_FIELD(s.u.ondemand);
> >>> -        CHK_FIELD(cppc_para);
> >>>
> >>>  #undef CHK_FIELD
> >>
> >> What is done here is already less than what could be done; I think ...
> >>
> >
> > Emm, maybe because we define two different cpufreq para structures for user
> space and sysctl, struct xc_get_cpufreq_para and struct xen_get_cppc_para.
> > But for cppc para, it is an alias:
> > typedef struct xen_get_cppc_para xc_cppc_para_t;
>
> Oh. Then ...
>
> > So ...
> >
> >>> @@ -366,6 +365,33 @@ int xc_set_cpufreq_cppc(xc_interface *xch, int
> cpuid,
> >>>      return ret;
> >>>  }
> >>>
> >>> +int xc_get_cppc_para(xc_interface *xch, unsigned int cpuid,
> >>> +                     xc_cppc_para_t *cppc_para) {
> >>> +    int ret;
> >>> +    struct xen_sysctl sysctl = {};
> >>> +    struct xen_get_cppc_para *sys_cppc_para =
> >>> +&sysctl.u.pm_op.u.get_cppc;
> >>> +
> >>> +    if ( !xch  || !cppc_para )
> >>> +    {
> >>> +        errno = EINVAL;
> >>> +        return -1;
> >>> +    }
> >>> +
> >>> +    sysctl.cmd = XEN_SYSCTL_pm_op;
> >>> +    sysctl.u.pm_op.cmd = GET_CPUFREQ_CPPC;
> >>> +    sysctl.u.pm_op.cpuid = cpuid;
> >>> +
> >>> +    ret = xc_sysctl(xch, &sysctl);
> >>> +    if ( ret )
> >>> +        return ret;
> >>> +
> >>> +    BUILD_BUG_ON(sizeof(*cppc_para) != sizeof(*sys_cppc_para));
>
> ... why is this here, when ...
>
> >>> +    memcpy(cppc_para, sys_cppc_para, sizeof(*sys_cppc_para));
> >>
> >> ... you minimally want to apply as much checking here.
>
> ... a better effect can be had by
>
>     cppc_para = sys_cppc_para;
>
> ?
>

True, no need to do memory copy then if it is an alias

> Jan

 


Rackspace

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