Re: [PATCH] x86/resctrl: mba_MBps: Fall back to total b/w if local b/w unavailable

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

 



Tony,

On 10/25/23 15:39, Moger, Babu wrote:
> Hi Tony,
> 
> On 10/25/23 14:38, Tony Luck wrote:
>> On Wed, Oct 25, 2023 at 02:46:53PM +0200, Peter Newman wrote:
>>> Hi Tony,
>>>
>>> On Tue, Oct 24, 2023 at 8:16 PM Tony Luck <tony.luck@xxxxxxxxx> wrote:
>>>> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
>>>> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
>>>> @@ -418,6 +418,14 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
>>>>         return 0;
>>>>  }
>>>>
>>>> +static struct mbm_state *get_mbm_data(struct rdt_domain *dom_mbm, int rmid)
>>>> +{
>>>> +       if (is_mbm_local_enabled())
>>>> +               return &dom_mbm->mbm_local[rmid];
>>>> +
>>>> +       return &dom_mbm->mbm_total[rmid];
>>>> +}
>>>
>>> That looks very similar to the get_mbm_state() function I added to
>>> this same file recently:
>>>
>>> https://lore.kernel.org/all/20221220164132.443083-2-peternewman%40google.com
>>>
>>> I think the name you picked is misleadingly general. "local if
>>> available, otherwise total" seems to be a choice specific to the mbps
>>> controller. I think these functions should be reconciled a little
>>> better.
>>>
>>
>> Peter (and Babu, who made the same point about get_mbm_state().
>>
>> Do you want to see your function extended to do the "pick an MBM event?"
>>
>> I could add a s/w defined "event" to the enum resctrl_event_id and
>> extend get_mbm_state() like this:
>>
>>
>> static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 rmid,
>> 				       enum resctrl_event_id evtid)
>> {
>> 	switch (evtid) {
>> 	case QOS_L3_MBM_TOTAL_EVENT_ID:
>> 		return &d->mbm_total[rmid];
>> 	case QOS_L3_MBM_LOCAL_EVENT_ID:
>> 		return &d->mbm_local[rmid];
>> +	case QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID:
>> +		if (is_mbm_local_enabled())
>> +			return &d->mbm_local[rmid];
>> +		if (is_mbm_total_enabled())
>> +			return &d->mbm_total[rmid];
>> +		fallthrough;
>> 	default:
>> 		return NULL;
>> 	}
>> }
>>
>> Is this the direction you are thinking of?
> 
> No. I was not thinking bit different.

I meant, I was thinking bit different.

> 
> You need these changes in only two functions, mbm_bw_count and
> update_mba_bw. You decide which event you want to use based on availability,
> 
> Something like this. I updated mbm_bw_count.
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c
> b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 0ad23475fe16..302993e4fbc3 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -436,8 +436,16 @@ static int __mon_event_count(u32 rmid, struct
> rmid_read *rr)
>   */
>  static void mbm_bw_count(u32 rmid, struct rmid_read *rr)
>  {
> -       struct mbm_state *m = &rr->d->mbm_local[rmid];
>         u64 cur_bw, bytes, cur_bytes;
> +       struct mbm_state *m;
> +       int evtid;
> +
> +       if (is_mbm_local_enabled())
> +               evtid = QOS_L3_MBM_LOCAL_EVENT_ID;
> +       else
> +               evtid = QOS_L3_MBM_TOTAL_EVENT_ID;
> +
> +       m = get_mbm_state(rr->d, rmid, evtid);
> 
>         cur_bytes = rr->val;
>         bytes = cur_bytes - m->prev_bw_bytes;
> 
> 
> Will this work?
> 
> Thanks
> Babu
> 
> 
>>
>> Callers then look like:
>>
>> static void mbm_bw_count(u32 rmid, struct rmid_read *rr)
>> {
>> 	struct mbm_state *m = get_mbm_state(rr->d, rmid, QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID);
>> 	u64 cur_bw, bytes, cur_bytes;
>>
>> similar for the other three places where this is needed.
>>
>> Any suggestions on how "QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID" could be
>> abbreviated, or just have some different, but descriptive, name?
>>
>> -Tony
> 

-- 
Thanks
Babu Moger




[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