xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING
@ 2016-06-22  7:03 Juergen Gross
  2016-06-22  7:03 ` [PATCH 1/3] xen: update xen headers Juergen Gross
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Juergen Gross @ 2016-06-22  7:03 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.

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                   | 42 +++++++++++++++++++++---------------
 include/xen/interface/vcpu.h         | 24 +++++++++++++--------
 include/xen/interface/xen.h          | 17 ++++++++++++++-
 7 files changed, 60 insertions(+), 27 deletions(-)

-- 
2.6.6


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

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

* [PATCH 1/3] xen: update xen headers
  2016-06-22  7:03 [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Juergen Gross
@ 2016-06-22  7:03 ` Juergen Gross
  2016-07-05 15:07   ` Stefano Stabellini
  2016-06-22  7:03 ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Juergen Gross @ 2016-06-22  7:03 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>
---
 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
http://lists.xen.org/xen-devel

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

* [PATCH 2/3] arm/xen: add support for vm_assist hypercall
  2016-06-22  7:03 [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Juergen Gross
  2016-06-22  7:03 ` [PATCH 1/3] xen: update xen headers Juergen Gross
@ 2016-06-22  7:03 ` Juergen Gross
  2016-06-22  7:03 ` [PATCH 3/3] xen: support runqueue steal time on xen Juergen Gross
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Juergen Gross @ 2016-06-22  7:03 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>
---
 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
http://lists.xen.org/xen-devel

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

