From: David Hildenbrand <david@redhat.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org, Thomas Huth <thuth@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Sebastian Mitterle <smitterl@redhat.com>,
Halil Pasic <pasic@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v1 2/2] s390x: firq: floating interrupt test
Date: Thu, 2 Dec 2021 12:13:08 +0100 [thread overview]
Message-ID: <95160439-2aa9-765f-9f06-16952e42a495@redhat.com> (raw)
In-Reply-To: <20211202120113.2dd279a8@p-imbrenda>
>> +static void wait_for_sclp_int(void)
>> +{
>> + /* Enable SCLP interrupts on this CPU only. */
>> + ctl_set_bit(0, CTL0_SERVICE_SIGNAL);
>> +
>> + set_flag(1);
>
> why not just WRITE_ONCE/READ_ONCE?
Because I shamelessly copied that from s390x/smp.c ;)
>> + set_flag(0);
>> +
>> + /* Start CPU #1 and let it wait for the interrupt. */
>> + psw.mask = extract_psw_mask();
>> + psw.addr = (unsigned long)wait_for_sclp_int;
>> + ret = smp_cpu_setup(1, psw);
>> + if (ret) {
>> + report_skip("cpu #1 not found");
>
> ...which means that this will hang, and so will all the other report*
> functions. maybe you should manually unset the flag before calling the
> various report* functions.
Good point, thanks!
>
>> + goto out;
>> + }
>> +
>> + /* Wait until the CPU #1 at least enabled SCLP interrupts. */
>> + wait_for_flag();
>> +
>> + /*
>> + * We'd have to jump trough some hoops to sense e.g., via SIGP
>> + * CONDITIONAL EMERGENCY SIGNAL if CPU #1 is already in the
>> + * wait state.
>> + *
>> + * Although not completely reliable, use SIGP SENSE RUNNING STATUS
>> + * until not reported as running -- after all, our SCLP processing
>> + * will take some time as well and make races very rare.
>> + */
>> + while(smp_sense_running_status(1));
>> +
>> + h = alloc_page();
>
> do you really need to dynamically allocate one page?
> is there a reason for not using a simple static buffer? (which you can
> have aligned and statically initialized)
I don't really have a strong opinion. I do prefer dynamic alloctions,
though, if there isn't a good reason not to use them. No need to mess
with page alignments manually.
>
>> + memset(h, 0, sizeof(*h));
>
> otherwise, if you really want to allocate the memory, get rid of the
> memset; the allocator always returns zeroed memory (unless you
> explicitly ask not to by using flags)
Right. "special" FLAG_DONTZERO in that semantics in that allocator.
>
>> + h->length = 4096;
>> + ret = servc(SCLP_CMDW_READ_CPU_INFO, __pa(h));
>> + if (ret) {
>> + report_fail("SCLP_CMDW_READ_CPU_INFO failed");
>> + goto out_destroy;
>> + }
>> +
>> + /*
>> + * Wait until the interrupt gets delivered on CPU #1, marking the
>
> why do you expect the interrupt to be delivered on CPU1? could it not
> be delivered on CPU0?
We don't enable SCLP interrupts + external interrupts on CPU #0 because
we'll only call sclp_setup_int() on CPU #1.
>
>> + * SCLP requests as done.
>> + */
>> + sclp_wait_busy();
>
> this is logically not wrong (and should stay, because it makes clear
> what you are trying to do), but strictly speaking it's not needed since
> the report below will hang as long as the SCLP busy flag is set.
Right. But it's really clearer to just have this in the code.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-12-02 11:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 9:58 [kvm-unit-tests PATCH v1 0/2] s390x: firq: floating interrupt test David Hildenbrand
2021-12-02 9:58 ` [kvm-unit-tests PATCH v1 1/2] s390x: make smp_cpu_setup() return 0 on success David Hildenbrand
2021-12-02 10:30 ` Thomas Huth
2021-12-02 10:33 ` Claudio Imbrenda
2021-12-02 11:28 ` Janosch Frank
2021-12-02 9:58 ` [kvm-unit-tests PATCH v1 2/2] s390x: firq: floating interrupt test David Hildenbrand
2021-12-02 11:01 ` Claudio Imbrenda
2021-12-02 11:13 ` David Hildenbrand [this message]
2021-12-02 11:26 ` David Hildenbrand
2021-12-02 12:07 ` Claudio Imbrenda
2021-12-02 12:24 ` David Hildenbrand
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=95160439-2aa9-765f-9f06-16952e42a495@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=smitterl@redhat.com \
--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