From: Benjamin Block <bblock@linux.ibm.com>
To: ionut.nechita@windriver.com
Cc: bhelgaas@google.com, helgaas@kernel.org, schnelle@linux.ibm.com,
alifm@linux.ibm.com, julianr@linux.ibm.com, dtatulea@nvidia.com,
ionut_n2001@yahoo.com, sunlightlinux@gmail.com,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/1] PCI/IOV: Add reentrant locking in sriov_add_vfs/sriov_del_vfs for complete serialization
Date: Thu, 26 Feb 2026 14:40:52 +0100 [thread overview]
Message-ID: <20260226134052.GA13050@p1gen4-pw042f0m> (raw)
In-Reply-To: <20260225202434.18737-2-ionut.nechita@windriver.com>
On Wed, Feb 25, 2026 at 10:24:34PM +0200, ionut.nechita@windriver.com wrote:
> From: Ionut Nechita <ionut.nechita@windriver.com>
>
--8<--
>
> Instead, introduce owner tracking for pci_rescan_remove_lock via a new
> pci_lock_rescan_remove_reentrant() helper. This function checks if the
> current task already holds the lock:
> - If the lock is not held: acquires it and returns true, providing
> full serialization against concurrent hotplug events (including
> platform-generated events on s390).
> - If the lock is already held by the current task (reentrant call from
> remove_store or sriov_numvfs_store paths): returns false without
> re-acquiring, avoiding deadlock while the caller already provides
> the necessary serialization.
> - If the lock is held by another task (concurrent hotplug): blocks
> until the lock is released, then acquires it, providing complete
> serialization. This is the key improvement over a trylock approach.
>
--8<--
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index bccc7a4bdd794..467362c277f19 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -3509,19 +3509,38 @@ EXPORT_SYMBOL_GPL(pci_rescan_bus);
> * routines should always be executed under this mutex.
> */
> DEFINE_MUTEX(pci_rescan_remove_lock);
> +static struct task_struct *pci_rescan_remove_owner;
^
const *pci_rescan_remove_owner
Minor nitpick: you could declare this `const`; making it clear that this is
not meant to be used to modify the task in any way.
> void pci_lock_rescan_remove(void)
> {
> mutex_lock(&pci_rescan_remove_lock);
> + pci_rescan_remove_owner = current;
> }
> EXPORT_SYMBOL_GPL(pci_lock_rescan_remove);
>
> void pci_unlock_rescan_remove(void)
> {
> + pci_rescan_remove_owner = NULL;
> mutex_unlock(&pci_rescan_remove_lock);
> }
> EXPORT_SYMBOL_GPL(pci_unlock_rescan_remove);
>
> +bool pci_lock_rescan_remove_reentrant(void)
> +{
> + if (pci_rescan_remove_owner == current)
> + return false;
> + pci_lock_rescan_remove();
> + return true;
> +}
> +EXPORT_SYMBOL_GPL(pci_lock_rescan_remove_reentrant);
Otherwise this looks good to me.
I've run tests on s390 with hot-unplug from within Linux and externally
triggered, driver unbind/unload, s390 PCI recovery, and some other minor
tests.
No lockdep splats, no other warnings/splats; it looks good to me.
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Tested-by: Benjamin Block <bblock@linux.ibm.com>
--
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development
IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy
Vors. Aufs.-R.: Wolfgang Wendt / Geschäftsführung: David Faller
Sitz der Ges.: Ehningen / Registergericht: AmtsG Stuttgart, HRB 243294
next prev parent reply other threads:[~2026-02-26 13:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 20:24 [PATCH v3 0/1] PCI/IOV: Add reentrant locking in sriov_add_vfs/sriov_del_vfs ionut.nechita
2026-02-25 20:24 ` [PATCH v3 1/1] PCI/IOV: Add reentrant locking in sriov_add_vfs/sriov_del_vfs for complete serialization ionut.nechita
2026-02-26 13:40 ` Benjamin Block [this message]
2026-02-26 9:36 ` [PATCH v3 0/1] PCI/IOV: Add reentrant locking in sriov_add_vfs/sriov_del_vfs Benjamin Block
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=20260226134052.GA13050@p1gen4-pw042f0m \
--to=bblock@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=dtatulea@nvidia.com \
--cc=helgaas@kernel.org \
--cc=ionut.nechita@windriver.com \
--cc=ionut_n2001@yahoo.com \
--cc=julianr@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=schnelle@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=sunlightlinux@gmail.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
all inboxes | Powered by JetHome®