xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] xen: update xen headers
       [not found] <1467781230-12484-1-git-send-email-jgross@suse.com>
@ 2016-07-06  5:00 ` Juergen Gross
  2016-07-06  5:00 ` [PATCH v2 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Juergen Gross @ 2016-07-06  5:00 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, boris.ostrovsky, sstabellini, david.vrabel

Update some Xen headers to be able to use new functionality.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 include/xen/interface/vcpu.h | 24 +++++++++++++++---------
 include/xen/interface/xen.h  | 17 ++++++++++++++++-
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/include/xen/interface/vcpu.h b/include/xen/interface/vcpu.h
index b05288c..98188c8 100644
--- a/include/xen/interface/vcpu.h
+++ b/include/xen/interface/vcpu.h
@@ -75,15 +75,21 @@
  */
 #define VCPUOP_get_runstate_info	 4
 struct vcpu_runstate_info {
-		/* VCPU's current state (RUNSTATE_*). */
-		int		 state;
-		/* When was current state entered (system time, ns)? */
-		uint64_t state_entry_time;
-		/*
-		 * Time spent in each RUNSTATE_* (ns). The sum of these times is
-		 * guaranteed not to drift from system time.
-		 */
-		uint64_t time[4];
+	/* VCPU's current state (RUNSTATE_*). */
+	int		 state;
+	/* When was current state entered (system time, ns)? */
+	uint64_t state_entry_time;
+	/*
+	 * Update indicator set in state_entry_time:
+	 * When activated via VMASST_TYPE_runstate_update_flag, set during
+	 * updates in guest memory mapped copy of vcpu_runstate_info.
+	 */
+#define XEN_RUNSTATE_UPDATE	(1ULL << 63)
+	/*
+	 * Time spent in each RUNSTATE_* (ns). The sum of these times is
+	 * guaranteed not to drift from system time.
+	 */
+	uint64_t time[4];
 };
 DEFINE_GUEST_HANDLE_STRUCT(vcpu_runstate_info);
 
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index d133112..1b0d189 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -413,7 +413,22 @@ DEFINE_GUEST_HANDLE_STRUCT(mmuext_op);
 /* x86/PAE guests: support PDPTs above 4GB. */
 #define VMASST_TYPE_pae_extended_cr3     3
 
-#define MAX_VMASST_TYPE 3
+/*
+ * x86 guests: Sane behaviour for virtual iopl
+ *  - virtual iopl updated from do_iret() hypercalls.
+ *  - virtual iopl reported in bounce frames.
+ *  - guest kernels assumed to be level 0 for the purpose of iopl checks.
+ */
+#define VMASST_TYPE_architectural_iopl   4
+
+/*
+ * All guests: activate update indicator in vcpu_runstate_info
+ * Enable setting the XEN_RUNSTATE_UPDATE flag in guest memory mapped
+ * vcpu_runstate_info during updates of the runstate information.
+ */
+#define VMASST_TYPE_runstate_update_flag 5
+
+#define MAX_VMASST_TYPE 5
 
 #ifndef __ASSEMBLY__
 
-- 
2.6.6


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] arm/xen: add support for vm_assist hypercall
       [not found] <1467781230-12484-1-git-send-email-jgross@suse.com>
  2016-07-06  5:00 ` [PATCH v2 1/3] xen: update xen headers Juergen Gross
@ 2016-07-06  5:00 ` Juergen Gross
  2016-07-06  5:00 ` [PATCH v2 3/3] xen: support runqueue steal time on xen Juergen Gross
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Juergen Gross @ 2016-07-06  5:00 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, boris.ostrovsky, sstabellini, david.vrabel

Add support for the Xen HYPERVISOR_vm_assist hypercall.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 arch/arm/include/asm/xen/hypercall.h | 1 +
 arch/arm/xen/enlighten.c             | 1 +
 arch/arm/xen/hypercall.S             | 1 +
 arch/arm64/xen/hypercall.S           | 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h
index b6b962d..9d874db 100644
--- a/arch/arm/include/asm/xen/hypercall.h
+++ b/arch/arm/include/asm/xen/hypercall.h
@@ -52,6 +52,7 @@ int HYPERVISOR_memory_op(unsigned int cmd, void *arg);
 int HYPERVISOR_physdev_op(int cmd, void *arg);
 int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args);
 int HYPERVISOR_tmem_op(void *arg);
+int HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type);
 int HYPERVISOR_platform_op_raw(void *arg);
 static inline int HYPERVISOR_platform_op(struct xen_platform_op *op)
 {
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 71db30c..0f3aa12 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -389,4 +389,5 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_multicall);
+EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist);
 EXPORT_SYMBOL_GPL(privcmd_call);
diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S
index 9a36f4f..a648dfc 100644
--- a/arch/arm/xen/hypercall.S
+++ b/arch/arm/xen/hypercall.S
@@ -91,6 +91,7 @@ HYPERCALL3(vcpu_op);
 HYPERCALL1(tmem_op);
 HYPERCALL1(platform_op_raw);
 HYPERCALL2(multicall);
+HYPERCALL2(vm_assist);
 
 ENTRY(privcmd_call)
 	stmdb sp!, {r4}
diff --git a/arch/arm64/xen/hypercall.S b/arch/arm64/xen/hypercall.S
index 70df80e..329c802 100644
--- a/arch/arm64/xen/hypercall.S
+++ b/arch/arm64/xen/hypercall.S
@@ -82,6 +82,7 @@ HYPERCALL3(vcpu_op);
 HYPERCALL1(tmem_op);
 HYPERCALL1(platform_op_raw);
 HYPERCALL2(multicall);
+HYPERCALL2(vm_assist);
 
 ENTRY(privcmd_call)
 	mov x16, x0
-- 
2.6.6


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] xen: support runqueue steal time on xen
       [not found] <1467781230-12484-1-git-send-email-jgross@suse.com>
  2016-07-06  5:00 ` [PATCH v2 1/3] xen: update xen headers Juergen Gross
  2016-07-06  5:00 ` [PATCH v2 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
@ 2016-07-06  5:00 ` Juergen Gross
       [not found] ` <1467781230-12484-4-git-send-email-jgross@suse.com>
  2016-07-06 12:06 ` [PATCH v2 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING David Vrabel
  4 siblings, 0 replies; 6+ messages in thread
From: Juergen Gross @ 2016-07-06  5:00 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, boris.ostrovsky, sstabellini, david.vrabel

Up to now reading the stolen time of a remote cpu was not possible in a
performant way under Xen. This made support of runqueue steal time via
paravirt_steal_rq_enabled impossible.

With the addition of an appropriate hypervisor interface this is now
possible, so add the support.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2: removed static variable as requested by Stefano Stabellini
---
 drivers/xen/time.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 2257b66..a7fe35b 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -47,27 +47,31 @@ static u64 get64(const u64 *p)
 	return ret;
 }
 
