xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 6/7] x86/viridian: make the threshold for HvNotifyLongSpinWait tunable
Date: Fri, 17 Mar 2017 09:57:12 +0000	[thread overview]
Message-ID: <1489744633-28760-7-git-send-email-paul.durrant@citrix.com> (raw)
In-Reply-To: <1489744633-28760-1-git-send-email-paul.durrant@citrix.com>

The current threshold before the guest issues the hypercall is, and always
has been, hard-coded to 2047. It is not clear where this number came
from so, to at least allow for ease of experimentation, this patch makes
the threshold tunable via the Xen command line.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 docs/misc/xen-command-line.markdown |  8 ++++++++
 xen/arch/x86/hvm/viridian.c         | 24 +++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
index 4daf5b5..7f7e0d9 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -1623,6 +1623,14 @@ The optional `keep` parameter causes Xen to continue using the vga
 console even after dom0 has been started.  The default behaviour is to
 relinquish control to dom0.
 
+### viridian\_spinlock\_retry\_count
+> `= <integer>`
+
+> Default: `2047`
+
+Specify the maximum number of retries before an enlightened Windows
+guest will notify Xen that it has failed to acquire a spinlock.
+
 ### vpid (Intel)
 > `= <boolean>`
 
diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
index deb57f9..e7cc4e4 100644
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -22,6 +22,12 @@
 #include <public/sched.h>
 #include <public/hvm/hvm_op.h>
 
+#define VIRIDIAN_SPINLOCK_RETRY_COUNT_DEFAULT 2047
+
+static int __read_mostly viridian_spinlock_retry_count;
+integer_param("viridian_spinlock_retry_count",
+              viridian_spinlock_retry_count);
+
 /* Viridian MSR numbers. */
 #define HV_X64_MSR_GUEST_OS_ID                   0x40000000
 #define HV_X64_MSR_HYPERCALL                     0x40000001
@@ -241,7 +247,13 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf,
             res->a |= CPUID4A_HCALL_REMOTE_TLB_FLUSH;
         if ( !cpu_has_vmx_apic_reg_virt )
             res->a |= CPUID4A_MSR_BASED_APIC;
-        res->b = 2047; /* long spin count */
+
+        /*
+         * This value is the recommended number of attempts to try to
+         * acquire a spinlock before notifying the hypervisor via the
+         * HvNotifyLongSpinWait hypercall.
+         */
+        res->b = viridian_spinlock_retry_count;
         break;
 
     case 6:
@@ -991,6 +1003,16 @@ static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
 HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt,
                           viridian_load_vcpu_ctxt, 1, HVMSR_PER_VCPU);
 
+static int __init viridian_init(void)
+{
+    if ( !viridian_spinlock_retry_count )
+        viridian_spinlock_retry_count =
+            VIRIDIAN_SPINLOCK_RETRY_COUNT_DEFAULT;
+
+    return 0;
+}
+__initcall(viridian_init);
+
 /*
  * Local variables:
  * mode: C
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-03-17  9:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17  9:57 [PATCH 0/7] x86/viridian updates Paul Durrant
2017-03-17  9:57 ` [PATCH 1/7] x86/viridian: update to version 5.0a of the specification Paul Durrant
2017-03-20 11:27   ` Jan Beulich
2017-03-20 11:43     ` Paul Durrant
2017-03-20 11:54       ` Jan Beulich
2017-03-17  9:57 ` [PATCH 2/7] x86/viridian: fix xen-hvmcrash when vp_assist page is present Paul Durrant
2017-03-20 11:36   ` Jan Beulich
2017-03-20 11:50     ` Paul Durrant
2017-03-20 13:42       ` Paul Durrant
2017-03-20 13:58         ` Jan Beulich
2017-03-17  9:57 ` [PATCH 3/7] x86/viridian: don't put Xen version information in CPUID leaf 2 Paul Durrant
2017-03-20 11:41   ` Jan Beulich
2017-03-20 11:57     ` Paul Durrant
2017-03-20 12:03       ` Jan Beulich
2017-03-20 13:08         ` Paul Durrant
2017-03-20 13:20           ` Jan Beulich
2017-03-17  9:57 ` [PATCH 4/7] x86/viridian: get rid of the magic numbers in CPUID leaves 1 and 2 Paul Durrant
2017-03-20 12:15   ` Jan Beulich
2017-03-20 12:56     ` Paul Durrant
2017-03-17  9:57 ` [PATCH 5/7] x86/viridian: add warnings for unimplemented hypercalls and MSRs Paul Durrant
2017-03-20 12:21   ` Jan Beulich
2017-03-20 12:54     ` Paul Durrant
2017-03-17  9:57 ` Paul Durrant [this message]
2017-03-20 12:26   ` [PATCH 6/7] x86/viridian: make the threshold for HvNotifyLongSpinWait tunable Jan Beulich
2017-03-20 12:51     ` Paul Durrant
2017-03-20 13:22       ` Jan Beulich
2017-03-20 17:03   ` Andrew Cooper
2017-03-20 17:07     ` Paul Durrant
2017-03-17  9:57 ` [PATCH 7/7] x86/viridian: implement the crash MSRs Paul Durrant
2017-03-20 12:38   ` Jan Beulich
2017-03-20 12:48     ` Paul Durrant
2017-03-20 13:29       ` Jan Beulich
2017-03-20 13:33         ` Paul Durrant

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=1489744633-28760-7-git-send-email-paul.durrant@citrix.com \
    --to=paul.durrant@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.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 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).