[PATCH v22 15/20] tests/avocado: s390x cpu topology polarization

Nina Schoetterl-Glausch posted 20 patches 2 years, 5 months ago
Maintainers: Nina Schoetterl-Glausch <nsg@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Cleber Rosa <crosa@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>
There is a newer version of this series
[PATCH v22 15/20] tests/avocado: s390x cpu topology polarization
Posted by Nina Schoetterl-Glausch 2 years, 5 months ago
From: Pierre Morel <pmorel@linux.ibm.com>

Polarization is changed on a request from the guest.
Let's verify the polarization is accordingly set by QEMU.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
---
 tests/avocado/s390_topology.py | 45 ++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py
index 3a54fe2e00..d7ee36cb89 100644
--- a/tests/avocado/s390_topology.py
+++ b/tests/avocado/s390_topology.py
@@ -41,6 +41,7 @@ class S390CPUTopology(QemuSystemTest):
     The polarization is changed on a request from the guest.
     """
     timeout = 90
+    event_timeout = 10
 
     KERNEL_COMMON_COMMAND_LINE = ('printk.time=0 '
                                   'root=/dev/ram '
@@ -103,6 +104,14 @@ def kernel_init(self):
                          '-initrd', initrd_path,
                          '-append', kernel_command_line)
 
+    def system_init(self):
+        self.log.info("System init")
+        exec_command_and_wait_for_pattern(self,
+                """ mount proc -t proc /proc;
+                    mount sys -t sysfs /sys;
+                    /bin/cat /sys/devices/system/cpu/dispatching """,
+                    '0')
+
     def test_single(self):
         """
         This test checks the simplest topology with a single CPU.
@@ -198,3 +207,39 @@ def test_hotplug_full(self):
         self.check_topology(3, 1, 1, 1, 'high', False)
         self.check_topology(4, 1, 1, 1, 'medium', False)
         self.check_topology(5, 2, 1, 1, 'high', True)
+
+
+    def guest_set_dispatching(self, dispatching):
+        exec_command(self,
+                f'echo {dispatching} > /sys/devices/system/cpu/dispatching')
+        self.vm.event_wait('CPU_POLARIZATION_CHANGE', self.event_timeout)
+        exec_command_and_wait_for_pattern(self,
+                '/bin/cat /sys/devices/system/cpu/dispatching', dispatching)
+
+
+    def test_polarization(self):
+        """
+        This test verifies that QEMU modifies the entitlement change after
+        several guest polarization change requests.
+
+        :avocado: tags=arch:s390x
+        :avocado: tags=machine:s390-ccw-virtio
+        """
+        self.kernel_init()
+        self.vm.launch()
+        self.wait_until_booted()
+
+        self.system_init()
+        res = self.vm.qmp('query-s390x-cpu-polarization')
+        self.assertEqual(res['return']['polarization'], 'horizontal')
+        self.check_topology(0, 0, 0, 0, 'medium', False)
+
+        self.guest_set_dispatching('1');
+        res = self.vm.qmp('query-s390x-cpu-polarization')
+        self.assertEqual(res['return']['polarization'], 'vertical')
+        self.check_topology(0, 0, 0, 0, 'medium', False)
+
+        self.guest_set_dispatching('0');
+        res = self.vm.qmp('query-s390x-cpu-polarization')
+        self.assertEqual(res['return']['polarization'], 'horizontal')
+        self.check_topology(0, 0, 0, 0, 'medium', False)
-- 
2.39.2
Re: [PATCH v22 15/20] tests/avocado: s390x cpu topology polarization
Posted by Thomas Huth 2 years, 5 months ago
On 01/09/2023 17.58, Nina Schoetterl-Glausch wrote:
> From: Pierre Morel <pmorel@linux.ibm.com>
> 
> Polarization is changed on a request from the guest.
> Let's verify the polarization is accordingly set by QEMU.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
>   tests/avocado/s390_topology.py | 45 ++++++++++++++++++++++++++++++++++
>   1 file changed, 45 insertions(+)
> 
> diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py
> index 3a54fe2e00..d7ee36cb89 100644
> --- a/tests/avocado/s390_topology.py
> +++ b/tests/avocado/s390_topology.py
> @@ -41,6 +41,7 @@ class S390CPUTopology(QemuSystemTest):
>       The polarization is changed on a request from the guest.
>       """
>       timeout = 90
> +    event_timeout = 10
>   
>       KERNEL_COMMON_COMMAND_LINE = ('printk.time=0 '
>                                     'root=/dev/ram '
> @@ -103,6 +104,14 @@ def kernel_init(self):
>                            '-initrd', initrd_path,
>                            '-append', kernel_command_line)
>   
> +    def system_init(self):
> +        self.log.info("System init")
> +        exec_command_and_wait_for_pattern(self,
> +                """ mount proc -t proc /proc;
> +                    mount sys -t sysfs /sys;
> +                    /bin/cat /sys/devices/system/cpu/dispatching """,

Is the /bin/ prefix really required here?

> +                    '0')
> +
>       def test_single(self):
>           """
>           This test checks the simplest topology with a single CPU.
> @@ -198,3 +207,39 @@ def test_hotplug_full(self):
>           self.check_topology(3, 1, 1, 1, 'high', False)
>           self.check_topology(4, 1, 1, 1, 'medium', False)
>           self.check_topology(5, 2, 1, 1, 'high', True)
> +
> +
> +    def guest_set_dispatching(self, dispatching):
> +        exec_command(self,
> +                f'echo {dispatching} > /sys/devices/system/cpu/dispatching')
> +        self.vm.event_wait('CPU_POLARIZATION_CHANGE', self.event_timeout)
> +        exec_command_and_wait_for_pattern(self,
> +                '/bin/cat /sys/devices/system/cpu/dispatching', dispatching)

