Re: [PATCH v15 29/34] x86,fs/resctrl: Auto assign counters on mkdir and clean up on group removal

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

 



Hi Babu,

On 7/8/25 3:17 PM, Babu Moger wrote:
> Resctrl provides a user-configurable option mbm_assign_on_mkdir that
> determines if a counter will automatically be assigned to an RMID, event
> pair when its associated monitor group is created via mkdir.
> 
> Enable mbm_assign_on_mkdir by default and automatically assign the counters
> when a resctrl group is created.
> 
> Counters allocated to a resctrl group should be released when the group is
> deleted. Add support to unassign and free counters during the group
> teardown.
> 
> By default, each group requires two counters: one for the MBM total event
> and one for the MBM local event.
> 
> If the counters are exhausted, the kernel will log the error message
> "Unable to allocate counter in domain" in
> /sys/fs/resctrl/info/last_cmd_status when a new group is created and the
> counter assignment will fail. However, the creation of a group should not
> fail due to assignment failures. Users have the flexibility to modify the
> assignments at a later time.

I find that this changelog jumps around a bit. Below is an attempt at some
re-organization. Please feel free to improve:

	Resctrl provides a user-configurable option mbm_assign_on_mkdir that            
	determines if a counter will automatically be assigned to an RMID, event        
	pair when its associated monitor group is created via mkdir.                    
                                                                                
	Enable mbm_assign_on_mkdir by default to automatically assign                   
	counters to the two default events (MBM total and MBM local) of a new           
	monitoring group created via mkdir. This maintains backward compatibility       
	with original resctrl support for these two events.                             
                                                                                
	Unassign and free counters belonging to a monitoring group when the group is    
	deleted.                                                                        
                                                                                
	Monitor group creation does not fail if a counter cannot be assigned to         
	one or both events. There may be limited counters and users have the      
	flexibility to modify counter assignments at a later time.                      
	Log the error message "Unable to allocate counter in domain" in                 
	/sys/fs/resctrl/info/last_cmd_status when a new monitoring group is created     
	but counter assignment failed.

> 
> Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
> ---

...

> ---
>  arch/x86/kernel/cpu/resctrl/monitor.c |  1 +
>  fs/resctrl/rdtgroup.c                 | 70 ++++++++++++++++++++++++++-
>  2 files changed, 69 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 026c2e2d19d3..e0706083fe0e 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -457,6 +457,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
>  		r->mon.mbm_cntr_assignable = true;
>  		cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
>  		r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
> +		r->mon.mbm_assign_on_mkdir = true;

This is a resctrl fs default. Should it not be set in
resctrl_mon_resource_init()?


>  	}
>  
>  	r->mon_capable = true;
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index b7289ce2b3a6..645245f274e9 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -2884,6 +2884,54 @@ static void schemata_list_destroy(void)
>  	}
>  }
>  
> +/*
> + * rdtgroup_assign_cntrs() - Assign counters to MBM events. Called when
> + *			     a new group is created.
> + * If "mbm_event" counter assignment mode is enabled, counters should be
> + * automatically assigned if the "mbm_assign_on_mkdir" is set.
> + * Each group can accommodate two counters: one for the total event and

"Each group can accommodate two counters" -> "Each group can accommodate two counters
per domain"?

> + * one for the local event. Assignments may fail due to the limited number
> + * of counters. However, it is not necessary to fail the group creation
> + * and thus no failure is returned. Users have the option to modify the
> + * counter assignments after the group has been created.
> + */
> +static void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp)
> +{
> +	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
> +
> +	if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r) ||
> +	    !r->mon.mbm_assign_on_mkdir)
> +		return;
> +
> +	if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID))
> +		rdtgroup_assign_cntr_event(NULL, rdtgrp,
> +					   &mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID]);
> +
> +	if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID))
> +		rdtgroup_assign_cntr_event(NULL, rdtgrp,
> +					   &mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]);
> +}
> +

Reinette





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux