Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: David Hildenbrand <dahi@linux.vnet.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Cc: KVM list <kvm@vger.kernel.org>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [s390] possible deadlock in handle_sigp?
Date: Thu, 15 Sep 2016 22:50:11 +0200	[thread overview]
Message-ID: <8a57010d-486a-e927-45f0-33b99036daf0@redhat.com> (raw)
In-Reply-To: <20160915212142.5fd5048e@thinkpad-w530>



On 15/09/2016 21:21, David Hildenbrand wrote:
> Smells like having to provide a lock per CPU. Trylock that lock, if that's not
> possible, cc=busy. SIGP SET ARCHITECTURE has to lock all CPUs.

Makes sense.  On the other hand:

- you have to trylock both the source and the destination, I think.

- since no one ever does a lock, only a trylock, the trylock can be
replaced by a simple test-and-set of a flag in S390CPU (e.g.
cpu->doing_sigp).  Because the access to the bitmap _is_ protected by
the BQL, it needn't even use atomics and it can be as simple as

static bool start_sigp(S390CPU *src, S390CPU *dst)
{
    if (!src->in_sigp && !dst->in_sigp) {
        src->in_sigp = dst->in_sigp = true;
        return true;
    }
    return false;
}

and end_sigp is similarly obvious.

Thanks,

Paolo

> That was the initital design, until I realized that this was all protected by
> the BQL.

  reply	other threads:[~2016-09-15 20:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 16:44 [s390] possible deadlock in handle_sigp? Paolo Bonzini
2016-09-12 17:37 ` Christian Borntraeger
2016-09-12 18:03   ` Paolo Bonzini
2016-09-13 13:06     ` Christian Borntraeger
2016-09-15 19:21       ` David Hildenbrand
2016-09-15 20:50         ` Paolo Bonzini [this message]
2016-09-19  8:15         ` Christian Borntraeger
2016-09-19 11:25           ` David Hildenbrand
2016-09-19 11:45             ` Christian Borntraeger
2016-09-20 11:57 ` [PATCH] s390x/kvm: Fix potential deadlock in sigp handling Christian Borntraeger

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=8a57010d-486a-e927-45f0-33b99036daf0@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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