lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200824052025.48362-1-benbjiang@tencent.com>
Date:   Mon, 24 Aug 2020 13:20:25 +0800
From:   Jiang Biao <benbjiang@...il.com>
To:     bhelgaas@...gle.com
Cc:     linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jiang Biao <benbjiang@...cent.com>,
        Bin Lai <robinlai@...cent.com>
Subject: [PATCH] driver/pci: reduce the single block time in pci_read_config

From: Jiang Biao <benbjiang@...cent.com>

pci_read_config() could block several ms in kernel space, mainly
caused by the while loop to call pci_user_read_config_dword().
Singel pci_user_read_config_dword() loop could consume 130us+,
              |    pci_user_read_config_dword() {
              |      _raw_spin_lock_irq() {
! 136.698 us  |        native_queued_spin_lock_slowpath();
! 137.582 us  |      }
              |      pci_read() {
              |        raw_pci_read() {
              |          pci_conf1_read() {
  0.230 us    |            _raw_spin_lock_irqsave();
  0.035 us    |            _raw_spin_unlock_irqrestore();
  8.476 us    |          }
  8.790 us    |        }
  9.091 us    |      }
! 147.263 us  |    }
and dozens of the loop could consume ms+.

If we execute some lspci commands concurrently, ms+ scheduling
latency could be detected.

Add scheduling chance in the loop to improve the latency.

Reported-by: Bin Lai <robinlai@...cent.com>
Signed-off-by: Jiang Biao <benbjiang@...cent.com>
---
 drivers/pci/pci-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6d78df9..3b9f63d 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -708,6 +708,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
 		data[off - init_off + 3] = (val >> 24) & 0xff;
 		off += 4;
 		size -= 4;
+		cond_resched();
 	}
 
 	if (size >= 2) {
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