dito?

> +
> +    def test_polarization(self):
> +        """
> +        This test verifies that QEMU modifies the entitlement change after
> +        several guest polarization change requests.
> +
> +        :avocado: tags=arch:s390x
> +        :avocado: tags=machine:s390-ccw-virtio
> +        """
> +        self.kernel_init()
> +        self.vm.launch()
> +        self.wait_until_booted()
> +
> +        self.system_init()
> +        res = self.vm.qmp('query-s390x-cpu-polarization')
> +        self.assertEqual(res['return']['polarization'], 'horizontal')
> +        self.check_topology(0, 0, 0, 0, 'medium', False)
> +
> +        self.guest_set_dispatching('1');
> +        res = self.vm.qmp('query-s390x-cpu-polarization')
> +        self.assertEqual(res['return']['polarization'], 'vertical')
> +        self.check_topology(0, 0, 0, 0, 'medium', False)
> +
> +        self.guest_set_dispatching('0');
> +        res = self.vm.qmp('query-s390x-cpu-polarization')
> +        self.assertEqual(res['return']['polarization'], 'horizontal')
> +        self.check_topology(0, 0, 0, 0, 'medium', False)

Anyway:
Reviewed-by: Thomas Huth <thuth@redhat.com>
Re: [PATCH v22 15/20] tests/avocado: s390x cpu topology polarization
Posted by Nina Schoetterl-Glausch 2 years, 5 months ago
On Thu, 2023-09-07 at 11:02 +0200, Thomas Huth wrote:
> On 01/09/2023 17.58, Nina Schoetterl-Glausch wrote:
> > From: Pierre Morel <pmorel@linux.ibm.com>
> > 
> > Polarization is changed on a request from the guest.
> > Let's verify the polarization is accordingly set by QEMU.
> > 
> > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> > Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > ---
> >   tests/avocado/s390_topology.py | 45 ++++++++++++++++++++++++++++++++++
> >   1 file changed, 45 insertions(+)
> > 
> > diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py
> > index 3a54fe2e00..d7ee36cb89 100644
> > --- a/tests/avocado/s390_topology.py
> > +++ b/tests/avocado/s390_topology.py
> > @@ -41,6 +41,7 @@ class S390CPUTopology(QemuSystemTest):
> >       The polarization is changed on a request from the guest.
> >       """
> >       timeout = 90
> > +    event_timeout = 10
> >   
> >       KERNEL_COMMON_COMMAND_LINE = ('printk.time=0 '
> >                                     'root=/dev/ram '
> > @@ -103,6 +104,14 @@ def kernel_init(self):
> >                            '-initrd', initrd_path,
> >                            '-append', kernel_command_line)
> >   
> > +    def system_init(self):
> > +        self.log.info("System init")
> > +        exec_command_and_wait_for_pattern(self,
> > +                """ mount proc -t proc /proc;
> > +                    mount sys -t sysfs /sys;
> > +                    /bin/cat /sys/devices/system/cpu/dispatching """,
> 
> Is the /bin/ prefix really required here?

No, /bin is a symlink to /usr/bin and that's in PATH.
Not sure why Pierre did it this way, might be a remnant of some other
vm image/initrd.
I'll remove it.

> 
> > +                    '0')
> > +
> >       def test_single(self):
> >           """
> >           This test checks the simplest topology with a single CPU.
> > @@ -198,3 +207,39 @@ def test_hotplug_full(self):
> >           self.check_topology(3, 1, 1, 1, 'high', False)
> >           self.check_topology(4, 1, 1, 1, 'medium', False)
> >           self.check_topology(5, 2, 1, 1, 'high', True)
> > +
> > +
> > +    def guest_set_dispatching(self, dispatching):
> > +        exec_command(self,
> > +                f'echo {dispatching} > /sys/devices/system/cpu/dispatching')
> > +        self.vm.event_wait('CPU_POLARIZATION_CHANGE', self.event_timeout)
> > +        exec_command_and_wait_for_pattern(self,
> > +                '/bin/cat /sys/devices/system/cpu/dispatching', dispatching)
> 
> dito?
> 
> > +
> > +    def test_polarization(self):
> > +        """
> > +        This test verifies that QEMU modifies the entitlement change after
> > +        several guest polarization change requests.
> > +
> > +        :avocado: tags=arch:s390x
> > +        :avocado: tags=machine:s390-ccw-virtio
> > +        """
> > +        self.kernel_init()
> > +        self.vm.launch()
> > +        self.wait_until_booted()
> > +
> > +        self.system_init()
> > +        res = self.vm.qmp('query-s390x-cpu-polarization')
> > +        self.assertEqual(res['return']['polarization'], 'horizontal')
> > +        self.check_topology(0, 0, 0, 0, 'medium', False)
> > +
> > +        self.guest_set_dispatching('1');
> > +        res = self.vm.qmp('query-s390x-cpu-polarization')
> > +        self.assertEqual(res['return']['polarization'], 'vertical')
> > +        self.check_topology(0, 0, 0, 0, 'medium', False)
> > +
> > +        self.guest_set_dispatching('0');
> > +        res = self.vm.qmp('query-s390x-cpu-polarization')
> > +        self.assertEqual(res['return']['polarization'], 'horizontal')
> > +        self.check_topology(0, 0, 0, 0, 'medium', False)
> 
> Anyway:
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Thanks!
Re: [PATCH v22 15/20] tests/avocado: s390x cpu topology polarization
Posted by Nina Schoetterl-Glausch 2 years, 5 months ago
On Fri, 2023-09-01 at 17:58 +0200, Nina Schoetterl-Glausch wrote:
> From: Pierre Morel <pmorel@linux.ibm.com>
> 
> Polarization is changed on a request from the guest.
> Let's verify the polarization is accordingly set by QEMU.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>