From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [s390] possible deadlock in handle_sigp? Date: Thu, 15 Sep 2016 22:50:11 +0200 Message-ID: <8a57010d-486a-e927-45f0-33b99036daf0@redhat.com> References: <33773797-04ec-413f-7ba2-4bb7a4350a44@de.ibm.com> <20160915212142.5fd5048e@thinkpad-w530> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Cc: KVM list , Cornelia Huck , qemu-devel To: David Hildenbrand , Christian Borntraeger Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48410 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751180AbcIOUuQ (ORCPT ); Thu, 15 Sep 2016 16:50:16 -0400 In-Reply-To: <20160915212142.5fd5048e@thinkpad-w530> Sender: kvm-owner@vger.kernel.org List-ID: 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.