fs/resctrl: Fix some resctl bugs related to mpam
Subsystems (4)
v5 cover fs/resctrl: Fix some resctl bugs related to mpam
From: Jinjie Ruan <[email protected]>
Fix resctrl RMID allocation to report a retryable -EBUSY only when the target CLOSID actually has RMIDs in limbo.
Split the domain-offline path out so it releases busy RMIDs without allocating a monitor context it never uses.
Also unmount resctrl with the CDP state it was mounted with to fix another bug with mpam cdp.
And do not allow monitor group move when the RMID index changes.
These fixes are split out of the v10 Narrow-PARTID series below.
https://lore.kernel.org/all/[email protected]/
Changes in v5:
- Update and split the patch as Reinette and Ben suggested.
- Adjust the commit message.
- Add Reviewed-by.
- Link to v4:
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Fix the unmount resctrl bug as Reinette suggested.
- Adjust the commit message.
- Add Reviewed-bys.
- Link to v3:
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Add Reviewed-by.
- Local varibles uses reverse Christmas tree style.
- Update the commit message as Reinette suggested.
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2
- Update the commit message as Reinette suggested.
- Link to v1: https://lore.kernel.org/all/[email protected]/
Jinjie Ruan (6):
fs/resctrl: Report a temporary RMID shortage per CLOSID fs/resctrl: Do not allocate a monitor context when releasing limbo
RMIDs
fs/resctrl: Clear the CDP state after the cleanup fs/resctrl: Stop the limbo handler while resctrl is unmounted fs/resctrl: Release the limbo RMIDs when the CDP state changes fs/resctrl: Add info/moveable_mon_group
Peter Newman (1):
fs/resctrl: Disallow monitor group move when the RMID index changes
Documentation/filesystems/resctrl.rst | 15 ++- arch/x86/include/asm/resctrl.h | 6 + drivers/resctrl/mpam_resctrl.c | 9 ++ fs/resctrl/internal.h | 3 +- fs/resctrl/monitor.c | 151 ++++++++++++++++++++------ fs/resctrl/rdtgroup.c | 50 ++++++++- include/linux/arm_mpam.h | 1 + 7 files changed, 196 insertions(+), 39 deletions(-)
Signature · 1 line
2.43.0
PATCH v5 1/7 fs/resctrl: Report a temporary RMID shortage per CLOSID
From: Jinjie Ruan <[email protected]>
An RMID that is freed is held in limbo until its cache occupancy drops below the threshold, after which it returns to the free list. A request that fails because of limbo is thus temporary and worth retrying, which resctrl reports to userspace as -EBUSY. A request that fails because every RMID is in use is permanent and reported as -ENOSPC.
Where an RMID is only meaningful together with a CLOSID, a request can only be satisfied by an RMID belonging to the requested CLOSID, so the distinction has to be drawn per CLOSID. Instead it is drawn system wide. -ENOSPC is reported when the free list holds no RMID for the requested CLOSID, even when that CLOSID has RMIDs in limbo. -EBUSY is reported when the free list is empty and another CLOSID has an RMID in limbo, even when the requested CLOSID has none. Userspace is thus told to give up on a shortage that may clear on its own, and to retry one that cannot clear until it removes a group itself.
Architectures where the RMID is independent of the CLOSID always match the first entry on the free list, so neither case arises there and only MPAM systems are affected.
Draw the distinction from the number of RMIDs the requested CLOSID has in limbo where the RMID depends on the CLOSID, and from the system wide count otherwise. Drop the separate test for an empty free list, which the search handles on its own.
--- fs/resctrl/monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/resctrl/monitor.c +11 -4
@@ -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 ); }/**
Signature · 1 line
2.43.0
Re: [PATCH v5 1/7] fs/resctrl: Report a temporary RMID shortage per CLOSID
Please ignore, will resend.
Quoted 72 lines · Jinjie Ruan
From: Jinjie Ruan <[email protected]>
An RMID that is freed is held in limbo until its cache occupancy drops below the threshold, after which it returns to the free list. A request that fails because of limbo is thus temporary and worth retrying, which resctrl reports to userspace as
-EBUSY. A request that fails because every RMID is in use is permanent and reported as-ENOSPC.Where an RMID is only meaningful together with a CLOSID, a request can only be satisfied by an RMID belonging to the requested CLOSID, so the distinction has to be drawn per CLOSID. Instead it is drawn system wide.
-ENOSPCis reported when the free list holds no RMID for the requested CLOSID, even when that CLOSID has RMIDs in limbo.-EBUSYis reported when the free list is empty and another CLOSID has an RMID in limbo, even when the requested CLOSID has none. Userspace is thus told to give up on a shortage that may clear on its own, and to retry one that cannot clear until it removes a group itself.Architectures where the RMID is independent of the CLOSID always match the first entry on the free list, so neither case arises there and only MPAM systems are affected.
Draw the distinction from the number of RMIDs the requested CLOSID has in limbo where the RMID depends on the CLOSID, and from the system wide count otherwise. Drop the separate test for an empty free list, which the search handles on its own.
Fixes c4c0376eefe1 ("x86/resctrl: Allow RMID allocation to be scoped by CLOSID")Signed-off-by Jinjie Ruan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Reviewed-by Ben Horgan <[email protected]>Cc James Morse <[email protected]>Cc Reinette Chatre <[email protected]>Cc Babu Moger <[email protected]>Cc <[email protected]> # 7.1.x--- fs/resctrl/monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)fs/resctrl/monitor.c +11
-4@@ -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 ); }/**
Signature · 2 lines
Best regards, Jinjie
PATCH v5 2/7 fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs
In reply to Jinjie RuanFrom: Jinjie Ruan <[email protected]>
Busy RMIDs of a monitor domain are normally released by the limbo handler once their cache occupancy drops below the threshold. When a domain goes offline, its busy RMIDs are released without checking occupancy, since the domain is going away and the RMIDs would otherwise never return to the free list.
On the monitor domain offline path, __check_limbo() allocates the monitor context that an occupancy check needs before it scans the busy RMIDs, but without using it, and returns early when that allocation fails. Then the caller destroys the domain's monitoring state, including the bitmap that records which RMIDs are busy, so nothing can clear those bits afterwards and the busy counts never reach zero. Those RMIDs never return to the free list and, where the RMID depends on the CLOSID, the dirty count of their CLOSID never decreases. The allocation can also wait for a monitor to become free, which stalls the CPU offline path on a context that is not going to be used.
Only MPAM systems are affected. An architecture that can always read an RMID allocates nothing for the monitor context, so the allocation can neither fail nor wait there.
Move the release of busy RMIDs into a separate function that does not take a monitor context and leave the occupancy check to __check_limbo().
--- fs/resctrl/internal.h | 2 +- fs/resctrl/monitor.c | 72 ++++++++++++++++++++++++++++--------------- fs/resctrl/rdtgroup.c | 2 +- 3 files changed, 49 insertions(+), 27 deletions(-)
fs/resctrl/internal.h +1 -1
@@ -405,7 +405,7 @@ void cqm_handle_limbo(struct work_struct *work);bool has_busy_rmid (struct rdt_l3_mon_domain *d); -void __check_limbo (struct rdt_l3_mon_domain *d,bool force_free); +void release_limbo_rmids (struct rdt_l3_mon_domain *d);void resctrl_file_fflags_init (const char *config,unsigned long fflags);
fs/resctrl/monitor.c +47 -25
105 lines not on this page · raw message
fs/resctrl/rdtgroup.c +1 -1
@@ -4590,7 +4590,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *h* the RMID as busy creates RMID leaks if the * package never comes back. */ -__check_limbo (d, true); +release_limbo_rmids (d); }domain_destroy_l3_mon_state (d);
Signature · 1 line
2.43.0
PATCH v5 3/7 fs/resctrl: Clear the CDP state after the cleanup
In reply to Jinjie RuanFrom: Jinjie Ruan <[email protected]>
On MPAM a CLOSID is translated into the PARTIDs that the hardware configuration uses. Without CDP, CLOSID c is PARTID c; with CDP it is PARTIDs 2c and 2c+1. resctrl_unmount() clears the CDP state with rdt_disable_ctx() before resctrl_fs_teardown() removes the groups, so the teardown translates the CLOSIDs differently from when the groups were set up.
For example, rdtgroup_unassign_cntrs() unassigns and resets the MBM counters of each group through resctrl_arch_config_cntr(). On MPAM that helper maps a counter to a monitor with the index resctrl_get_config_index() returns for the CDP state. A counter assigned while CDP was enabled is mapped to the monitor for PARTIDs 2c and 2c+1. With CDP cleared, MPAM removes the mapping of PARTID c and resets the monitor for PARTID c instead, so the mappings of PARTIDs 2c and 2c+1 are left behind. The helper had an empty body on MPAM until the ABMC support implemented it, which is when the teardown started to program the mapping with the cleared state.
Clear the CDP state after resctrl_fs_teardown(), so the teardown runs with the CDP state the configuration was created under.
x86 is not affected as its RMIDs and counters do not depend on the CLOSID.
--- fs/resctrl/rdtgroup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/resctrl/rdtgroup.c +8 -2
@@ -3150,13 +3150,19 @@ static void resctrl_unmount(void)cpus_read_lock ();mutex_lock (&rdtgroup_mutex); -rdt_disable_ctx (); -/* Put everything back to default values. */ for_each_alloc_capable_rdt_resource (r)resctrl_arch_reset_all_ctrls (r);resctrl_fs_teardown (); + +/* +* Clear the CDP state after the cleanup. The CDP state decides +* which hardware configuration a CLOSID refers to, so the teardown +* must run with the state the configuration was created under. +*/ +rdt_disable_ctx (); +if (resctrl_arch_alloc_capable ())resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())
Signature · 1 line
2.43.0
PATCH v5 4/7 fs/resctrl: Stop the limbo handler while resctrl is unmounted
In reply to Jinjie RuanFrom: Jinjie Ruan <[email protected]>
A group's RMID is not returned to the free list when the group is removed. It stays in limbo until the cache lines tagged with it are evicted, and the limbo handler reads its occupancy counter in the meantime. The limbo handler keeps running after resctrl is unmounted, while the MBM overflow handler stops once resctrl_mounted is cleared.
Reading the RMIDs in limbo while resctrl is unmounted is not safe on every architecture. On MPAM the counter of an RMID is selected by the PARTIDs of the CLOSID that owned it, and the CLOSID to PARTID mapping depends on the CDP state. The unmount clears the CDP state, so the handler that keeps running reads the RMIDs freed under CDP through the PARTIDs of the cleared state.
Stop the limbo handler while resctrl is unmounted, as the overflow handler does, and restart it after a mount on every domain that still has RMIDs in limbo. The worker can stay queued across the unmount, so cancel it before queuing it again. This keeps the limbo handler lifetime the same on every architecture.
On x86 the RMIDs in limbo are no longer drained while resctrl is unmounted. Nothing needs them until the mount that follows the unmount, after which the handler frees them as before.
--- fs/resctrl/internal.h | 1 + fs/resctrl/monitor.c | 43 +++++++++++++++++++++++++++++++++++++++++-- fs/resctrl/rdtgroup.c | 2 ++ 3 files changed, 44 insertions(+), 2 deletions(-)
fs/resctrl/internal.h +1 -0
@@ -373,6 +373,7 @@ void closid_free(int closid);int setup_rmid_lru_list (void );void free_rmid_lru_list (void ); +void resctrl_limbo_resume (void );int alloc_rmid (u32 closid);
fs/resctrl/monitor.c +41 -2
61 lines not on this page · raw message
fs/resctrl/rdtgroup.c +2 -0
@@ -3267,6 +3267,8 @@ static int rdt_get_tree(struct fs_context *fc) RESCTRL_PICK_ANY_CPU); } +resctrl_limbo_resume (); +/* * Ensure root remains accessible after mutex is unlocked so that * kernfs_kill_sb() can run safely if called by kernfs_get_tree()'s
Signature · 1 line
2.43.0
PATCH v5 5/7 fs/resctrl: Release the limbo RMIDs when the CDP state changes
In reply to Jinjie RuanFrom: Jinjie Ruan <[email protected]>
On MPAM the counter of an RMID is selected by the PARTIDs of the CLOSID that owned it. Without CDP, CLOSID c is PARTID c; with CDP it is PARTIDs 2c and 2c+1. An RMID that stays in limbo across an unmount and a mount that changes the CDP state is read through the PARTIDs of the new state, which are not the PARTIDs its cache lines are tagged with.
With 5 PARTIDs:
mount CDP off, CLOSID c -> PARTID c mkdir g1..g4 CLOSIDs 1..4 umount RMIDs enter limbo with CLOSIDs 1..4 mount -o cdp CDP on, CLOSID c -> PARTIDs 2c, 2c+1 limbo handler reads CLOSID 2 as PARTID 5 > PARTID_MAX 4
MSC error interrupt, mpam_disable()
The other direction is worse because nothing reports it. If resctrl is mounted with CDP and mounted again without it, CLOSID c is read as PARTID c, which is in range, so the limbo handler silently tests the occupancy of the PARTID of a different CLOSID and frees or keeps the RMIDs based on it.
When a mount changes the CDP state, release the RMIDs in limbo without reading them instead of restarting the limbo handler. Cache lines that still carry those RMIDs are accounted to the next user of each RMID.
The CDP state that matters is the one that changes the PARTIDs used by the monitors, which is not necessarily the CDP state of the L3 resource. MPAM gives every CLOSID two PARTIDs in all MSCs while CDP is enabled on any resource, so enabling CDP on L2 alone also changes the PARTIDs the L3 monitors use. Add resctrl_arch_mon_cdp_enabled() to let the architecture report this. Only MPAM can be affected, so the RMIDs are only released where the RMID depends on the CLOSID. On x86 the RMID does not depend on the CLOSID, and resctrl_arch_mon_cdp_enabled() returns false.
Reproduced on QEMU with the sequence above:
mpam:__mpam_irq_handler: error irq from msc:1 'MSMONCFG_ID_RANGE', partid:5, pmg: 0, ris: 0 mpam:mpam_disable: MPAM disabled due to hardware error interrupt
With the change the sequence completes without an error.
---
v5:
- Split the change of the limbo handler lifetime into the previous
patch. The limbo handler now stops while resctrl is unmounted on every architecture, and only the release of the RMIDs depends on CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
- Drop the cqm_work_cpu changes. resctrl_limbo_resume() cancels the
worker before it queues it again or releases the RMIDs.
- Move the rdt_disable_ctx() reordering to a separate patch.
- Add resctrl_arch_mon_cdp_enabled() instead of comparing the CDP state
of L2 in the file system.
- Rename limbo_cdp to limbo_cdp_enabled and document that it is only set
with CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
- Check QOS_L3_OCCUP_EVENT_ID first and drop the rmid_busy_llc check.
- Use lockdep_assert_cpus_held() at the start of resctrl_limbo_resume().
- Describe the reverse sequence, from CDP on to CDP off.
- Link to v4: https://lore.kernel.org/all/[email protected]/
v4:
- Use resctrl_mounted instead of a separate limbo_paused flag.
- Record the CDP state once when resctrl is mounted.
- Add resctrl_limbo_resume(), called once resctrl_mounted is set.
- Previous Link: https://lore.kernel.org/all/[email protected]/
--- arch/x86/include/asm/resctrl.h | 6 ++++++ drivers/resctrl/mpam_resctrl.c | 9 +++++++++ fs/resctrl/monitor.c | 25 +++++++++++++++++++++++-- include/linux/arm_mpam.h | 1 + 4 files changed, 39 insertions(+), 2 deletions(-)
arch/x86/include/asm/resctrl.h +6 -0
@@ -181,6 +181,12 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)return rmid; } +/* The RMID does not depend on the CLOSID, so neither does CDP change it */ +static inline bool resctrl_arch_mon_cdp_enabled (void ) +{ +return false; +} +/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r,
drivers/resctrl/mpam_resctrl.c +9 -0
@@ -148,6 +148,15 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid)return mpam_resctrl_controls[rid].cdp_enabled; } +/* +* CDP emulation gives every CLOSID two PARTIDs in all MSCs, so CDP enabled +* on any resource changes the PARTIDs the monitors use for a CLOSID. +*/ +bool resctrl_arch_mon_cdp_enabled (void ) +{ +return cdp_enabled; +} +u32 resctrl_arch_preconvert_bw (const struct rdt_resource *r,u32 val) {return val;
fs/resctrl/monitor.c +23 -2
@@ -70,6 +70,14 @@ static u32 *closid_num_dirty_rmid;*/ static unsigned int rmid_limbo_count; +/* +* @limbo_cdp_enabled - Whether CDP changed the hardware IDs the monitors +* used for a CLOSID when the RMIDs in limbo were freed. +* Only set when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID +* is enabled. +*/ +static bool limbo_cdp_enabled; +/* * @rmid_entry - The entry in the limbo and free lists. */
@@ -1044,12 +1052,15 @@ int setup_rmid_lru_list(void)* resctrl_limbo_resume() - Restart the limbo handler after a mount. * * The limbo handler stops while resctrl is unmounted. Restart it on every -* domain that still has RMIDs in limbo. +* domain that still has RMIDs in limbo. Where the RMID depends on the +* CLOSID and the mount changed the hardware IDs a CLOSID is monitored +* with, the RMIDs in limbo can no longer be read: release them instead. */ void resctrl_limbo_resume (void ) {struct rdt_l3_mon_domain *d;struct rdt_resource *r; +bool release = false;lockdep_assert_cpus_held ();lockdep_assert_held (&rdtgroup_mutex);
@@ -1057,6 +1068,13 @@ void resctrl_limbo_resume(void)if (!resctrl_is_mon_event_enabled (QOS_L3_OCCUP_EVENT_ID ))return ; +if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { +bool cdp_enabled =resctrl_arch_mon_cdp_enabled (); + + release = cdp_enabled != limbo_cdp_enabled; + limbo_cdp_enabled = cdp_enabled; + } + r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );list_for_each_entry_rcu (d, &r->mon_domains, hdr.list,lockdep_is_cpus_held ()) {
@@ -1068,7 +1086,10 @@ void resctrl_limbo_resume(void)* it is queued again on a CPU picked now. */ cancel_delayed_work (&d->cqm_limbo); -cqm_setup_limbo_handler (d,0 ,RESCTRL_PICK_ANY_CPU ); +if (release) +release_limbo_rmids (d); +else +cqm_setup_limbo_handler (d,0 ,RESCTRL_PICK_ANY_CPU ); } }
include/linux/arm_mpam.h +1 -0
@@ -62,6 +62,7 @@ bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid);u32 resctrl_arch_rmid_idx_encode (u32 closid,u32 rmid);void resctrl_arch_rmid_idx_decode (u32 idx,u32 *closid,u32 *rmid);u32 resctrl_arch_system_num_rmid_idx (void ); +bool resctrl_arch_mon_cdp_enabled (void );struct rdt_resource ;void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,enum resctrl_event_id evtid);
Signature · 1 line
2.43.0
PATCH v5 6/7 fs/resctrl: Disallow monitor group move when the RMID index changes
In reply to Jinjie RuanFrom: Peter Newman <[email protected]>
A MON group can be moved into the mon_groups directory of another CTRL_MON group to move its tasks to that group's allocation while keeping their monitoring data. Where the RMID is only meaningful together with the CLOSID, as on arm64 MPAM where the RMID is a PMG that extends the PARTID, the move changes the RMID index of the group. The move succeeds, but:
- The group's monitoring data is reset. Its counters are identified by the CLOSID and RMID together, so after the move the group reads the counters of the new CLOSID instead of the ones its tasks used.
- The group uses an RMID index that was never allocated to it. When the group is removed, free_rmid() puts an RMID index of the new CLOSID into limbo without checking that the group owns it. If another group of that CLOSID holds the index, the limbo handler tests and frees an RMID that is still in use, while the RMID index allocated to the moved group is never freed.
- The tasks are not moved. mongrp_reparent() sets the new parent and CLOSID of the group before rdt_move_group_tasks() looks for the tasks to update, and the search then matches on the new CLOSID, which none of the tasks carries yet. The tasks keep the old CLOSID and the old CTRL_MON group's allocation, and the group does not count them.
Fixing the task move does not make the move work. The RMID index is the hardware ID the counters count for, so a group whose CLOSID changes cannot keep its monitoring data, and it would need a new RMID index allocated for the new CLOSID, which fails when every RMID index of that CLOSID is in use. The documentation promises that a move keeps the monitoring data, so the move cannot be supported, as decided in the thread at the Link tag.
Reject the move with -EOPNOTSUPP when it changes the RMID index of the group, and document that a move is not allowed when the monitoring data or assigned tasks would be impacted. Where the RMID does not depend on the CLOSID, such as on x86, the move keeps the same RMID index and is still allowed. Renaming a MON group within the same CTRL_MON group keeps the CLOSID and is still allowed everywhere.
---
v5:
- Retitle as the RMID index changes, not the RMID, and a rename within
the same CTRL_MON group is still allowed.
- Describe the RMID index that is freed without having been allocated,
and why the move cannot be fixed instead of being rejected.
- Drop the parent and resctrl_arch_mon_capable() checks, which the RMID index comparison and the MON group check already cover.
- Use the resctrl.rst terms in the last_cmd_status message.
- Drop the stable version range and the Link tags the changelog did not refer to, and link the decision to reject the move instead.
- Link to v2: https://lore.kernel.org/all/[email protected]/
v2:
- Drop the Suggested-by tag.
- Describe the systems by whether the RMID depends on the CLOSID rather than by MPAM, in both the changelog and resctrl.rst.
- Explain that moving a monitor group is already broken on these systems because the tasks are not moved, so no existing user relies on it.
- v1: https://lore.kernel.org/all/[email protected]/
--- Documentation/filesystems/resctrl.rst | 8 ++++---- fs/resctrl/rdtgroup.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
Documentation/filesystems/resctrl.rst +4 -4
@@ -551,10 +551,10 @@ will automatically remove all MON groups below it. Moving MON group directories to a new parent CTRL_MON group is supported for the purpose of changing the resource allocations of a MON group -without impacting its monitoring data or assigned tasks. This operation -is not allowed for MON groups which monitor CPUs. No other move -operation is currently allowed other than simply renaming a CTRL_MON or -MON group. +without impacting its monitoring data or assigned tasks. This operation is +not allowed for MON groups which monitor CPUs, or when the monitoring data +or assigned tasks would be impacted. No other move operation is currently +allowed other than simply renaming a CTRL_MON or MON group. All groups contain the following files:
fs/resctrl/rdtgroup.c +13 -0
@@ -4403,6 +4403,19 @@ static int rdtgroup_rename(struct kernfs_node *kn, goto out; } +/* +* Moving the group to another CTRL_MON group changes its CLOSID. +* Where the RMID is only meaningful together with the CLOSID, this +* changes the RMID index and the monitor state cannot follow the +* move. A rename within the same CTRL_MON group keeps the index. +*/ +if (resctrl_arch_rmid_idx_encode (rdtgrp->closid, rdtgrp->mon.rmid) != +resctrl_arch_rmid_idx_encode (new_prdtgrp->closid, rdtgrp->mon.rmid)) { +rdt_last_cmd_puts ("Moving a MON group to a new CTRL_MON group is not supported\n" ); + ret = -EOPNOTSUPP ; + goto out; + } +/* * If the MON group is monitoring CPUs, the CPUs must be assigned to the * current parent CTRL_MON group and therefore cannot be assigned to
Signature · 1 line
2.43.0
PATCH v5 7/7 fs/resctrl: Add info/moveable_mon_group
In reply to Jinjie RuanFrom: Jinjie Ruan <[email protected]>
Moving a MON group into the mon_groups directory of another CTRL_MON group changes the CLOSID of the group while its RMID stays the same. Where the RMID is only meaningful together with the CLOSID, as on arm64 MPAM, the move changes the RMID index of the group and is rejected with -EOPNOTSUPP.
Userspace cannot tell whether the move is supported without trying it. Add "info/moveable_mon_group", which reads 1 when a MON group can be moved to another CTRL_MON group and 0 when the move is rejected, and refer to it where resctrl.rst describes the move.
--- Documentation/filesystems/resctrl.rst | 11 +++++++++-- fs/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-)
Documentation/filesystems/resctrl.rst +9 -2
@@ -526,6 +526,12 @@ conveyed in the error returns from file operations. E.g. # cat info/last_cmd_status mask f7 has non-consecutive 1-bits +The top level of the "info" directory also has a "moveable_mon_group" +file, which reports whether a MON group can be moved to the +"mon_groups" directory of another CTRL_MON group. It reads 1 if the +move is supported, and 0 if the move would impact the monitoring data +and fails with -EOPNOTSUPP. + Resource alloc and monitor groups =================================
@@ -553,8 +559,9 @@ Moving MON group directories to a new parent CTRL_MON group is supported for the purpose of changing the resource allocations of a MON group without impacting its monitoring data or assigned tasks. This operation is not allowed for MON groups which monitor CPUs, or when the monitoring data -or assigned tasks would be impacted. No other move operation is currently -allowed other than simply renaming a CTRL_MON or MON group. +or assigned tasks would be impacted, which "info/moveable_mon_group" +reports. No other move operation is currently allowed other than simply +renaming a CTRL_MON or MON group. All groups contain the following files:
fs/resctrl/rdtgroup.c +23 -0
@@ -1200,6 +1200,22 @@ static int rdt_num_rmids_show(struct kernfs_open_file *of,return 0 ; } +static int rdt_moveable_mon_group_show (struct kernfs_open_file *of, +struct seq_file *seq,void *v) +{ +/* +* Moving a MON group to another CTRL_MON group keeps its RMID but +* changes its CLOSID. Where the RMID index depends on the CLOSID, +* the RMID index changes with the CLOSID and the move is rejected. +*/ +bool fixed =IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID ) && +resctrl_arch_alloc_capable (); + +seq_printf (seq,"%u\n" , !fixed); + +return 0 ; +} +static int rdt_mon_features_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) {
@@ -1975,6 +1991,13 @@ static struct rftype res_common_files[] = { .seq_show = rdt_last_cmd_status_show, .fflags = RFTYPE_TOP_INFO, }, + { + .name = "moveable_mon_group", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdt_moveable_mon_group_show, + .fflags = RFTYPE_TOP_INFO, + }, { .name = "mbm_assign_on_mkdir", .mode = 0644,
Signature · 1 line
2.43.0