Messages in this thread | | | Date | Thu, 15 Jun 2023 15:09:12 -0700 | Subject | Re: [PATCH v4 08/24] x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid | From | Reinette Chatre <> |
| |
Hi James,
On 5/25/2023 11:01 AM, James Morse wrote:
...
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c > index 1e7fa40ee471..128d4c7206e4 100644 > --- a/arch/x86/kernel/cpu/resctrl/monitor.c > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c > @@ -379,6 +379,51 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid) > return ERR_PTR(-ENOSPC); > } > > +/** > + * resctrl_find_cleanest_closid() - Find a CLOSID where all the associated > + * RMID are clean, or the CLOSID that has > + * the most clean RMID. > + * > + * MPAM's equivalent of RMID are per-CLOSID, meaning a freshly allocated CLOSID > + * may not be able to allocate clean RMID. To avoid this the allocator will > + * choose the CLOSID with the most clean RMID. > + * > + * When the CLOSID and RMID are independent numbers, the first free CLOSID will > + * be returned. > + * > + * Call when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is defined. If not, call > + * resctrl_closid_alloc_first_free() instead.
I was not able to find where resctrl_closid_alloc_first_free() is introduced.
> + */ > +int resctrl_find_cleanest_closid(void) > +{ > + u32 cleanest_closid = ~0, iter_num_dirty; > + int i = 0; > + > + lockdep_assert_held(&rdtgroup_mutex); > + > + if (!IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) > + return -EIO; > + > + for (i = 0; i < closids_supported(); i++) { > + if (closid_allocated(i)) > + continue; > + > + iter_num_dirty = closid_num_dirty_rmid[i]; > + if (iter_num_dirty == 0) > + return i; > + > + if (cleanest_closid == ~0) > + cleanest_closid = i; > + > + if (iter_num_dirty < closid_num_dirty_rmid[cleanest_closid]) > + cleanest_closid = i; > + } > +
Reinette
| |