kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: David Hildenbrand <david@redhat.com>, kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, thuth@redhat.com
Subject: Re: [kvm-unit-tests PATCH 1/6] s390x: Use interrupts in SCLP and add locking
Date: Tue, 3 Sep 2019 09:53:57 +0200	[thread overview]
Message-ID: <4309b6ea-e479-f25d-276a-6d8260d4f19f@linux.ibm.com> (raw)
In-Reply-To: <74d31bb9-4941-01f3-571b-8a89a05402c8@redhat.com>


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

On 8/30/19 2:21 PM, David Hildenbrand wrote:
> On 29.08.19 14:14, Janosch Frank wrote:
>> We need to properly implement interrupt handling for SCLP, because on
>> z/VM and LPAR SCLP calls are not synchronous!
>>
>> Also with smp CPUs have to compete for sclp. Let's add some locking,
>> so they execute sclp calls in an orderly fashion and don't compete for
>> the data buffer.

[...]

>> +
>> +void sclp_mark_busy(void)
>> +{
>> +	/*
>> +	 * With multiple CPUs we might need to wait for another CPU's
>> +	 * request before grabbing the busy indication.
>> +	 */
>> +retry_wait:
>> +	sclp_wait_busy();
>> +	spin_lock(&sclp_lock);
>> +	if (sclp_busy) {
>> +		spin_unlock(&sclp_lock);
>> +		goto retry_wait;
>> +	}
>> +	sclp_busy = true;
>> +	spin_unlock(&sclp_lock);
> 
> while (true) {
> 	sclp_wait_busy();
> 	spin_lock(&sclp_lock);
> 	if (!sclp_busy) {
> 		sclp_busy = true
> 		spin_unlock(&sclp_lock);
> 		break;
> 	}
> 	spin_unlock(&sclp_lock);
> }
> 
> Or can we simply switch to an atomic_t for sclp_busy and implement
> cmpxchg using __sync_bool_compare_and_swap/ __sync_val_compare_and_swap ?
> 
> I guess then we can drop the lock. But maybe I am missing something :)

If you want to add it and it works, I'm open for it :)
Until then I'm taking your suggestion.

> 
>> +}
[...]
>>  extern char _sccb[];
>> +void sclp_handle_ext(void);
>> +void sclp_wait_busy(void);
>> +void sclp_mark_busy(void);
> 
> I wonder if we can find better names ...
> 
> sclp_prepare()
> sclp_finalize()
> 
> or sth like that.

Hmm, IMHO my names are a bit better, since they clearly state, that we
wait until the other user has finished.



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

  parent reply	other threads:[~2019-09-03  7:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-29 12:14 [kvm-unit-tests PATCH 0/6] s390x: Add multiboot and smp Janosch Frank
2019-08-29 12:14 ` [kvm-unit-tests PATCH 1/6] s390x: Use interrupts in SCLP and add locking Janosch Frank
2019-08-30 12:21   ` David Hildenbrand
2019-09-02 11:42     ` Thomas Huth
2019-09-03  7:53     ` Janosch Frank [this message]
2019-09-03  8:52       ` David Hildenbrand
2019-08-29 12:14 ` [kvm-unit-tests PATCH 2/6] s390x: Add linemode console Janosch Frank
2019-09-02 11:59   ` Thomas Huth
2019-08-29 12:14 ` [kvm-unit-tests PATCH 3/6] s390x: Add linemode buffer to fix newline on every print Janosch Frank
2019-08-29 12:14 ` [kvm-unit-tests PATCH 4/6] s390x: Add initial smp code Janosch Frank
2019-09-02 13:21   ` Thomas Huth
2019-09-03  8:10     ` Janosch Frank
2019-08-29 12:14 ` [kvm-unit-tests PATCH 5/6] s390x: Prepare for external calls Janosch Frank
2019-09-02 13:58   ` Thomas Huth
2019-09-02 14:17     ` Janosch Frank
2019-08-29 12:14 ` [kvm-unit-tests PATCH 6/6] s390x: SMP test Janosch Frank
2019-09-02 15:40   ` Thomas Huth
2019-09-03  8:44     ` Janosch Frank
2019-09-03  8:56       ` Thomas Huth

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=4309b6ea-e479-f25d-276a-6d8260d4f19f@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=thuth@redhat.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).