lkml.org 
[lkml]   [2021]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] pci: call cond_resched() after pci bus config writing
Date
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
\
 
 \ /
  Last update: 2021-10-15 04:41    [W:0.046 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site