Re: [PATCH v5 02/24] x86/resctrl: Access per-rmid structures by index

From: Reinette Chatre
Date: Wed Aug 09 2023 - 18:32:54 EST


Hi James,

On 7/28/2023 9:42 AM, James Morse wrote:


> @@ -600,7 +600,7 @@ static void clear_closid_rmid(int cpu)
> state->default_rmid = 0;
> state->cur_closid = 0;
> state->cur_rmid = 0;
> - wrmsr(MSR_IA32_PQR_ASSOC, 0, 0);
> + wrmsr(MSR_IA32_PQR_ASSOC, 0, RESCTRL_RESERVED_CLOSID);
> }

Can the remaining "0" be replaced with RESCTRL_RESERVED_RMID?


...

> @@ -377,14 +399,17 @@ static void add_rmid_to_limbo(struct rmid_entry *entry)
>
> void free_rmid(u32 closid, u32 rmid)
> {
> + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid);
> struct rmid_entry *entry;
>
> - if (!rmid)
> - return;
> -
> lockdep_assert_held(&rdtgroup_mutex);
>
> - entry = __rmid_entry(closid, rmid);
> + /* do not allow the default rmid to be free'd */
> + if (idx == resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID,
> + RESCTRL_RESERVED_RMID))
> + return;
> +

Why is this encoding necessary? Can the provided function parameters
not be tested directly against RESCTRL_RESERVED_CLOSID and
RESCTRL_RESERVED_RMID ?

> + entry = __rmid_entry(idx);
>
> if (is_llc_occupancy_enabled())
> add_rmid_to_limbo(entry);

Reinette