* [PATCH v2] pci: call cond_resched() after pci bus config writing
@ 2021-10-15 2:40 menglong8.dong
2021-10-15 11:06 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: menglong8.dong @ 2021-10-15 2:40 UTC (permalink / raw)
To: helgaas; +Cc: bhelgaas, linux-pci, linux-kernel, Menglong Dong
From: Menglong Dong <imagedong@tencent.com>
While the system is running in KVM, pci config writing for virtio devices
may cost long time (about 1-2ms), as it causes VM-exit. During
__pci_bus_assign_resources(), pci_setup_bridge(), which can write pci
config up to 10 times, can be called many times without any
cond_resched(). So __pci_bus_assign_resources() can cause 25+ms
scheduling latency with !CONFIG_PREEMPT.
To solve this problem, call cond_resched() after pci config writing.
Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
v2:
- use cond_resched() instead of _cond_resched()
---
drivers/pci/access.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 46935695cfb9..4c52a50f2c46 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -57,6 +57,7 @@ int noinline pci_bus_write_config_##size \
pci_lock_config(flags); \
res = bus->ops->write(bus, devfn, pos, len, value); \
pci_unlock_config(flags); \
+ cond_resched(); \
return res; \
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] pci: call cond_resched() after pci bus config writing
2021-10-15 2:40 [PATCH v2] pci: call cond_resched() after pci bus config writing menglong8.dong
@ 2021-10-15 11:06 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2021-10-15 11:06 UTC (permalink / raw)
To: menglong8.dong; +Cc: bhelgaas, linux-pci, linux-kernel, Menglong Dong
On Fri, Oct 15, 2021 at 10:40:25AM +0800, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
>
> While the system is running in KVM, pci config writing for virtio devices
> may cost long time (about 1-2ms), as it causes VM-exit. During
> __pci_bus_assign_resources(), pci_setup_bridge(), which can write pci
> config up to 10 times, can be called many times without any
> cond_resched(). So __pci_bus_assign_resources() can cause 25+ms
> scheduling latency with !CONFIG_PREEMPT.
>
> To solve this problem, call cond_resched() after pci config writing.
See https://lore.kernel.org/r/20211013190014.GA1909934@bhelgaas
for comments about subject line, s/pci/PCI/, line length, etc.
> Signed-off-by: Menglong Dong <imagedong@tencent.com>
> ---
> v2:
> - use cond_resched() instead of _cond_resched()
> ---
> drivers/pci/access.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index 46935695cfb9..4c52a50f2c46 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -57,6 +57,7 @@ int noinline pci_bus_write_config_##size \
> pci_lock_config(flags); \
> res = bus->ops->write(bus, devfn, pos, len, value); \
> pci_unlock_config(flags); \
> + cond_resched(); \
> return res; \
> }
>
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-15 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-15 2:40 [PATCH v2] pci: call cond_resched() after pci bus config writing menglong8.dong
2021-10-15 11:06 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).