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>
Tue, 1 Oct 2024 18:13:03 +0000 (20:13 +0200)
commitbf9345ffed1b8c6e52027aa5dc8782afb04d1ca8
tree381dd80934f12ef43f6e8e11da414a5782bde685
parent11e74153bd616bacdce2d2c19758981b68e4f064
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