Re: [PATCH v4 08/24] x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid

From: James Morse
Date: Fri Jul 28 2023 - 12:36:02 EST


Hi Reinette,

On 6/15/23 23:09, Reinette Chatre wrote:
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.

Oops, this was the name for the other half of closid_alloc() back when I thought it was more
readable to give it a name. The version posted leaves it alone to reduce the churn. I'll drop this paragraph.


Thanks,

James