Re: [PATCH v11 18/23] fs/resctrl: Call arch code for every mount

From: Reinette Chatre

Date: Thu Sep 10 2026 - 00:08:14 EST


Hi Tony,

On 8/31/26 10:44 AM, Tony Luck wrote:
> Linux file system code provides no serialization of mount(2) system
> calls. Without such serialization calling resctrl_arch_pre_mount() on
> every mount before acquiring rdtgroup_mutex would open up many complex
> races between mount and unmount operations.
>
> Add resctrl_mount_lock to provide serialization and protect resctrl_mounted.
>
> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
> ---



> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 3ac518ed2368..7f09d76dbf8c 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -30,6 +30,9 @@
>
> #include "internal.h"
>
> +/* Mutex protecting resctrl_mounted and mount/unmount operations */

Could you please expand this to highlight that changes to resctrl_mounted should
be made with resctrl_mount_lock *and* rdtgroup_mutex held.

> +static DEFINE_MUTEX(resctrl_mount_lock);
> +
> /* Mutex to protect rdtgroup access. */
> DEFINE_MUTEX(rdtgroup_mutex);
>
> @@ -3149,6 +3152,7 @@ static void resctrl_unmount(void)
> {
> struct rdt_resource *r;
>
> + mutex_lock(&resctrl_mount_lock);
> cpus_read_lock();
> mutex_lock(&rdtgroup_mutex);
>
> @@ -3166,6 +3170,8 @@ static void resctrl_unmount(void)
> resctrl_mounted = false;
> mutex_unlock(&rdtgroup_mutex);
> cpus_read_unlock();
> + resctrl_arch_unmount();
> + mutex_unlock(&resctrl_mount_lock);
> }
>
> static int rdt_get_tree(struct fs_context *fc)
> @@ -3177,24 +3183,27 @@ static int rdt_get_tree(struct fs_context *fc)
> struct rdt_resource *r;
> int ret;
>
> - DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount);

Please note that after this series the comment above resctrl_arch_pre_mount()
in resctrl.h still reads:
"Architecture hook called at beginning of first file system mount attempt"

The sashiko reported issues look real to me.

Reinette