linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Michael Mueller <mimu@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Pierre Morel <pmorel@linux.ibm.com>,
	Tony Krowiak <akrowiak@linux.ibm.com>,
	Niklas Schnelle <schnelle@linux.ibm.com>,
	farman@linux.ibm.com, kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: s390: clear kicked_mask before sleeping again
Date: Wed, 20 Oct 2021 07:35:15 +0200	[thread overview]
Message-ID: <20211020073515.3ad4c377@p-imbrenda> (raw)
In-Reply-To: <20211019175401.3757927-2-pasic@linux.ibm.com>

On Tue, 19 Oct 2021 19:53:59 +0200
Halil Pasic <pasic@linux.ibm.com> wrote:

> The idea behind kicked mask is that we should not re-kick a vcpu that
> is already in the "kick" process, i.e. that was kicked and is
> is about to be dispatched if certain conditions are met.
> 
> The problem with the current implementation is, that it assumes the
> kicked vcpu is going to enter SIE shortly. But under certain
> circumstances, the vcpu we just kicked will be deemed non-runnable and
> will remain in wait state. This can happen, if the interrupt(s) this
> vcpu got kicked to deal with got already cleared (because the interrupts
> got delivered to another vcpu). In this case kvm_arch_vcpu_runnable()
> would return false, and the vcpu would remain in kvm_vcpu_block(),
> but this time with its kicked_mask bit set. So next time around we
> wouldn't kick the vcpu form __airqs_kick_single_vcpu(), but would assume
> that we just kicked it.
> 
> Let us make sure the kicked_mask is cleared before we give up on
> re-dispatching the vcpu.
> 
> Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
> Reported-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Fixes: 9f30f6216378 ("KVM: s390: add gib_alert_irq_handler()")
> ---
>  arch/s390/kvm/kvm-s390.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 6a6dd5e1daf6..1c97493d21e1 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -3363,6 +3363,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
>  
>  int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
>  {
> +	clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask);

so, you unconditionally clear the flag, before knowing if the vCPU is
runnable?

from your description I would have expected to only clear the bit if
the vCPU is not runnable.

would things break if we were to try to kick the vCPU again after
clearing the bit, but before dispatching it?

>  	return kvm_s390_vcpu_has_irq(vcpu, 0);
>  }
>  


  parent reply	other threads:[~2021-10-20  5:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 17:53 [PATCH 0/3] fixes for __airqs_kick_single_vcpu() Halil Pasic
2021-10-19 17:53 ` [PATCH 1/3] KVM: s390: clear kicked_mask before sleeping again Halil Pasic
2021-10-19 21:22   ` Christian Borntraeger
2021-10-20  5:35   ` Claudio Imbrenda [this message]
2021-10-20  6:03     ` Christian Borntraeger
2021-10-20  6:08       ` Claudio Imbrenda
2021-10-20  8:14         ` Halil Pasic
2021-10-20 10:42           ` Claudio Imbrenda
2021-10-20  8:06   ` Michael Mueller
2021-10-20 10:44   ` Claudio Imbrenda
2021-10-19 17:54 ` [PATCH 2/3] KVM: s390: preserve deliverable_mask in __airqs_kick_single_vcpu Halil Pasic
2021-10-19 21:24   ` Christian Borntraeger
2021-10-20  5:39   ` Claudio Imbrenda
2021-10-20  8:08   ` Michael Mueller
2021-10-19 17:54 ` [PATCH 3/3] KVM: s390: clear kicked_mask if not idle after set Halil Pasic
2021-10-19 21:35   ` Christian Borntraeger
2021-10-20  5:14     ` Christian Borntraeger
2021-10-20  7:52     ` Halil Pasic
2021-10-26  8:52       ` Christian Borntraeger
2021-10-20  9:48   ` Michael Mueller
2021-10-20 10:31     ` Christian Borntraeger
2021-10-20 10:45       ` Halil Pasic
2021-10-20 10:52         ` Christian Borntraeger
2021-10-20 10:51       ` Michael Mueller
2021-10-20 11:04 ` [PATCH 0/3] fixes for __airqs_kick_single_vcpu() Christian Borntraeger
2021-10-20 12:12   ` Halil Pasic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211020073515.3ad4c377@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mimu@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=pmorel@linux.ibm.com \
    --cc=schnelle@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).