* [PATCH 3/3] xen: support runqueue steal time on xen
  2016-06-22  7:03 [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Juergen Gross
  2016-06-22  7:03 ` [PATCH 1/3] xen: update xen headers Juergen Gross
  2016-06-22  7:03 ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
@ 2016-06-22  7:03 ` Juergen Gross
  2016-07-05 15:23   ` Stefano Stabellini
  2016-06-22 15:48 ` [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Boris Ostrovsky
       [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
  4 siblings, 1 reply; 11+ messages in thread
From: Juergen Gross @ 2016-06-22  7:03 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>
---
 drivers/xen/time.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 2257b66..65afbe9 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -19,6 +19,9 @@
 /* runstate info updated by Xen */
 static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
 
+/* runstate info of remote cpu accessible */
+static bool xen_runstate_remote;
+
 /* return an consistent snapshot of 64-bit time/counter value */
 static u64 get64(const u64 *p)
 {
@@ -47,27 +50,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 +87,8 @@ static u64 xen_steal_clock(int cpu)
 {
 	struct vcpu_runstate_info state;
 
-	BUG_ON(cpu != smp_processor_id());
-	xen_get_runstate_snapshot(&state);
+	BUG_ON(!xen_runstate_remote && cpu != smp_processor_id());
+	xen_get_runstate_snapshot_cpu(&state, cpu);
 	return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
 }
 
@@ -98,11 +105,12 @@ void xen_setup_runstate_info(int cpu)
 
 void __init xen_time_setup_guest(void)
 {
+	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
http://lists.xen.org/xen-devel

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

* Re: [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING
  2016-06-22  7:03 [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Juergen Gross
                   ` (2 preceding siblings ...)
  2016-06-22  7:03 ` [PATCH 3/3] xen: support runqueue steal time on xen Juergen Gross
@ 2016-06-22 15:48 ` Boris Ostrovsky
       [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
  4 siblings, 0 replies; 11+ messages in thread
From: Boris Ostrovsky @ 2016-06-22 15:48 UTC (permalink / raw)
  To: Juergen Gross, xen-devel, linux-kernel; +Cc: sstabellini, david.vrabel

On 06/22/2016 03:03 AM, 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.
>
> 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                   | 42 +++++++++++++++++++++---------------
>  include/xen/interface/vcpu.h         | 24 +++++++++++++--------
>  include/xen/interface/xen.h          | 17 ++++++++++++++-
>  7 files changed, 60 insertions(+), 27 deletions(-)
>

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>


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

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

* Re: [PATCH 2/3] arm/xen: add support for vm_assist hypercall
       [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
@ 2016-07-04  9:21   ` Juergen Gross
  2016-07-04 11:20   ` Julien Grall
  2016-07-05 15:03   ` Stefano Stabellini
  2 siblings, 0 replies; 11+ messages in thread
From: Juergen Gross @ 2016-07-04  9:21 UTC (permalink / raw)
  To: xen-devel, linux-kernel; +Cc: boris.ostrovsky, sstabellini, david.vrabel

On 22/06/16 09:03, Juergen Gross wrote:
> Add support for the Xen HYPERVISOR_vm_assist hypercall.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Stefano, could you please comment?


Juergen

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


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

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

* Re: [PATCH 2/3] arm/xen: add support for vm_assist hypercall
       [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
  2016-07-04  9:21   ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
@ 2016-07-04 11:20   ` Julien Grall
  2016-07-05 15:03   ` Stefano Stabellini
  2 siblings, 0 replies; 11+ messages in thread
From: Julien Grall @ 2016-07-04 11:20 UTC (permalink / raw)
  To: Juergen Gross, xen-devel, linux-kernel
  Cc: boris.ostrovsky, sstabellini, david.vrabel

Hi Juergen,

On 22/06/16 08:03, Juergen Gross wrote:
> Add support for the Xen HYPERVISOR_vm_assist hypercall.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Julien Grall <julien.grall@arm.com>

Regards,

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

-- 
Julien Grall

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

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

* Re: [PATCH 2/3] arm/xen: add support for vm_assist hypercall
       [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
  2016-07-04  9:21   ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
  2016-07-04 11:20   ` Julien Grall
@ 2016-07-05 15:03   ` Stefano Stabellini
  2 siblings, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-07-05 15:03 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, boris.ostrovsky, sstabellini, linux-kernel, david.vrabel

On Wed, 22 Jun 2016, Juergen Gross wrote:
> Add support for the Xen HYPERVISOR_vm_assist hypercall.
> 
> Signed-off-by: Juergen Gross <jgross@suse.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	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xen: update xen headers
  2016-06-22  7:03 ` [PATCH 1/3] xen: update xen headers Juergen Gross
@ 2016-07-05 15:07   ` Stefano Stabellini
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-07-05 15:07 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, boris.ostrovsky, sstabellini, linux-kernel, david.vrabel

On Wed, 22 Jun 2016, Juergen Gross wrote:
> Update some Xen headers to be able to use new functionality.
> 
> Signed-off-by: Juergen Gross <jgross@suse.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	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] xen: support runqueue steal time on xen
  2016-06-22  7:03 ` [PATCH 3/3] xen: support runqueue steal time on xen Juergen Gross
@ 2016-07-05 15:23   ` Stefano Stabellini
  2016-07-06  4:25     ` Juergen Gross
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Stabellini @ 2016-07-05 15:23 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, boris.ostrovsky, sstabellini, linux-kernel, david.vrabel

On Wed, 22 Jun 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>
> ---
>  drivers/xen/time.c | 42 +++++++++++++++++++++++++-----------------
>  1 file changed, 25 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/xen/time.c b/drivers/xen/time.c
> index 2257b66..65afbe9 100644
> --- a/drivers/xen/time.c
> +++ b/drivers/xen/time.c
> @@ -19,6 +19,9 @@
>  /* runstate info updated by Xen */
>  static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
>  
> +/* runstate info of remote cpu accessible */
> +static bool xen_runstate_remote;

Honestly I would rather have one global variable less if it means only
dropping one BUG_ON.


>  /* return an consistent snapshot of 64-bit time/counter value */
>  static u64 get64(const u64 *p)
>  {
> @@ -47,27 +50,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 +87,8 @@ static u64 xen_steal_clock(int cpu)
>  {
>  	struct vcpu_runstate_info state;
>  
> -	BUG_ON(cpu != smp_processor_id());
> -	xen_get_runstate_snapshot(&state);
> +	BUG_ON(!xen_runstate_remote && cpu != smp_processor_id());
> +	xen_get_runstate_snapshot_cpu(&state, cpu);
>  	return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
>  }
>  
> @@ -98,11 +105,12 @@ void xen_setup_runstate_info(int cpu)
>  
>  void __init xen_time_setup_guest(void)
>  {
> +	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);
>  }

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

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

* Re: [PATCH 3/3] xen: support runqueue steal time on xen
  2016-07-05 15:23   ` Stefano Stabellini
@ 2016-07-06  4:25     ` Juergen Gross
  0 siblings, 0 replies; 11+ messages in thread
From: Juergen Gross @ 2016-07-06  4:25 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, boris.ostrovsky, linux-kernel, david.vrabel

On 05/07/16 17:23, Stefano Stabellini wrote:
> On Wed, 22 Jun 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>
>> ---
>>  drivers/xen/time.c | 42 +++++++++++++++++++++++++-----------------
>>  1 file changed, 25 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/xen/time.c b/drivers/xen/time.c
>> index 2257b66..65afbe9 100644
>> --- a/drivers/xen/time.c
>> +++ b/drivers/xen/time.c
>> @@ -19,6 +19,9 @@
>>  /* runstate info updated by Xen */
>>  static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
>>  
>> +/* runstate info of remote cpu accessible */
>> +static bool xen_runstate_remote;
> 
> Honestly I would rather have one global variable less if it means only
> dropping one BUG_ON.

Okay, I'll remove it.


Juergen

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

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22  7:03 [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Juergen Gross
2016-06-22  7:03 ` [PATCH 1/3] xen: update xen headers Juergen Gross
2016-07-05 15:07   ` Stefano Stabellini
2016-06-22  7:03 ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
2016-06-22  7:03 ` [PATCH 3/3] xen: support runqueue steal time on xen Juergen Gross
2016-07-05 15:23   ` Stefano Stabellini
2016-07-06  4:25     ` Juergen Gross
2016-06-22 15:48 ` [PATCH 0/3] xen: add full support for CONFIG_PARAVIRT_TIME_ACCOUNTING Boris Ostrovsky
     [not found] ` <1466579034-12113-3-git-send-email-jgross@suse.com>
2016-07-04  9:21   ` [PATCH 2/3] arm/xen: add support for vm_assist hypercall Juergen Gross
2016-07-04 11:20   ` Julien Grall
2016-07-05 15:03   ` Stefano Stabellini

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