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>,
Nico Boehr <nrb@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 v2 4/6] s390x: smp: Create and use a non-waiting CPU stop
Date: Fri, 11 Mar 2022 18:38:20 +0100 [thread overview]
Message-ID: <20220311173822.1234617-5-farman@linux.ibm.com> (raw)
In-Reply-To: <20220311173822.1234617-1-farman@linux.ibm.com>
When stopping a CPU, kvm-unit-tests serializes/waits for everything
to finish, in order to get a consistent result whenever those
functions are used.
But to test the SIGP STOP itself, these additional measures could
mask other problems. For example, did the STOP work, or is the CPU
still operating?
Let's create a non-waiting SIGP STOP and use it here, to ensure that
the CPU is correctly stopped. A smp_cpu_stopped() call will still
be used to see that the SIGP STOP has been processed, and the state
of the CPU can be used to determine whether the test passes/fails.
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
lib/s390x/smp.c | 27 +++++++++++++++++++++++++++
lib/s390x/smp.h | 1 +
s390x/smp.c | 17 +++++++++--------
3 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
index 368d6add..b69c0e09 100644
--- a/lib/s390x/smp.c
+++ b/lib/s390x/smp.c
@@ -119,6 +119,33 @@ int smp_cpu_stop(uint16_t idx)
return rc;
}
+/*
+ * Functionally equivalent to smp_cpu_stop(), but without the
+ * elements that wait/serialize matters itself.
+ * Used to see if KVM itself is serialized correctly.
+ */
+int smp_cpu_stop_nowait(uint16_t idx)
+{
+ check_idx(idx);
+
+ /* refuse to work on the boot CPU */
+ if (idx == 0)
+ return -1;
+
+ spin_lock(&lock);
+
+ /* Don't suppress a CC2 with sigp_retry() */
+ if (sigp(cpus[idx].addr, SIGP_STOP, 0, NULL)) {
+ spin_unlock(&lock);
+ return -1;
+ }
+
+ cpus[idx].active = false;
+ spin_unlock(&lock);
+
+ return 0;
+}
+
int smp_cpu_stop_store_status(uint16_t idx)
{
int rc;
diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h
index 1e69a7de..bae03dfd 100644
--- a/lib/s390x/smp.h
+++ b/lib/s390x/smp.h
@@ -44,6 +44,7 @@ bool smp_sense_running_status(uint16_t idx);
int smp_cpu_restart(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);
int smp_cpu_stop_store_status(uint16_t idx);
int smp_cpu_destroy(uint16_t idx);
int smp_cpu_setup(uint16_t idx, struct psw psw);
diff --git a/s390x/smp.c b/s390x/smp.c
index 50811bd0..f70a9c54 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -76,14 +76,15 @@ static void test_restart(void)
static void test_stop(void)
{
- smp_cpu_stop(1);
- /*
- * The smp library waits for the CPU to shut down, but let's
- * also do it here, so we don't rely on the library
- * implementation
- */
- while (!smp_cpu_stopped(1)) {}
- report_pass("stop");
+ int rc;
+
+ report_prefix_push("stop");
+
+ rc = smp_cpu_stop_nowait(1);
+ report(!rc, "return code");
+ report(smp_cpu_stopped(1), "cpu stopped");
+
+ report_prefix_pop();
}
static void test_stop_store_status(void)
--
2.32.0
next prev parent reply other threads:[~2022-03-11 17:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 17:38 [PATCH kvm-unit-tests v2 0/6] s390x SIGP fixes Eric Farman
2022-03-11 17:38 ` [PATCH kvm-unit-tests v2 1/6] lib: s390x: smp: Retry SIGP SENSE on CC2 Eric Farman
2022-03-24 8:08 ` Thomas Huth
2022-03-11 17:38 ` [PATCH kvm-unit-tests v2 2/6] s390x: smp: Test SIGP RESTART against stopped CPU Eric Farman
2022-03-24 8:15 ` Thomas Huth
2022-03-11 17:38 ` [PATCH kvm-unit-tests v2 3/6] s390x: smp: Fix checks for SIGP STOP STORE STATUS Eric Farman
2022-03-15 6:39 ` Nico Boehr
2022-03-15 17:39 ` Claudio Imbrenda
2022-03-11 17:38 ` Eric Farman [this message]
2022-03-15 6:45 ` [PATCH kvm-unit-tests v2 4/6] s390x: smp: Create and use a non-waiting CPU stop Nico Boehr
2022-03-11 17:38 ` [PATCH kvm-unit-tests v2 5/6] s390x: smp: Create and use a non-waiting CPU restart Eric Farman
2022-03-15 6:51 ` Nico Boehr
2022-03-21 7:43 ` Janosch Frank
2022-03-11 17:38 ` [PATCH kvm-unit-tests v2 6/6] lib: s390x: smp: Remove smp_sigp_retry Eric Farman
2022-03-15 7:20 ` Nico Boehr
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=20220311173822.1234617-5-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=nrb@linux.ibm.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