x86/resctrl: Move mbm_cfg_mask to struct rdt_resource

ANBZ: #21730

commit c32a7d7777 upstream.

The mbm_cfg_mask field lists the bits that user-space can set when configuring
an event. This value is output via the last_cmd_status file.

Once the filesystem parts of resctrl are moved to live in /fs/, the struct
rdt_hw_resource is inaccessible to the filesystem code. Because this value is
output to user-space, it has to be accessible to the filesystem code.

Move it to struct rdt_resource.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64
Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20250311183715.16445-23-james.morse@arm.com
Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
Reviewed-by: Kun(llfl) <llfl@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/5425
This commit is contained in:
James Morse 2025-03-11 18:37:07 +00:00 committed by 小龙
parent 32c69150cc
commit cd7acb07fe
5 changed files with 7 additions and 7 deletions

View File

@ -195,8 +195,6 @@ out:
* @msr_update: Function pointer to update QOS MSRs
* @mon_scale: cqm counter * mon_scale = occupancy in bytes
* @mbm_width: Monitor width, to detect and correct for overflow.
* @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth
* Monitoring Event Configuration (BMEC) is supported.
* @cdp_enabled: CDP state of this resource
* @mbm_cntr_assign_enabled: ABMC feature is enabled
*
@ -212,7 +210,6 @@ struct rdt_hw_resource {
struct rdt_resource *r);
unsigned int mon_scale;
unsigned int mbm_width;
unsigned int mbm_cfg_mask;
bool cdp_enabled;
bool mbm_cntr_assign_enabled;
};

View File

@ -303,7 +303,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
/* Detect list of bandwidth sources that can be tracked */
cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx);
hw_res->mbm_cfg_mask = ecx & MAX_EVT_CONFIG_BITS;
r->mbm_cfg_mask = ecx & MAX_EVT_CONFIG_BITS;
}
if (rdt_cpu_has(X86_FEATURE_ABMC)) {

View File

@ -391,14 +391,13 @@ void resctrl_arch_event_config_set(void *info)
int resctrl_arch_mbm_config_write_domain(void *rdt_resource, void *dom, u32 evtid, u32 val)
{
struct rdt_resource *r = rdt_resource;
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
struct rdt_domain *d = dom;
struct mon_config_info mon_info = {0};
u32 config_val;
int ret = 0;
/* Value from user cannot be more than the supported set of events */
if ((val & hw_res->mbm_cfg_mask) != val)
if ((val & r->mbm_cfg_mask) != val)
return -EINVAL;
/*

View File

@ -2096,7 +2096,8 @@ next:
if (d->id == dom_id) {
ret = resctrl_arch_mbm_config_write_domain(r, d, evtid, val);
if (ret) {
rdt_last_cmd_puts("Invalid event configuration\n");
rdt_last_cmd_printf("Invalid event configuration: max valid mask is 0x%02x\n",
r->mbm_cfg_mask);
return -EINVAL;
}

View File

@ -250,6 +250,8 @@ struct resctrl_mon {
* @default_ctrl: Specifies default cache cbm or memory B/W percent.
* @format_str: Per resource format string to show domain value
* @fflags: flags to choose base and info files
* @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth
* monitoring events can be configured.
* @cdp_capable: Is the CDP feature available on this resource
*/
struct rdt_resource {
@ -266,6 +268,7 @@ struct rdt_resource {
u32 default_ctrl;
const char *format_str;
unsigned long fflags;
unsigned int mbm_cfg_mask;
bool cdp_capable;
};