On 24.03.2025 08:59, Penny, Zheng wrote:
> [Public]
> 
> Hi,
> 
>> -----Original Message-----
>> From: Jan Beulich <jbeul...@suse.com>
>> Sent: Friday, March 14, 2025 12:33 AM
>> To: Penny, Zheng <penny.zh...@amd.com>
>> Cc: Huang, Ray <ray.hu...@amd.com>; Stefano Stabellini
>> <sstabell...@kernel.org>; Julien Grall <jul...@xen.org>; Bertrand Marquis
>> <bertrand.marq...@arm.com>; Orzel, Michal <michal.or...@amd.com>;
>> Volodymyr Babchuk <volodymyr_babc...@epam.com>; Andrew Cooper
>> <andrew.coop...@citrix.com>; Anthony PERARD <anthony.per...@vates.tech>;
>> Roger Pau Monné <roger....@citrix.com>; Alistair Francis
>> <alistair.fran...@wdc.com>; Bob Eshleman <bobbyeshle...@gmail.com>;
>> Connor Davis <connojda...@gmail.com>; Oleksii Kurochko
>> <oleksii.kuroc...@gmail.com>; Stabellini, Stefano 
>> <stefano.stabell...@amd.com>;
>> Sergiy Kibrik <sergiy_kib...@epam.com>; xen-devel@lists.xenproject.org
>> Subject: Re: [PATCH v1 18/19] xen/sysctl: wrap around arch-specific
>> arch_do_sysctl
>>
>> On 12.03.2025 05:06, Penny Zheng wrote:
>>> --- a/xen/arch/x86/psr.c
>>> +++ b/xen/arch/x86/psr.c
>>> @@ -133,9 +133,11 @@ static const struct feat_props {
>>>       */
>>>      enum psr_type alt_type;
>>>
>>> +#ifdef CONFIG_SYSCTL
>>>      /* get_feat_info is used to return feature HW info through sysctl. */
>>>      bool (*get_feat_info)(const struct feat_node *feat,
>>>                            uint32_t data[], unsigned int array_len);
>>> +#endif
>>>
>>>      /* write_msr is used to write out feature MSR register. */
>>>      void (*write_msr)(unsigned int cos, uint32_t val, enum psr_type
>>> type); @@ -418,6 +420,7 @@ static bool mba_init_feature(const struct
>> cpuid_leaf *regs,
>>>      return true;
>>>  }
>>>
>>> +#ifdef CONFIG_SYSCTL
>>>  static bool cf_check cat_get_feat_info(
>>>      const struct feat_node *feat, uint32_t data[], unsigned int
>>> array_len)  { @@ -430,6 +433,7 @@ static bool cf_check
>>> cat_get_feat_info(
>>>
>>>      return true;
>>>  }
>>> +#endif
>>>
>>>  /* L3 CAT props */
>>>  static void cf_check l3_cat_write_msr( @@ -442,11 +446,14 @@ static
>>> const struct feat_props l3_cat_props = {
>>>      .cos_num = 1,
>>>      .type[0] = PSR_TYPE_L3_CBM,
>>>      .alt_type = PSR_TYPE_UNKNOWN,
>>> +#ifdef CONFIG_SYSCTL
>>>      .get_feat_info = cat_get_feat_info,
>>> +#endif
>>>      .write_msr = l3_cat_write_msr,
>>>      .sanitize = cat_check_cbm,
>>>  };
>>>
>>> +#ifdef CONFIG_SYSCTL
>>>  /* L3 CDP props */
>>>  static bool cf_check l3_cdp_get_feat_info(
>>>      const struct feat_node *feat, uint32_t data[], uint32_t
>>> array_len) @@ -458,6 +465,7 @@ static bool cf_check
>>> l3_cdp_get_feat_info(
>>>
>>>      return true;
>>>  }
>>> +#endif
>>>
>>>  static void cf_check l3_cdp_write_msr(
>>>      unsigned int cos, uint32_t val, enum psr_type type) @@ -473,7
>>> +481,9 @@ static const struct feat_props l3_cdp_props = {
>>>      .type[0] = PSR_TYPE_L3_DATA,
>>>      .type[1] = PSR_TYPE_L3_CODE,
>>>      .alt_type = PSR_TYPE_L3_CBM,
>>> +#ifdef CONFIG_SYSCTL
>>>      .get_feat_info = l3_cdp_get_feat_info,
>>> +#endif
>>>      .write_msr = l3_cdp_write_msr,
>>>      .sanitize = cat_check_cbm,
>>>  };
>>> @@ -489,11 +499,14 @@ static const struct feat_props l2_cat_props = {
>>>      .cos_num = 1,
>>>      .type[0] = PSR_TYPE_L2_CBM,
>>>      .alt_type = PSR_TYPE_UNKNOWN,
>>> +#ifdef CONFIG_SYSCTL
>>>      .get_feat_info = cat_get_feat_info,
>>> +#endif
>>>      .write_msr = l2_cat_write_msr,
>>>      .sanitize = cat_check_cbm,
>>>  };
>>>
>>> +#ifdef CONFIG_SYSCTL
>>>  /* MBA props */
>>>  static bool cf_check mba_get_feat_info(
>>>      const struct feat_node *feat, uint32_t data[], unsigned int
>>> array_len) @@ -508,6 +521,7 @@ static bool cf_check mba_get_feat_info(
>>>
>>>      return true;
>>>  }
>>> +#endif
>>>
>>>  static void cf_check mba_write_msr(
>>>      unsigned int cos, uint32_t val, enum psr_type type) @@ -545,7
>>> +559,9 @@ static const struct feat_props mba_props = {
>>>      .cos_num = 1,
>>>      .type[0] = PSR_TYPE_MBA_THRTL,
>>>      .alt_type = PSR_TYPE_UNKNOWN,
>>> +#ifdef CONFIG_SYSCTL
>>>      .get_feat_info = mba_get_feat_info,
>>> +#endif
>>>      .write_msr = mba_write_msr,
>>>      .sanitize = mba_sanitize_thrtl,
>>>  };
>>> @@ -808,6 +824,7 @@ static struct psr_socket_info *get_socket_info(unsigned
>> int socket)
>>>      return socket_info + socket;
>>>  }
>>>
>>> +#ifdef CONFIG_SYSCTL
>>>  int psr_get_info(unsigned int socket, enum psr_type type,
>>>                   uint32_t data[], unsigned int array_len)  { @@
>>> -839,6 +856,7 @@ int psr_get_info(unsigned int socket, enum psr_type
>>> type,
>>>
>>>      return -EINVAL;
>>>  }
>>> +#endif /* CONFIG_SYSCTL */
>>>
>>>  int psr_get_val(struct domain *d, unsigned int socket,
>>>                  uint32_t *val, enum psr_type type)
>>
>> That's quite a lot of #ifdef-ary here. I wonder if we can't do any better.
>>
> 
> xl-psr half relies on sysctl op, and half relies on domctl. So I'm not sure 
> for
> CONFIG_X86_PSR, whether we shall make it dependent on CONFIG_SYSCTL

And indeed I don't think you can. That also wasn't what I had in mind (or else I
would have said so explicitly); I kept my reply vague because I didn't have any
concrete suggestion (yet).

Jan

Reply via email to