Re: [PATCH v10 11/12] x86/resctrl: Add the ERDT CMT scale
From: Reinette Chatre
Date: Wed Dec 02 2026 - 14:47:13 EST
Hi Chenyu,
On 11/29/26 3:56 AM, Chen Yu wrote:
> On Wed, Nov 25, 2026 at 11:12:42AM -0800, Reinette Chatre wrote:
>> On 11/5/26 2:09 AM, Chen Yu wrote:
>>> The limbo handler polls the LLC occupancy of limbo RMIDs and makes an RMID
>>> available for reuse once its occupancy drops below
>>> resctrl_rmid_realloc_threshold. User space sets this threshold in bytes by
>>> writing to the "max_threshold_occupancy" file. The occupancy counter only has
>>> the granularity of its scale, the number of bytes one counter unit represents,
>>> so resctrl_arch_round_mon_val() rounds the written byte value down to a multiple
>>> of that scale before it is stored in resctrl_rmid_realloc_threshold.
>>>
>>> resctrl_arch_round_mon_val() uses the CPUID-provided scale. LLC occupancy read
>>> via ERDT is instead scaled by the CMRC up_scale of each ERDT domain.
>>> resctrl_rmid_realloc_threshold is a single global value, so one scale has to be
>>> derived from the per-domain values.
>>>
>>> Add erdt_cmt_scale to hold the largest CMRC up_scale among all ERDT domains. Use
>>> the largest because rounding is a floor: a larger scale yields a slightly lower
>>> threshold, i.e. an RMID has to drop to a slightly lower occupancy before it is
>>
>> Regarding "a larger scale yields a slightly lower threshold". I do not think this
>> is universally true.
>>
>> resctrl_arch_round_mon_val() computes threshold using
>> threshold = (val / scale) * scale
>>
>> With an input of val=100 and a sample of scale values the threshold could vary:
>> scale = 30 -> threshold = 90
>> scale = 40 -> threshold = 80
>> scale = 60 -> threshold = 60
>> scale = 100 -> threshold = 100
>>
>> Above shows that it is not guaranteed that a larger scale automatically yields a
>> lower threshold so perhaps there are some built-in assumptions in this implementation?
>>
>
> You are right, previously I thought the larger the scale(denominator) is, the smaller
> the final value would be - and that is not be the case according to your example.
>
>> If all domains actually have the same up_scale, then that could just be enforced
>> directly instead of routed through a max that is not actually a maximum?
>>
>> If, instead, the maximum scale is a multiple of all the possible scale values,
>> which is the only scenario under which the changelog statement is accurate,
>> then that should be stated clearly?
>>
>> If, instead, as the changelog implies, scale values can be arbitrary,
>> then using the max does not seem justified.
>>
>
> There is no description in the spec saying whether each CMRC could have a
> different up_scale value. Let me check with the silicon team whether each
> domain should have the same up_scale in the CMRC table. If yes, let me change
> the max() into a sanity check. If there is no answer on whether each domain
> must have the same up_scale, can we use the first up_scale detected, just as
> the current code does in the legacy MSR-based path, using the boot CPU's
> boot_cpu_data.x86_cache_occ_scale and print a warning?
Let's start with what you learn from the team on what software can expect the
relationship between the different up_scale values to be.
Reinette