-/*
- * Runstate accounting
- */
-void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
+static void xen_get_runstate_snapshot_cpu(struct vcpu_runstate_info *res,
+					  unsigned int cpu)
 {
 	u64 state_time;
 	struct vcpu_runstate_info *state;
 
 	BUG_ON(preemptible());
 
-	state = this_cpu_ptr(&xen_runstate);
+	state = per_cpu_ptr(&xen_runstate, cpu);
 
-	/*
-	 * The runstate info is always updated by the hypervisor on
-	 * the current CPU, so there's no need to use anything
-	 * stronger than a compiler barrier when fetching it.
-	 */
 	do {
 		state_time = get64(&state->state_entry_time);
+		rmb();	/* Hypervisor might update data. */
 		*res = READ_ONCE(*state);
-	} while (get64(&state->state_entry_time) != state_time);
+		rmb();	/* Hypervisor might update data. */
+	} while (get64(&state->state_entry_time) != state_time ||
+		 (state_time & XEN_RUNSTATE_UPDATE));
+}
+
+/*
+ * Runstate accounting
+ */
+void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
+{
+	xen_get_runstate_snapshot_cpu(res, smp_processor_id());
 }
 
 /* return true when a vcpu could run but has no real cpu to run on */
@@ -80,8 +84,7 @@ static u64 xen_steal_clock(int cpu)
 {
 	struct vcpu_runstate_info state;
 
-	BUG_ON(cpu != smp_processor_id());
-	xen_get_runstate_snapshot(&state);
+	xen_get_runstate_snapshot_cpu(&state, cpu);
 	return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
 }
 
