From: Eric Farman <farman@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
Eric Farman <farman@linux.ibm.com>
Subject: [PATCH kvm-unit-tests v1 5/6] s390x: smp: Create and use a non-waiting CPU restart
Date: Thu, 3 Mar 2022 22:04:24 +0100 [thread overview]
Message-ID: <20220303210425.1693486-6-farman@linux.ibm.com> (raw)
In-Reply-To: <20220303210425.1693486-1-farman@linux.ibm.com>
The kvm-unit-tests infrastructure for a CPU restart waits for the
SIGP RESTART to complete. In order to test the restart itself,
create a variation that does not wait, and test the state of the
CPU directly.
While here, add some better report prefixes/messages, to clarify
which condition is being examined (similar to test_stop_store_status()).
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
lib/s390x/smp.c | 22 ++++++++++++++++++++++
lib/s390x/smp.h | 1 +
s390x/smp.c | 18 +++++++++++++++---
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
index 84e536e8..85b046a5 100644
--- a/lib/s390x/smp.c
+++ b/lib/s390x/smp.c
@@ -192,6 +192,28 @@ int smp_cpu_restart(uint16_t idx)
return rc;
}
+/*
+ * Functionally equivalent to smp_cpu_restart(), but without the
+ * elements that wait/serialize matters here in the test.
+ * Used to see if KVM itself is serialized correctly.
+ */
+int smp_cpu_restart_nowait(uint16_t idx)
+{
+ spin_lock(&lock);
+
+ /* Don't suppress a CC2 with sigp_retry() */
+ if (smp_sigp(idx, SIGP_RESTART, 0, NULL)) {
+ spin_unlock(&lock);
+ return -1;
+ }
+
+ cpus[idx].active = true;
+
+ spin_unlock(&lock);
+
+ return 0;
+}
+
int smp_cpu_start(uint16_t idx, struct psw psw)
{
int rc;
diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h
index bae03dfd..24a0e2e0 100644
--- a/lib/s390x/smp.h
+++ b/lib/s390x/smp.h
@@ -42,6 +42,7 @@ uint16_t smp_cpu_addr(uint16_t idx);
bool smp_cpu_stopped(uint16_t idx);
bool smp_sense_running_status(uint16_t idx);
int smp_cpu_restart(uint16_t idx);
+int smp_cpu_restart_nowait(uint16_t idx);
int smp_cpu_start(uint16_t idx, struct psw psw);
int smp_cpu_stop(uint16_t idx);
int smp_cpu_stop_nowait(uint16_t idx);
diff --git a/s390x/smp.c b/s390x/smp.c
index 11c2c673..03160b80 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -55,23 +55,35 @@ static void test_restart(void)
struct cpu *cpu = smp_cpu_from_idx(1);
struct lowcore *lc = cpu->lowcore;
+ report_prefix_push("restart");
+ report_prefix_push("stopped");
+
lc->restart_new_psw.mask = extract_psw_mask();
lc->restart_new_psw.addr = (unsigned long)test_func;
/* Make sure cpu is stopped */
smp_cpu_stop(1);
set_flag(0);
- smp_cpu_restart(1);
+ smp_cpu_restart_nowait(1);
+ report(!smp_cpu_stopped(1), "cpu started");
wait_for_flag();
+ report_pass("test flag");
+
+ report_prefix_pop();
+ report_prefix_push("running");
/*
* Wait until cpu 1 has set the flag because it executed the
* restart function.
*/
set_flag(0);
- smp_cpu_restart(1);
+ smp_cpu_restart_nowait(1);
+ report(!smp_cpu_stopped(1), "cpu started");
wait_for_flag();
- report_pass("restart while running");
+ report_pass("test flag");
+
+ report_prefix_pop();
+ report_prefix_pop();
}
static void test_stop(void)
--
2.32.0
next prev parent reply other threads:[~2022-03-03 21:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 21:04 [PATCH kvm-unit-tests v1 0/6] s390x: SIGP fixes Eric Farman
2022-03-03 21:04 ` [PATCH kvm-unit-tests v1 1/6] lib: s390x: smp: Retry SIGP SENSE on CC2 Eric Farman
2022-03-07 11:50 ` Nico Boehr
2022-03-07 15:20 ` Claudio Imbrenda
2022-03-03 21:04 ` [PATCH kvm-unit-tests v1 2/6] s390x: smp: Test SIGP RESTART against stopped CPU Eric Farman
2022-03-04 10:43 ` Janosch Frank
2022-03-04 14:20 ` Eric Farman
2022-03-07 12:42 ` Nico Boehr
2022-03-07 15:22 ` Claudio Imbrenda
2022-03-03 21:04 ` [PATCH kvm-unit-tests v1 3/6] s390x: smp: Fix checks for SIGP STOP STORE STATUS Eric Farman
2022-03-04 10:40 ` Janosch Frank
2022-03-04 14:38 ` Eric Farman
2022-03-07 18:30 ` Eric Farman
2022-03-03 21:04 ` [PATCH kvm-unit-tests v1 4/6] s390x: smp: Create and use a non-waiting CPU stop Eric Farman
2022-03-07 13:31 ` Nico Boehr
2022-03-07 19:01 ` Eric Farman
2022-03-07 15:30 ` Claudio Imbrenda
2022-03-07 19:03 ` Eric Farman
2022-03-08 10:31 ` Claudio Imbrenda
2022-03-08 21:18 ` Eric Farman
2022-03-09 9:27 ` Claudio Imbrenda
2022-03-03 21:04 ` Eric Farman [this message]
2022-03-07 15:31 ` [PATCH kvm-unit-tests v1 5/6] s390x: smp: Create and use a non-waiting CPU restart Claudio Imbrenda
2022-03-03 21:04 ` [PATCH kvm-unit-tests v1 6/6] lib: s390x: smp: Convert remaining smp_sigp to _retry Eric Farman
2022-03-04 10:56 ` Janosch Frank
2022-03-04 14:15 ` Eric Farman
2022-03-07 14:42 ` Nico Boehr
2022-03-07 20:15 ` Eric Farman
2022-03-08 9:03 ` Janosch Frank
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=20220303210425.1693486-6-farman@linux.ibm.com \
--to=farman@linux.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.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