[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250507090407.2146324-1-kerayhuang@tencent.com>
Date: Wed, 7 May 2025 17:04:07 +0800
From: Zijiang Huang <huangzjsmile@...il.com>
To: lukas@...ner.de
Cc: bhelgaas@...gle.com,
flyingpeng@...cent.com,
huangzjsmile@...il.com,
kerayhuang@...cent.com,
linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org,
tglx@...utronix.de
Subject: Re: [PATCH] PCI: Using lockless config space accessors based on
Hi Lukas,
I think it's safe to make this change for user-space accessors as well,
since user-space only reads from proc files.
> Why is performance of the user space accessors important?
> Perhaps because of vfio?
During stability testing on large-scale machines (384+ CPUs), we always
observed that heavy concurrent user-space access to PCI config space triggers
kernel softlockups.
Reproduction method: stress-ng --pci 384
Thanks,
keray
> That's the information I'm missing in the commit message.
>
> Thanks,
>
> Lukas
>
> > Signed-off-by: Zijiang Huang <kerayhuang@...cent.com>
> > Reviewed-by: Hao Peng <flyingpeng@...cent.com>
> > ---
> > drivers/pci/access.c | 12 +++++++-----
> > 1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> > index 3c230ca3d..5200f7bbc 100644
> > --- a/drivers/pci/access.c
> > +++ b/drivers/pci/access.c
> > @@ -216,20 +216,21 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
> > }
> >
> > /* Returns 0 on success, negative values indicate error. */
> > -#define PCI_USER_READ_CONFIG(size, type) \
> > +#define PCI_USER_READ_CONFIG(size, type) \
> > int pci_user_read_config_##size \
> > (struct pci_dev *dev, int pos, type *val) \
> > { \
> > int ret = PCIBIOS_SUCCESSFUL; \
> > u32 data = -1; \
> > + unsigned long flags; \
> > if (PCI_##size##_BAD) \
> > return -EINVAL; \
> > - raw_spin_lock_irq(&pci_lock); \
> > + pci_lock_config(flags); \
> > if (unlikely(dev->block_cfg_access)) \
> > pci_wait_cfg(dev); \
> > ret = dev->bus->ops->read(dev->bus, dev->devfn, \
> > pos, sizeof(type), &data); \
> > - raw_spin_unlock_irq(&pci_lock); \
> > + pci_unlock_config(flags); \
> > if (ret) \
> > PCI_SET_ERROR_RESPONSE(val); \
> > else \
> > @@ -244,14 +245,15 @@ int pci_user_write_config_##size \
> > (struct pci_dev *dev, int pos, type val) \
> > { \
> > int ret = PCIBIOS_SUCCESSFUL; \
> > + unsigned long flags; \
> > if (PCI_##size##_BAD) \
> > return -EINVAL; \
> > - raw_spin_lock_irq(&pci_lock); \
> > + pci_lock_config(flags); \
> > if (unlikely(dev->block_cfg_access)) \
> > pci_wait_cfg(dev); \
> > ret = dev->bus->ops->write(dev->bus, dev->devfn, \
> > pos, sizeof(type), val); \
> > - raw_spin_unlock_irq(&pci_lock); \
> > + pci_unlock_config(flags); \
> > return pcibios_err_to_errno(ret); \
> > } \
> > EXPORT_SYMBOL_GPL(pci_user_write_config_##size);
> > --
> > 2.43.5
Powered by blists - more mailing lists