@@ -98,11 +101,14 @@ void xen_setup_runstate_info(int cpu)
 
 void __init xen_time_setup_guest(void)
 {
+	bool xen_runstate_remote;
+
+	xen_runstate_remote = !HYPERVISOR_vm_assist(VMASST_CMD_enable,
+					VMASST_TYPE_runstate_update_flag);
+
 	pv_time_ops.steal_clock = xen_steal_clock;
 
 	static_key_slow_inc(&paravirt_steal_enabled);
-	/*
-	 * We can't set paravirt_steal_rq_enabled as this would require the
-	 * capability to read another cpu's runstate info.
-	 */
+	if (xen_runstate_remote)
+		static_key_slow_inc(&paravirt_steal_rq_enabled);
 }
-- 
2.6.6


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] xen: support runqueue steal time on xen
       [not found] ` <1467781230-12484-4-git-send-email-jgross@suse.com>
@ 2016-07-06 10:03   ` Stefano Stabellini
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2016-07-06 10:03 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, boris.ostrovsky, sstabellini, linux-kernel, david.vrabel

On Wed, 6 Jul 2016, Juergen Gross wrote:
> Up to now reading the stolen time of a remote cpu was not possible in a
> performant way under Xen. This made support of runqueue steal time via
> paravirt_steal_rq_enabled impossible.
> 
> With the addition of an appropriate hypervisor interface this is now
> possible, so add the support.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> V2: removed static variable as requested by Stefano Stabellini
> ---
>  drivers/xen/time.c | 40 +++++++++++++++++++++++-----------------
>  1 file changed, 23 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/xen/time.c b/drivers/xen/time.c
> index 2257b66..a7fe35b 100644
> --- a/drivers/xen/time.c
> +++ b/drivers/xen/time.c
> @@ -47,27 +47,31 @@ static u64 get64(const u64 *p)
>  	return ret;
>  }
>  
> -/*
> - * Runstate accounting
> - */
> -void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
> +static void xen_get_runstate_snapshot_cpu(struct vcpu_runstate_info *res,
> +					  unsigned int cpu)
>  {
>  	u64 state_time;
>  	struct vcpu_runstate_info *state;
>  
>  	BUG_ON(preemptible());
>  
> -	state = this_cpu_ptr(&xen_runstate);
> +	state = per_cpu_ptr(&xen_runstate, cpu);
>  
> -	/*
> -	 * The runstate info is always updated by the hypervisor on
> -	 * the current CPU, so there's no need to use anything
> -	 * stronger than a compiler barrier when fetching it.
> -	 */
>  	do {
>  		state_time = get64(&state->state_entry_time);
> +		rmb();	/* Hypervisor might update data. */
>  		*res = READ_ONCE(*state);
> -	} while (get64(&state->state_entry_time) != state_time);
> +		rmb();	/* Hypervisor might update data. */
> +	} while (get64(&state->state_entry_time) != state_time ||
> +		 (state_time & XEN_RUNSTATE_UPDATE));
> +}
> +
> +/*
> + * Runstate accounting
> + */
> +void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
> +{
> +	xen_get_runstate_snapshot_cpu(res, smp_processor_id());
>  }
>  
>  /* return true when a vcpu could run but has no real cpu to run on */
> @@ -80,8 +84,7 @@ static u64 xen_steal_clock(int cpu)
>  {
>  	struct vcpu_runstate_info state;
>  
> -	BUG_ON(cpu != smp_processor_id());
> -	xen_get_runstate_snapshot(&state);
> +	xen_get_runstate_snapshot_cpu(&state, cpu);
>  	return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
>  }
>  
> @@ -98,11 +101,14 @@ void xen_setup_runstate_info(int cpu)
>  
>  void __init xen_time_setup_guest(void)
>  {
> +	bool xen_runstate_remote;
> +
> +	xen_runstate_remote = !HYPERVISOR_vm_assist(VMASST_CMD_enable,
> +					VMASST_TYPE_runstate_update_flag);
> +
>  	pv_time_ops.steal_clock = xen_steal_clock;
>  
>  	static_key_slow_inc(&paravirt_steal_enabled);
> -	/*
> -	 * We can't set paravirt_steal_rq_enabled as this would require the
> -	 * capability to read another cpu's runstate info.
> -	 */
> +	if (xen_runstate_remote)
> +		static_key_slow_inc(&paravirt_steal_rq_enabled);
>  }
> -- 
> 2.6.6
> 

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING
       [not found] <1467781230-12484-1-git-send-email-jgross@suse.com>
                   ` (3 preceding siblings ...)
       [not found] ` <1467781230-12484-4-git-send-email-jgross@suse.com>
