[PATCH 1/2] fs/resctrl: Return -EBUSY when per-CLOSID RMIDs are in limbo
From: Jinjie Ruan
Date: Thu Oct 29 2026 - 04:16:18 EST
resctrl_find_free_rmid() returns -ENOSPC when no matching RMID is
found. With CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID the target CLOSID may
have RMIDs in limbo rather than permanently exhausted.
Check closid_num_dirty_rmid[] for the target CLOSID before returning
-ENOSPC, and return -EBUSY so userspace can retry.
Cc: James Morse <james.morse@xxxxxxx>
Cc: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Cc: Babu Moger <babu.moger@xxxxxxx>
Fixes: c4c0376eefe1 ("x86/resctrl: Allow RMID allocation to be scoped by CLOSID")
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
fs/resctrl/monitor.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 04e4ea612b7c..b8f4e1ff4083 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -207,9 +207,6 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid)
struct rmid_entry *itr;
u32 itr_idx, cmp_idx;
- if (list_empty(&rmid_free_lru))
- return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC);
-
list_for_each_entry(itr, &rmid_free_lru, list) {
/*
* Get the index of this free RMID, and the index it would need
@@ -225,7 +222,17 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid)
return itr;
}
- return ERR_PTR(-ENOSPC);
+ /*
+ * No free RMID matched. If this CLOSID has RMIDs in limbo, return
+ * -EBUSY so userspace can retry. Otherwise, the CLOSID is genuinely
+ * out of RMIDs. When RMIDs are not per-CLOSID, any RMID in limbo
+ * delays the allocation.
+ */
+ if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
+ return closid_num_dirty_rmid[closid] ? ERR_PTR(-EBUSY) :
+ ERR_PTR(-ENOSPC);
+
+ return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC);
}
/**
--
2.34.1