qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>, Alexander Graf <agraf@suse.de>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v1 for-2.11 2/3] s390x/tcg: fix DIAG 308 with > 1 VCPU (single threaded TCG)
Date: Thu, 16 Nov 2017 19:24:03 +0100	[thread overview]
Message-ID: <556871d6-b07a-d7b5-c4d0-78615224b05e@redhat.com> (raw)
In-Reply-To: <871sky14a9.fsf@linaro.org>

On 16.11.2017 19:12, Alex Bennée wrote:
> 
> David Hildenbrand <david@redhat.com> writes:
> 
>> On 16.11.2017 18:37, Alex Bennée wrote:
>>>
>>> David Hildenbrand <david@redhat.com> writes:
>>>
>>>> Currently, single threaded TCG with > 1 VCPU gets stuck during IPL, when
>>>> the bios tries to switch to the loaded kernel via DIAG 308.
>>>>
>>>> pause_all_vcpus()/resume_all_vcpus() should not be called from a VCPU.
>>>>
>>>> And there is also no need for it. run_on_cpu() will make sure that the
>>>> CPUs exit KVM/TCG, where they get stopped. Once stopped, they will no
>>>> longer run.
>>>>
>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>> ---
>>>>  target/s390x/diag.c | 4 ----
>>>>  1 file changed, 4 deletions(-)
>>>>
>>>> diff --git a/target/s390x/diag.c b/target/s390x/diag.c
>>>> index dbbb9e886f..52bc348808 100644
>>>> --- a/target/s390x/diag.c
>>>> +++ b/target/s390x/diag.c
>>>> @@ -27,7 +27,6 @@ static int modified_clear_reset(S390CPU *cpu)
>>>>      S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
>>>>      CPUState *t;
>>>>
>>>> -    pause_all_vcpus();
>>>>      cpu_synchronize_all_states();
>>>>      CPU_FOREACH(t) {
>>>>          run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL);
>>>
>>> I think you also need to fix the run_on_cpu to be a async_run_on_cpu as
>>> you would otherwise hang waiting for run_on_cpu to finish on a
>>> single-threaded TCG run (as you are in the only vCPU context).
>>
>> No, it works just fine for single threaded TCG. run_on_cpu() can deal
>> with single threaded TCG just fine. (otherwise e.g. SIGP code also
>> wouldn't work)
>>
>> In do_run_on_cpu, the following code always directly triggers for single
>> threaded tcg:
>>
>>     if (qemu_cpu_is_self(cpu)) {
>>
>>         func(cpu, data);
>>
>>         return;
>>
>>     }
> 
> For -smp 1 it's fine, but have you tested --accel thread=single -smp 2?

Yes, otherwise I would never have noticed this bug ;)

I use for my current single threaded setup:
"--accel thread=single -smp 4"

The point is: if run_on_cpu() would not be able to cope with this very
simple problem, it would basically be useless.

instead of scheduling work, it simply executes all these functions
directly for single threaded TCG. For multi threaded TCG it actually
schedules work, that's why I notice the missing iolock (see patch
following this one)

> 
>>
>>>
>>> If it is important that the source vCPU doesn't continue you can
>>> schedule it's work afterwards with a async_safe_run_on_cpu which will
>>> complete after all other vCPUs have executed their work.
>>>
>>
>> It is important. Introducing async helpers at a point where sync is
>> needed sounds strange.
> 
> Well the helper that schedulules the final async helper also needs to
> exit the run loop at that point, otherwise you are right it would
> attempt to execute a few more instructions in the block.
> 

And the nice thing about run_on_cpu here is for single threaded TCG that
not a single work has to be scheduled.

-- 

Thanks,

David / dhildenb

  reply	other threads:[~2017-11-16 18:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 17:05 [Qemu-devel] [PATCH v1 for-2.11 0/3] s390x: fixes for SIGP and DIAG 308 David Hildenbrand
2017-11-16 17:05 ` [Qemu-devel] [PATCH v1 for-2.11 1/3] s390x: fix storing CPU status (again) David Hildenbrand
2017-11-16 20:45   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2017-11-16 20:58   ` [Qemu-devel] " Christian Borntraeger
2017-11-16 17:05 ` [Qemu-devel] [PATCH v1 for-2.11 2/3] s390x/tcg: fix DIAG 308 with > 1 VCPU (single threaded TCG) David Hildenbrand
2017-11-16 17:37   ` Alex Bennée
2017-11-16 17:52     ` David Hildenbrand
2017-11-16 18:12       ` Alex Bennée
2017-11-16 18:24         ` David Hildenbrand [this message]
2017-11-16 18:14       ` Alex Bennée
2017-11-16 17:47   ` David Hildenbrand
2017-11-16 20:57   ` Christian Borntraeger
2017-11-16 21:42     ` David Hildenbrand
2017-11-16 17:05 ` [Qemu-devel] [PATCH v1 for-2.11 3/3] s390x/tcg: fix DIAG 308 with > 1 VCPU (MTTCG) David Hildenbrand
2017-11-16 20:54   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2017-11-16 17:23 ` [Qemu-devel] [PATCH v1 for-2.11 0/3] s390x: fixes for SIGP and DIAG 308 Cornelia Huck
2017-11-16 17:32   ` David Hildenbrand
2017-11-16 20:55   ` Christian Borntraeger
2017-11-17  8:07     ` Cornelia Huck
2017-11-17  8:10   ` Cornelia Huck
2017-11-17  8:38     ` 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=556871d6-b07a-d7b5-c4d0-78615224b05e@redhat.com \
    --to=david@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    /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).