linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.28k stars 999 forks source link

ltp_tpci: testcase 12 related to virtio releasing and reassigning resource leads to guest hung #1061

Open juexinformac opened 10 months ago

juexinformac commented 10 months ago

ENV: kernel 6.0.7-301.fc37.x86_64, qemu-7.0.0-9.fc37 VM: virsh xml: machine='pc-i440fx-6.2'

<os>
    <type arch='x86_64' machine='pc-i440fx-6.2'>hvm</type>
    <boot dev='hd'/>
</os>
<devices>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' iothread='1'/>
      <source file='replace your vm image path'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>
......

I executed the testcase in the virtualization environment of fedora37 qemu 7.0 (I440FX): ./runltp -f kernel_misc -s tpci after run the testcase 12, leads to guest hung(io hung), the test releases virtio device resource and then reassign. [ 59.043221][ T2431] ltp_tpci: test-case 12 [ 59.043845][ T2431] ltp_tpci: assign resources [ 59.044499][ T2431] ltp_tpci: assign resource #0 [ 59.045176][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 262401, start 0xc000, end 0xc07f [ 59.046456][ T2431] ltp_tpci: assign resource #1 [ 59.047112][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 262656, start 0xfebd3000, end 0xfebd3fff [ 59.048517][ T2431] ltp_tpci: assign resource #2 [ 59.049369][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 0, start 0x0, end 0x0 [ 59.050593][ T2431] ltp_tpci: assign resource #3 [ 59.051316][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 0, start 0x0, end 0x0 [ 59.052413][ T2431] ltp_tpci: assign resource #4 [ 59.053103][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 1319436, start 0xfe008000, end 0xfe00bfff [ 59.054522][ T2431] virtio-pci 0000:00:06.0: BAR 4: releasing [mem 0xfe008000-0xfe00bfff 64bit pref] [ 59.087851][ T2431] virtio-pci 0000:00:06.0: BAR 4: assigned [mem 0x440008000-0x44000bfff 64bit pref] [ 59.090712][ T2431] ltp_tpci: assign resource to '4', ret '0' [ 59.091576][ T2431] ltp_tpci: assign resource #5 [ 59.092315][ T2431] ltp_tpci: name = (null), flags = 0, start 0x0, end 0x0 [ 59.093312][ T2431] ltp_tpci: assign resource #6 [ 59.094047][ T2431] ltp_tpci: name = 0000:00:06.0, flags = 0, start 0x0, end 0x0

virtio-pci BAR 4: before test: virtio-pci 0000:00:06.0: BAR 4: releasing [mem 0xfe008000-0xfe00bfff 64bit pref] after test: virtio-pci 0000:00:06.0: BAR 4: assigned [mem 0x440008000-0x44000bfff 64bit pref]

https://lists.linux.it/pipermail/ltp/2021-June/023296.html I found that someone had reported a similar problem to me before [https://lists.linux.it/pipermail/ltp/2021-June/023296.html] The modified method of react is:If I use this modification method it can pass

 .../device-drivers/pci/tpci_kernel/ltp_tpci.c     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
index f2d4a4ba497c..41462d4ead6d 100644
--- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
+++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
@@ -108,8 +108,9 @@ static int probe_pci_dev(unsigned int bus, unsigned int slot)
    if (!dev || !dev->driver)
        return -ENODEV;

-   prk_info("found pci_dev '%s', bus %u, devfn %u",
-       pci_name(dev), bus, slot);
+   prk_info("found pci_dev '%s', driver '%s', bus %u, devfn %u",
+       pci_name(dev), (dev->driver) ? dev->driver->name : "",
+       bus, slot);

    ltp_pci.dev = dev;
    ltp_pci.bus = dev->bus;
@@ -444,7 +445,15 @@ static int test_assign_resources(void)
            r->flags & IORESOURCE_PREFETCH) {
            ret = pci_assign_resource(dev, i);
            prk_info("assign resource to '%d', ret '%d'", i, ret);
-           rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+           if (dev->driver && !strncmp(dev->driver->name, "virtio-pci",
+                           strlen("virtio-pci"))) {
+               if (ret < 0 && ret != -EBUSY && ret != -ENOMEM)
+                   rc |= TFAIL;
+               else
+                   rc |= TPASS;
+           } else {
+               rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+           }
        }
    }

But the modification method of the ltp community is: [https://github.com/linux-test-project/ltp/commit/d631e9caef6818cffae6e028191787efcf65b3da] https://github.com/linux-test-project/ltp/blame/master/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c#L445-L446

Can you tell me whether the use of i440fx by vm is caused by the problem of ltp use cases? Looking forward to your reply

bigclouds commented 10 months ago

I think this test is wrong.
The prerequirement of the test is that bar can not change. in reality that can not be done.