From: "Kaya, Metin" <metikaya@amazon.com>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: [kvm-unit-tests PATCH 1/3] x86/hyperv_clock: handle non-consecutive APIC IDs
Date: Mon, 24 Jan 2022 16:16:59 +0000 [thread overview]
Message-ID: <1643041019466.87388@amazon.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 191 bytes --]
smp_id() should not be used if APIC IDs are not allocated consecutively.
Fix it by using on_cpu_async() with CPU ID parameter.
Fixes: 907ce0f78c94 ("KVM: x86: add hyperv clock test case")
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-x86-hyperv_clock-handle-non-consecutive-APIC-IDs.patch --]
[-- Type: text/x-patch; name="0001-x86-hyperv_clock-handle-non-consecutive-APIC-IDs.patch", Size: 2884 bytes --]
From 176152abd56b2a227c14290b3e1d57f1c37d3cd8 Mon Sep 17 00:00:00 2001
From: Metin Kaya <metikaya@amazon.com>
Date: Mon, 24 Jan 2022 10:22:32 +0000
Subject: [PATCH 1/3] x86/hyperv_clock: handle non-consecutive APIC IDs
smp_id() should not be used if APIC IDs are not allocated consecutively.
Fix it by using on_cpu_async() with CPU ID parameter.
Fixes: 907ce0f78c94 ("KVM: x86: add hyperv clock test case")
Signed-off-by: Metin Kaya <metikaya@amazon.com>
---
x86/hyperv_clock.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/x86/hyperv_clock.c b/x86/hyperv_clock.c
index f1e7204..dcf101a 100644
--- a/x86/hyperv_clock.c
+++ b/x86/hyperv_clock.c
@@ -63,7 +63,7 @@ uint64_t loops[MAX_CPU];
static void hv_clock_test(void *data)
{
- int i = smp_id();
+ int i = (long)data;
uint64_t t = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
uint64_t end = t + 3 * TICKS_PER_SEC;
uint64_t msr_sample = t + TICKS_PER_SEC;
@@ -80,7 +80,7 @@ static void hv_clock_test(void *data)
if (t < msr_sample) {
max_delta = delta > max_delta ? delta: max_delta;
} else if (delta < 0 || delta > max_delta * 3 / 2) {
- printf("suspecting drift on CPU %d? delta = %d, acceptable [0, %d)\n", smp_id(),
+ printf("suspecting drift on CPU %d? delta = %d, acceptable [0, %d)\n", i,
delta, max_delta);
ok[i] = false;
got_drift = true;
@@ -88,7 +88,7 @@ static void hv_clock_test(void *data)
}
if (now < t && !got_warp) {
- printf("warp on CPU %d!\n", smp_id());
+ printf("warp on CPU %d!\n", i);
ok[i] = false;
got_warp = true;
break;
@@ -97,7 +97,7 @@ static void hv_clock_test(void *data)
} while(t < end);
if (!got_drift)
- printf("delta on CPU %d was %d...%d\n", smp_id(), min_delta, max_delta);
+ printf("delta on CPU %d was %d...%d\n", i, min_delta, max_delta);
barrier();
}
@@ -106,7 +106,11 @@ static void check_test(int ncpus)
int i;
bool pass;
- on_cpus(hv_clock_test, NULL);
+ for (i = ncpus - 1; i >= 0; i--)
+ on_cpu_async(i, hv_clock_test, (void *)(long)i);
+
+ while (cpus_active() > 1)
+ pause();
pass = true;
for (i = ncpus - 1; i >= 0; i--)
@@ -117,6 +121,7 @@ static void check_test(int ncpus)
static void hv_perf_test(void *data)
{
+ int i = (long)data;
uint64_t t = hv_clock_read();
uint64_t end = t + 1000000000 / 100;
uint64_t local_loops = 0;
@@ -126,7 +131,7 @@ static void hv_perf_test(void *data)
local_loops++;
} while(t < end);
- loops[smp_id()] = local_loops;
+ loops[i] = local_loops;
}
static void perf_test(int ncpus)
@@ -134,7 +139,11 @@ static void perf_test(int ncpus)
int i;
uint64_t total_loops;
- on_cpus(hv_perf_test, NULL);
+ for (i = ncpus - 1; i >= 0; i--)
+ on_cpu_async(i, hv_perf_test, (void *)(long)i);
+
+ while (cpus_active() > 1)
+ pause();
total_loops = 0;
for (i = ncpus - 1; i >= 0; i--)
--
2.32.0
reply other threads:[~2022-01-24 16:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1643041019466.87388@amazon.com \
--to=metikaya@amazon.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.