qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390x/pv: Retry ioctls on -EINTR
@ 2020-03-27  9:43 Christian Borntraeger
  2020-03-27  9:49 ` David Hildenbrand
  2020-03-27  9:49 ` Janosch Frank
  0 siblings, 2 replies; 7+ messages in thread
From: Christian Borntraeger @ 2020-03-27  9:43 UTC (permalink / raw)
  To: qemu-devel, Cornelia Huck
  Cc: Janosch Frank, David Hildenbrand, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Marc Hartmayer,
	Richard Henderson

PV_ENABLE (and maybe others) might return -EINTR when a signal is
pending. Let us retry the ioctl in that case.

Fixes: 4d226deafc44 ("s390x: protvirt: Support unpack facility")
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/s390x/pv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 8cf5cd2c9b..2758b02c96 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -23,7 +23,11 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
         .cmd = cmd,
         .data = (uint64_t)data,
     };
-    int rc = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
+    int rc;
+
+    do {
+        rc  = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
+    } while (rc == -EINTR);
 
     if (rc) {
         error_report("KVM PV command %d (%s) failed: header rc %x rrc %x "
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:43 [PATCH] s390x/pv: Retry ioctls on -EINTR Christian Borntraeger
@ 2020-03-27  9:49 ` David Hildenbrand
  2020-03-27  9:54   ` Christian Borntraeger
  2020-03-27  9:49 ` Janosch Frank
  1 sibling, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2020-03-27  9:49 UTC (permalink / raw)
  To: Christian Borntraeger, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Marc Hartmayer, Janosch Frank,
	Richard Henderson

On 27.03.20 10:43, Christian Borntraeger wrote:
> PV_ENABLE (and maybe others) might return -EINTR when a signal is
> pending. Let us retry the ioctl in that case.
> 
> Fixes: 4d226deafc44 ("s390x: protvirt: Support unpack facility")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  hw/s390x/pv.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
> index 8cf5cd2c9b..2758b02c96 100644
> --- a/hw/s390x/pv.c
> +++ b/hw/s390x/pv.c
> @@ -23,7 +23,11 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
>          .cmd = cmd,
>          .data = (uint64_t)data,
>      };
> -    int rc = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
> +    int rc;
> +
> +    do {
> +        rc  = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
> +    } while (rc == -EINTR);
>  
>      if (rc) {
>          error_report("KVM PV command %d (%s) failed: header rc %x rrc %x "
> 

I fail to see where that is triggered in the kernel.

t480s: ~/git/linux/arch/s390/kvm (HEAD losgelöst bei next/master) $ git
grep "EINTR"
kvm-s390.c:     if (exit_reason == -EINTR) {
kvm-s390.c:             return -EINTR;
kvm-s390.c:             rc = -EINTR;
vsie.c: if (rc == -EINTR) {


Can you help me out? Is that documented?

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:43 [PATCH] s390x/pv: Retry ioctls on -EINTR Christian Borntraeger
  2020-03-27  9:49 ` David Hildenbrand
@ 2020-03-27  9:49 ` Janosch Frank
  1 sibling, 0 replies; 7+ messages in thread
From: Janosch Frank @ 2020-03-27  9:49 UTC (permalink / raw)
  To: Christian Borntraeger, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Richard Henderson, Marc Hartmayer,
	David Hildenbrand


[-- Attachment #1.1: Type: text/plain, Size: 1215 bytes --]

On 3/27/20 10:43 AM, Christian Borntraeger wrote:
> PV_ENABLE (and maybe others) might return -EINTR when a signal is
> pending. Let us retry the ioctl in that case.
> 
> Fixes: 4d226deafc44 ("s390x: protvirt: Support unpack facility")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

Acked-by: Janosch Frank <frankja@linux.vnet.ibm.com>

> ---
>  hw/s390x/pv.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
> index 8cf5cd2c9b..2758b02c96 100644
> --- a/hw/s390x/pv.c
> +++ b/hw/s390x/pv.c
> @@ -23,7 +23,11 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
>          .cmd = cmd,
>          .data = (uint64_t)data,
>      };
> -    int rc = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
> +    int rc;
> +
> +    do {
> +        rc  = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);

Double whitespace after rc.

> +    } while (rc == -EINTR);
>  
>      if (rc) {
>          error_report("KVM PV command %d (%s) failed: header rc %x rrc %x "
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:49 ` David Hildenbrand
@ 2020-03-27  9:54   ` Christian Borntraeger
  2020-03-27  9:56     ` David Hildenbrand
  2020-03-27  9:58     ` Christian Borntraeger
  0 siblings, 2 replies; 7+ messages in thread
From: Christian Borntraeger @ 2020-03-27  9:54 UTC (permalink / raw)
  To: David Hildenbrand, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Marc Hartmayer, Janosch Frank,
	Richard Henderson



On 27.03.20 10:49, David Hildenbrand wrote:
> On 27.03.20 10:43, Christian Borntraeger wrote:
>> PV_ENABLE (and maybe others) might return -EINTR when a signal is
>> pending. Let us retry the ioctl in that case.
>>
>> Fixes: 4d226deafc44 ("s390x: protvirt: Support unpack facility")
>> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
>> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> ---
>>  hw/s390x/pv.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
>> index 8cf5cd2c9b..2758b02c96 100644
>> --- a/hw/s390x/pv.c
>> +++ b/hw/s390x/pv.c
>> @@ -23,7 +23,11 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
>>          .cmd = cmd,
>>          .data = (uint64_t)data,
>>      };
>> -    int rc = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
>> +    int rc;
>> +
>> +    do {
>> +        rc  = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
>> +    } while (rc == -EINTR);
>>  
>>      if (rc) {
>>          error_report("KVM PV command %d (%s) failed: header rc %x rrc %x "
>>
> 
> I fail to see where that is triggered in the kernel.
> 
> t480s: ~/git/linux/arch/s390/kvm (HEAD losgelöst bei next/master) $ git
> grep "EINTR"
> kvm-s390.c:     if (exit_reason == -EINTR) {
> kvm-s390.c:             return -EINTR;
> kvm-s390.c:             rc = -EINTR;
> vsie.c: if (rc == -EINTR) {
> 
> 
> Can you help me out? Is that documented?

It is related to the kernel patch.
ksm_madvise->unmerge_ksm_pages has

                if (signal_pending(current))
                        err = -ERESTARTSYS;


entry.S will retranslate ERESTARTSYS into -EINTR. 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:54   ` Christian Borntraeger
@ 2020-03-27  9:56     ` David Hildenbrand
  2020-03-27  9:58     ` Christian Borntraeger
  1 sibling, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-03-27  9:56 UTC (permalink / raw)
  To: Christian Borntraeger, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Marc Hartmayer, Janosch Frank,
	Richard Henderson

On 27.03.20 10:54, Christian Borntraeger wrote:
> 
> 
> On 27.03.20 10:49, David Hildenbrand wrote:
>> On 27.03.20 10:43, Christian Borntraeger wrote:
>>> PV_ENABLE (and maybe others) might return -EINTR when a signal is
>>> pending. Let us retry the ioctl in that case.
>>>
>>> Fixes: 4d226deafc44 ("s390x: protvirt: Support unpack facility")
>>> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
>>> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
>>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>> ---
>>>  hw/s390x/pv.c | 6 +++++-
>>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
>>> index 8cf5cd2c9b..2758b02c96 100644
>>> --- a/hw/s390x/pv.c
>>> +++ b/hw/s390x/pv.c
>>> @@ -23,7 +23,11 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
>>>          .cmd = cmd,
>>>          .data = (uint64_t)data,
>>>      };
>>> -    int rc = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
>>> +    int rc;
>>> +
>>> +    do {
>>> +        rc  = kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd);
>>> +    } while (rc == -EINTR);
>>>  
>>>      if (rc) {
>>>          error_report("KVM PV command %d (%s) failed: header rc %x rrc %x "
>>>
>>
>> I fail to see where that is triggered in the kernel.
>>
>> t480s: ~/git/linux/arch/s390/kvm (HEAD losgelöst bei next/master) $ git
>> grep "EINTR"
>> kvm-s390.c:     if (exit_reason == -EINTR) {
>> kvm-s390.c:             return -EINTR;
>> kvm-s390.c:             rc = -EINTR;
>> vsie.c: if (rc == -EINTR) {
>>
>>
>> Can you help me out? Is that documented?
> 
> It is related to the kernel patch.
> ksm_madvise->unmerge_ksm_pages has
> 
>                 if (signal_pending(current))
>                         err = -ERESTARTSYS;
> 
> 
> entry.S will retranslate ERESTARTSYS into -EINTR. 

That's valuable information that should go into the patch description.
Also, the documentation should be updated to reflect this. Not obvious :)


-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:54   ` Christian Borntraeger
  2020-03-27  9:56     ` David Hildenbrand
@ 2020-03-27  9:58     ` Christian Borntraeger
  2020-03-27 10:01       ` David Hildenbrand
  1 sibling, 1 reply; 7+ messages in thread
From: Christian Borntraeger @ 2020-03-27  9:58 UTC (permalink / raw)
  To: David Hildenbrand, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Marc Hartmayer, Janosch Frank,
	Richard Henderson

>> I fail to see where that is triggered in the kernel.
>>
>> t480s: ~/git/linux/arch/s390/kvm (HEAD losgelöst bei next/master) $ git
>> grep "EINTR"
>> kvm-s390.c:     if (exit_reason == -EINTR) {
>> kvm-s390.c:             return -EINTR;
>> kvm-s390.c:             rc = -EINTR;
>> vsie.c: if (rc == -EINTR) {
>>
>>
>> Can you help me out? Is that documented?
> 
> It is related to the kernel patch.
> ksm_madvise->unmerge_ksm_pages has
> 
>                 if (signal_pending(current))
>                         err = -ERESTARTSYS;
> 
> 
> entry.S will retranslate ERESTARTSYS into -EINTR. 
> 

In the end both patches fixes an odd-ball case. Marc had a test running
that in parallel started guests and randomly killing QEMUs with pkill.
The QEMUs did end with 

qemu-system-s390x: KVM PV command 0 (KVM_PV_ENABLE) failed: header rc 0 rrc 0 IOCTL rc: -12

instead of

qemu-system-s390x: terminating on signal 15 from pid 26495 (pkill)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] s390x/pv: Retry ioctls on -EINTR
  2020-03-27  9:58     ` Christian Borntraeger
@ 2020-03-27 10:01       ` David Hildenbrand
  0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-03-27 10:01 UTC (permalink / raw)
  To: Christian Borntraeger, qemu-devel, Cornelia Huck
  Cc: Halil Pasic, qemu-s390x, Marc Hartmayer, Janosch Frank,
	Richard Henderson

On 27.03.20 10:58, Christian Borntraeger wrote:
>>> I fail to see where that is triggered in the kernel.
>>>
>>> t480s: ~/git/linux/arch/s390/kvm (HEAD losgelöst bei next/master) $ git
>>> grep "EINTR"
>>> kvm-s390.c:     if (exit_reason == -EINTR) {
>>> kvm-s390.c:             return -EINTR;
>>> kvm-s390.c:             rc = -EINTR;
>>> vsie.c: if (rc == -EINTR) {
>>>
>>>
>>> Can you help me out? Is that documented?
>>
>> It is related to the kernel patch.
>> ksm_madvise->unmerge_ksm_pages has
>>
>>                 if (signal_pending(current))
>>                         err = -ERESTARTSYS;
>>
>>
>> entry.S will retranslate ERESTARTSYS into -EINTR. 
>>
> 
> In the end both patches fixes an odd-ball case. Marc had a test running
> that in parallel started guests and randomly killing QEMUs with pkill.
> The QEMUs did end with 
> 
> qemu-system-s390x: KVM PV command 0 (KVM_PV_ENABLE) failed: header rc 0 rrc 0 IOCTL rc: -12
> 
> instead of
> 
> qemu-system-s390x: terminating on signal 15 from pid 26495 (pkill)
> 

I guess the same can happen with a qemu_cpu_kick(), just that the BQL
protects us from that to happen concurrently.

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-27 10:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27  9:43 [PATCH] s390x/pv: Retry ioctls on -EINTR Christian Borntraeger
2020-03-27  9:49 ` David Hildenbrand
2020-03-27  9:54   ` Christian Borntraeger
2020-03-27  9:56     ` David Hildenbrand
2020-03-27  9:58     ` Christian Borntraeger
2020-03-27 10:01       ` David Hildenbrand
2020-03-27  9:49 ` Janosch Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).