lscpu: optimize query virt pci device
authorGuixin Liu <kanie@linux.alibaba.com>
Wed, 21 Aug 2024 08:49:54 +0000 (16:49 +0800)
committerChris Hofstaedtler <zeha@debian.org>
Mon, 9 Sep 2024 21:20:25 +0000 (23:20 +0200)
commite96a9010c133f55654f9e3b5949c982982f93cde
treee685dbf252ecf2be6edaf24870ac92ad1aa70589
parent0fcc9443cd979ceebb4eba236c2e6424b5c2ceb7
lscpu: optimize query virt pci device

The lscpu command needs to traverse the /proc/bus/pci/devices file
three times to check for any PCI devices related to virtualization.
If there are many PCI devices on the machine, this can lead to
increased execution time for lscpu. It would be beneficial to
consolidate these queries into a single check to optimize the
execution time of lscpu.

Use time command to test on a machine with 13000 PCI devices:
before:
real  0m13.506s
user  0m0.028s
sys   0m13.409s
after:
real  0m5.834s
user  0m0.018s
sys   0m5.771s

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Gbp-Pq: Topic upstream-master
Gbp-Pq: Name lscpu-optimize-query-virt-pci-device.patch
sys-utils/lscpu-virt.c