@ 2016-07-06 12:06 ` David Vrabel
  4 siblings, 0 replies; 6+ messages in thread
From: David Vrabel @ 2016-07-06 12:06 UTC (permalink / raw)
  To: Juergen Gross, xen-devel, linux-kernel
  Cc: boris.ostrovsky, sstabellini, david.vrabel

On 06/07/16 06:00, Juergen Gross wrote:
> With most recent Xen hypervisor (4.8) it is now possible to add full
> support of CONFIG_PARAVIRT_TIME_ACCOUNTING.
> 
> To be applied on top of commit ed2f61fdd2356c2a1d1239aa1507ce4e2e059306
> "xen: add steal_clock support on x86" of kernel/git/xen/tip.git
> 
> Runtime tested on x86_64, compile tested on arm64.

Applied to for-linus-4.8, thanks.

David

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING
@ 2016-07-06  5:00 Juergen Gross
  0 siblings, 0 replies; 6+ messages in thread
From: Juergen Gross @ 2016-07-06  5:00 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, boris.ostrovsky, sstabellini, david.vrabel

With most recent Xen hypervisor (4.8) it is now possible to add full
support of CONFIG_PARAVIRT_TIME_ACCOUNTING.

To be applied on top of commit ed2f61fdd2356c2a1d1239aa1507ce4e2e059306
"xen: add steal_clock support on x86" of kernel/git/xen/tip.git

Runtime tested on x86_64, compile tested on arm64.

Changes in V2:
- patch 3: removed static variable as requested by Stefano Stabellini

Juergen Gross (3):
  xen: update xen headers
  arm/xen: add support for vm_assist hypercall
  xen: support runqueue steal time on xen

 arch/arm/include/asm/xen/hypercall.h |  1 +
 arch/arm/xen/enlighten.c             |  1 +
 arch/arm/xen/hypercall.S             |  1 +
 arch/arm64/xen/hypercall.S           |  1 +
 drivers/xen/time.c                   | 40 +++++++++++++++++++++---------------
 include/xen/interface/vcpu.h         | 24 ++++++++++++++--------
 include/xen/interface/xen.h          | 17 ++++++++++++++-
 7 files changed, 58 insertions(+), 27 deletions(-)

-- 
2.6.6


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-07-06 12:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1467781230-12484-1-git-send-email-jgross@suse.com>
2016-07-06  5:00 ` [PATCH v2 1/3] xen: update xen headers Juergen Gross
2016-07-06  5:00 ` [PATCH v2 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
2016-07-06  5:00 ` [PATCH v2 3/3] xen: support runqueue steal time on xen Juergen Gross
     [not found] ` <1467781230-12484-4-git-send-email-jgross@suse.com>
2016-07-06 10:03   ` Stefano Stabellini
2016-07-06 12:06 ` [PATCH v2 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING David Vrabel
2016-07-06  5:00 Juergen Gross

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).