From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] platform/x86/intel-uncore-freq: Fix deadlock when removing attributes
Date: Thu, 26 Nov 2026 01:56:25 +0200 (EET) [thread overview]
Message-ID: <4ff9e62f-db67-6eb5-94e1-8d8e36a2756e@linux.intel.com> (raw)
In-Reply-To: <20261115014948.2517688-3-srinivas.pandruvada@linux.intel.com>
On Sat, 14 Nov 2026, Srinivas Pandruvada wrote:
> uncore_freq_remove_die_entry() holds uncore_lock while removing the
> attribute group of an entry. Removing attributes waits for active sysfs
> callbacks of these attributes to finish. But the show and store callbacks
> take uncore_lock, which results in an ABBA deadlock:
>
> CPU0 CPU1
> ---- ----
> kernfs_fop_read_iter()
> show_attr() uncore_freq_remove_die_entry()
> mutex_lock(&uncore_lock)
> mutex_lock(&uncore_lock) delete_attr_group()
> sysfs_remove_group()
> waits for CPU0
>
> Mark the entry as not valid with an invalid control CPU under
> uncore_lock, and remove the attribute group after releasing it. Free
> the seqnum_id after the attribute group is removed, so that the name
> can't be used by a new entry while the old attributes still exist.
>
> Adding and removing the same entry is serialized by the callers: CPU
> hotplug callbacks in the MSR based driver, and device probe and remove
> in the TPMI driver. Callbacks running before the attributes are removed
> are safe: the MSR based driver returns -ENXIO for an invalid control CPU,
> and the TPMI driver MMIO is unmapped only after the device is removed.
>
> Fixes: ae7b2ce57851 ("platform/x86/intel/uncore-freq: Use sysfs API to create attributes")
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> .../uncore-frequency-common.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> index 6051aa040abf..22019099a857 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> @@ -313,17 +313,24 @@ void uncore_freq_remove_die_entry(struct uncore_data *data)
> {
> mutex_lock(&uncore_lock);
> /* Nothing to remove, if the entry was not added or already removed */
> - if (!data->valid)
> - goto uncore_unlock;
> + if (!data->valid) {
> + mutex_unlock(&uncore_lock);
> + return;
> + }
>
> - delete_attr_group(data, data->name);
> data->control_cpu = -1;
> data->valid = false;
> + mutex_unlock(&uncore_lock);
Please redo with scoped_guard() to avoid having to split unlock.
> +
> + /*
> + * Removing the attributes waits for active sysfs callbacks, which take
> + * uncore_lock. So this can't be done while holding uncore_lock.
> + */
> + delete_attr_group(data, data->name);
> +
> + /* Free the ID after the attributes with the name using it are removed */
> if (data->domain_id != UNCORE_DOMAIN_ID_INVALID)
> ida_free(&intel_uncore_ida, data->seqnum_id);
> -
> -uncore_unlock:
> - mutex_unlock(&uncore_lock);
> }
> EXPORT_SYMBOL_NS_GPL(uncore_freq_remove_die_entry, "INTEL_UNCORE_FREQUENCY");
>
>
--
i.
next prev parent reply other threads:[~2026-11-25 23:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 1:49 [PATCH 0/2] platform/x86/intel-uncore-freq: Fix error handling Srinivas Pandruvada
2026-11-15 1:49 ` [PATCH 1/2] platform/x86/intel-uncore-freq: Don't remove entries which are not added Srinivas Pandruvada
2026-11-15 1:49 ` [PATCH 2/2] platform/x86/intel-uncore-freq: Fix deadlock when removing attributes Srinivas Pandruvada
2026-11-25 23:56 ` Ilpo Järvinen [this message]
2026-11-16 17:11 ` [PATCH 0/2] platform/x86/intel-uncore-freq: Fix error handling Arnav Kapoor
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=4ff9e62f-db67-6eb5-94e1-8d8e36a2756e@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.