From: "Luck, Tony" <tony.luck@intel.com>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: "Chen, Yu C" <yu.c.chen@intel.com>,
Borislav Petkov <bp@alien8.de>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>, <patches@lists.linux.dev>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
Fenghua Yu <fenghuay@nvidia.com>,
James Morse <james.morse@arm.com>,
Drew Fustini <dfustini@baylibre.com>,
Babu Moger <babu.moger@amd.com>,
Peter Newman <peternewman@google.com>,
Dave Martin <Dave.Martin@arm.com>
Subject: Re: [PATCH 3/4] fs/resctrl: Fix deadlock for errors during mount
Date: Wed, 13 May 2026 16:04:27 -0700 [thread overview]
Message-ID: <agUDe3PcBy2mULyw@agluck-desk3> (raw)
In-Reply-To: <6ef756c6-7c21-47a4-8173-88e1989b7d1f@intel.com>
On Wed, May 13, 2026 at 03:19:40PM -0700, Reinette Chatre wrote:
> Hi Tony,
>
> On 5/13/26 12:51 PM, Luck, Tony wrote:
> ...
> > Are we out of the woods yet? Applying these suggestions I now have:
> >
> > /* Ensure root kn remains accessible after mutex is unlocked */
> > kernfs_get(rdtgroup_default.kn);
> >
> > /*
> > * Make backup of rdtgroup_default.kn just in case one of the
> > * following flows (that sets rdtgroup_default.kn to NULL) run after
> > * the mutex is unlocked:
> > * resctrl_exit()->resctrl_fs_teardown()->rdtgroup_destroy_root()
> > * kernfs_get_tree()->deactivate_locked_super()->rdt_kill_sb()->
> > * resctrl_unmount()->resctrl_fs_teardown()->rdtgroup_destroy_root()
> > * These flows would not actually result in rdtgroup_default.kn
> > * being removed thanks to the additional reference.
> > */
> > rdt_root_kn = rdtgroup_default.kn;
> >
> > rdt_last_cmd_clear();
> > mutex_unlock(&rdtgroup_mutex);
> > cpus_read_unlock();
> >
> > ret = kernfs_get_tree(fc);
> > /*
> > * resctrl can only be mounted once, new superblock only expected
> > * to be created once.
> > */
> > if (!ctx->kfc.new_sb_created)
> > resctrl_unmount();
> >
> > resctrl_unmount() clears resctrl_mounted, so as soon locks are released
> > a new mount attempt (maybe started a while ago, but blocked waiting for
> > the mutex) can begin. I just want to confirm that won't stomp on
> > anything left over from this failed mount that was waiting for this
> > kernfs_put() to happen. I think it is OK, because the new mount is
> > going to allocate all new structures. But there's been enough layers
> > to this onion that I'd like to confirm.
> >
> > kernfs_put(rdt_root_kn);
> > return ret;
>
> I agree with your analysis. I also think it highlights a sharp corner
> that may benefit from a comment. The rdt_root_kn is intentionally a local
> variable and the comments above explain that it is needed because of some
> flows that may set rdtgroup_default.kn to NULL. Based on the existing comments
> a reader may wonder why this cannot be optimized by using kernfs_root_to_node(rdt_root)
> instead of a local variable and that would be a problem in the scenario you
> describe.
>
> Could comment changes below help to clarify the motivation for the reference
> and provide enough information to support future changes?
>
> /*
> * Ensure root kn remains accessible after mutex is unlocked so that
> * kernfs_kill_sb() can run safely if called by kernfs_get_tree()'s
> * failure path after creating a superblock but before taking reference
> * on root kn.
> */
> kernfs_get(rdtgroup_default.kn);
>
> /*
> * Make backup of the current root kn being created to be used in kernfs_put().
> * The additional reference taken above will prevent the kn from being freed
> * before kernfs_kill_sb() can run but rdtgroup_default.kn may be set to NULL
> * via rdtgroup_destroy_root() and its backing root (rdt_root) could be overwritten
> * before kernfs_put() can run.
> */
> rdt_root_kn = rdtgroup_default.kn;
> ...
Looks good. Replaced previous comments with these new ones. Thanks.
>
> Reinette
>
-Tony
next prev parent reply other threads:[~2026-05-13 23:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 18:21 [PATCH 0/4] fs/resctrl: Fix three long-standing issues Tony Luck
2026-05-08 18:21 ` [PATCH 1/4] fs/resctrl: Move functions to avoid forward references in subsequent fixes Tony Luck
2026-05-08 18:21 ` [PATCH 2/4] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
2026-05-08 21:36 ` Luck, Tony
2026-05-09 12:43 ` Chen, Yu C
2026-05-11 3:15 ` Luck, Tony
2026-05-12 1:51 ` Chen, Yu C
2026-05-08 18:21 ` [PATCH 3/4] fs/resctrl: Fix deadlock for errors during mount Tony Luck
2026-05-10 13:52 ` Chen, Yu C
2026-05-11 22:53 ` Reinette Chatre
2026-05-12 7:28 ` Chen, Yu C
2026-05-12 14:34 ` Reinette Chatre
2026-05-13 3:24 ` Chen, Yu C
2026-05-13 19:51 ` Luck, Tony
2026-05-13 22:19 ` Reinette Chatre
2026-05-13 23:04 ` Luck, Tony [this message]
2026-05-08 18:21 ` [PATCH 4/4] fs/resctrl: Fix issues with worker threads when CPUs are taken offline Tony Luck
2026-05-11 23:06 ` Reinette Chatre
2026-05-13 20:10 ` Luck, Tony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=agUDe3PcBy2mULyw@agluck-desk3 \
--to=tony.luck@intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dfustini@baylibre.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=reinette.chatre@intel.com \
--cc=x86@kernel.org \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox