* [PATCH v9 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
@ 2014-01-09 18:32 ` Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 2/5] kernel: missing include in cputime.c Stefano Stabellini
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-09 18:32 UTC (permalink / raw)
To: xen-devel
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Stefano.Stabellini, Ian.Campbell, linux, olof, arnd,
catalin.marinas, Stefano Stabellini
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: konrad.wilk@oracle.com
---
Changes in v2:
- leave do_stolen_accounting in arch/x86/xen/time.c;
- use the new common functions in arch/ia64/xen/time.c.
---
arch/ia64/xen/time.c | 48 ++++----------------------
arch/x86/xen/time.c | 76 +----------------------------------------
drivers/xen/Makefile | 2 +-
drivers/xen/time.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
include/xen/xen-ops.h | 5 +++
5 files changed, 104 insertions(+), 118 deletions(-)
create mode 100644 drivers/xen/time.c
diff --git a/arch/ia64/xen/time.c b/arch/ia64/xen/time.c
index 1f8244a..79a0b8c 100644
--- a/arch/ia64/xen/time.c
+++ b/arch/ia64/xen/time.c
@@ -34,53 +34,17 @@
#include "../kernel/fsyscall_gtod_data.h"
-static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
static DEFINE_PER_CPU(unsigned long, xen_stolen_time);
static DEFINE_PER_CPU(unsigned long, xen_blocked_time);
/* taken from i386/kernel/time-xen.c */
static void xen_init_missing_ticks_accounting(int cpu)
{
- struct vcpu_register_runstate_memory_area area;
- struct vcpu_runstate_info *runstate = &per_cpu(xen_runstate, cpu);
- int rc;
+ xen_setup_runstate_info(&runstate);
- memset(runstate, 0, sizeof(*runstate));
-
- area.addr.v = runstate;
- rc = HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu,
- &area);
- WARN_ON(rc && rc != -ENOSYS);
-
- per_cpu(xen_blocked_time, cpu) = runstate->time[RUNSTATE_blocked];
- per_cpu(xen_stolen_time, cpu) = runstate->time[RUNSTATE_runnable]
- + runstate->time[RUNSTATE_offline];
-}
-
-/*
- * Runstate accounting
- */
-/* stolen from arch/x86/xen/time.c */
-static void get_runstate_snapshot(struct vcpu_runstate_info *res)
-{
- u64 state_time;
- struct vcpu_runstate_info *state;
-
- BUG_ON(preemptible());
-
- state = &__get_cpu_var(xen_runstate);
-
- /*
- * 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 = state->state_entry_time;
- rmb();
- *res = *state;
- rmb();
- } while (state->state_entry_time != state_time);
+ per_cpu(xen_blocked_time, cpu) = runstate.time[RUNSTATE_blocked];
+ per_cpu(xen_stolen_time, cpu) = runstate.time[RUNSTATE_runnable]
+ + runstate.time[RUNSTATE_offline];
}
#define NS_PER_TICK (1000000000LL/HZ)
@@ -94,7 +58,7 @@ consider_steal_time(unsigned long new_itm)
struct vcpu_runstate_info runstate;
struct task_struct *p = current;
- get_runstate_snapshot(&runstate);
+ xen_get_runstate_snapshot(&runstate);
/*
* Check for vcpu migration effect
@@ -202,7 +166,7 @@ static unsigned long long xen_sched_clock(void)
*/
now = ia64_native_sched_clock();
- get_runstate_snapshot(&runstate);
+ xen_get_runstate_snapshot(&runstate);
WARN_ON(runstate.state != RUNSTATE_running);
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 12a1ca7..d479444 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -32,86 +32,12 @@
#define TIMER_SLOP 100000
#define NS_PER_TICK (1000000000LL / HZ)
-/* runstate info updated by Xen */
-static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
-
/* snapshots of runstate info */
static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot);
/* unused ns of stolen time */
static DEFINE_PER_CPU(u64, xen_residual_stolen);
-/* return an consistent snapshot of 64-bit time/counter value */
-static u64 get64(const u64 *p)
-{
- u64 ret;
-
- if (BITS_PER_LONG < 64) {
- u32 *p32 = (u32 *)p;
- u32 h, l;
-
- /*
- * Read high then low, and then make sure high is
- * still the same; this will only loop if low wraps
- * and carries into high.
- * XXX some clean way to make this endian-proof?
- */
- do {
- h = p32[1];
- barrier();
- l = p32[0];
- barrier();
- } while (p32[1] != h);
-
- ret = (((u64)h) << 32) | l;
- } else
- ret = *p;
-
- return ret;
-}
-
-/*
- * Runstate accounting
- */
-static void get_runstate_snapshot(struct vcpu_runstate_info *res)
-{
- u64 state_time;
- struct vcpu_runstate_info *state;
-
- BUG_ON(preemptible());
-
- state = &__get_cpu_var(xen_runstate);
-
- /*
- * 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);
- barrier();
- *res = *state;
- barrier();
- } while (get64(&state->state_entry_time) != state_time);
-}
-
-/* return true when a vcpu could run but has no real cpu to run on */
-bool xen_vcpu_stolen(int vcpu)
-{
- return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable;
-}
-
-void xen_setup_runstate_info(int cpu)
-{
- struct vcpu_register_runstate_memory_area area;
-
- area.addr.v = &per_cpu(xen_runstate, cpu);
-
- if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
- cpu, &area))
- BUG();
-}
-
static void do_stolen_accounting(void)
{
struct vcpu_runstate_info state;
@@ -119,7 +45,7 @@ static void do_stolen_accounting(void)
s64 runnable, offline, stolen;
cputime_t ticks;
- get_runstate_snapshot(&state);
+ xen_get_runstate_snapshot(&state);
WARN_ON(state.state != RUNSTATE_running);
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 14fe79d..cd95fb7 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -2,7 +2,7 @@ ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
endif
obj-$(CONFIG_X86) += fallback.o
-obj-y += grant-table.o features.o events.o balloon.o manage.o
+obj-y += grant-table.o features.o events.o balloon.o manage.o time.o
obj-y += xenbus/
nostackp := $(call cc-option, -fno-stack-protector)
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
new file mode 100644
index 0000000..c2e39d3
--- /dev/null
+++ b/drivers/xen/time.c
@@ -0,0 +1,91 @@
+/*
+ * Xen stolen ticks accounting.
+ */
+#include <linux/kernel.h>
+#include <linux/kernel_stat.h>
+#include <linux/math64.h>
+#include <linux/gfp.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+#include <xen/events.h>
+#include <xen/features.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/vcpu.h>
+#include <xen/xen-ops.h>
+
+/* runstate info updated by Xen */
+static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
+
+/* return an consistent snapshot of 64-bit time/counter value */
+static u64 get64(const u64 *p)
+{
+ u64 ret;
+
+ if (BITS_PER_LONG < 64) {
+ u32 *p32 = (u32 *)p;
+ u32 h, l;
+
+ /*
+ * Read high then low, and then make sure high is
+ * still the same; this will only loop if low wraps
+ * and carries into high.
+ * XXX some clean way to make this endian-proof?
+ */
+ do {
+ h = p32[1];
+ barrier();
+ l = p32[0];
+ barrier();
+ } while (p32[1] != h);
+
+ ret = (((u64)h) << 32) | l;
+ } else
+ ret = *p;
+
+ return ret;
+}
+
+/*
+ * Runstate accounting
+ */
+void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
+{
+ u64 state_time;
+ struct vcpu_runstate_info *state;
+
+ BUG_ON(preemptible());
+
+ state = &__get_cpu_var(xen_runstate);
+
+ /*
+ * 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);
+ barrier();
+ *res = *state;
+ barrier();
+ } while (get64(&state->state_entry_time) != state_time);
+}
+
+/* return true when a vcpu could run but has no real cpu to run on */
+bool xen_vcpu_stolen(int vcpu)
+{
+ return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable;
+}
+
+void xen_setup_runstate_info(int cpu)
+{
+ struct vcpu_register_runstate_memory_area area;
+
+ area.addr.v = &per_cpu(xen_runstate, cpu);
+
+ if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
+ cpu, &area))
+ BUG();
+}
+
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index fb2ea8f..ee3303b 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -3,6 +3,7 @@
#include <linux/percpu.h>
#include <asm/xen/interface.h>
+#include <xen/interface/vcpu.h>
DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
@@ -16,6 +17,10 @@ void xen_mm_unpin_all(void);
void xen_timer_resume(void);
void xen_arch_resume(void);
+bool xen_vcpu_stolen(int vcpu);
+void xen_setup_runstate_info(int cpu);
+void xen_get_runstate_snapshot(struct vcpu_runstate_info *res);
+
int xen_setup_shutdown_event(void);
extern unsigned long *xen_contiguous_bitmap;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v9 2/5] kernel: missing include in cputime.c
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c Stefano Stabellini
@ 2014-01-09 18:32 ` Stefano Stabellini
2014-03-25 12:06 ` Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
` (3 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-09 18:32 UTC (permalink / raw)
To: xen-devel
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Stefano.Stabellini, Ian.Campbell, linux, olof, arnd,
catalin.marinas, Stefano Stabellini, mingo, peterz
steal_account_process_tick calls paravirt_steal_clock, but paravirt.h is
currently missing amoung the included header files.
Add include asm/paravirt.h.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: mingo@redhat.com
CC: peterz@infradead.org
---
kernel/sched/cputime.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 9994791..951833e 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -5,6 +5,9 @@
#include <linux/static_key.h>
#include <linux/context_tracking.h>
#include "sched.h"
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#endif
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
--
1.7.10.4
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v9 2/5] kernel: missing include in cputime.c
2014-01-09 18:32 ` [PATCH v9 2/5] kernel: missing include in cputime.c Stefano Stabellini
@ 2014-03-25 12:06 ` Stefano Stabellini
2014-03-25 16:51 ` Stefano Stabellini
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2014-03-25 12:06 UTC (permalink / raw)
To: peterz
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Ian Campbell, linux, olof, arnd, catalin.marinas,
mingo, xen-devel
Peter,
is this patch OK for you?
On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> steal_account_process_tick calls paravirt_steal_clock, but paravirt.h is
> currently missing among the included header files.
> Add include asm/paravirt.h.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: mingo@redhat.com
> CC: peterz@infradead.org
> ---
> kernel/sched/cputime.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 9994791..951833e 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -5,6 +5,9 @@
> #include <linux/static_key.h>
> #include <linux/context_tracking.h>
> #include "sched.h"
> +#ifdef CONFIG_PARAVIRT
> +#include <asm/paravirt.h>
> +#endif
>
>
> #ifdef CONFIG_IRQ_TIME_ACCOUNTING
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v9 2/5] kernel: missing include in cputime.c
2014-03-25 12:06 ` Stefano Stabellini
@ 2014-03-25 16:51 ` Stefano Stabellini
0 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-03-25 16:51 UTC (permalink / raw)
To: Stefano Stabellini
Cc: peterz, linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Ian Campbell, linux, olof, arnd, catalin.marinas,
mingo, xen-devel
Peter,
I am sorry for the confusion, I have already asked you this question and
you have already kindly given me feedback on it. I have even addressed
the problem and resent.
However I wrongly tagged my emails and patch series.
The right patch are v7 and v8, without #ifdef CONFIG_PARAVIRT in
cputime.c:
http://marc.info/?l=linux-kernel&m=138920709703581&w=2
also appended below. I am very sorry for the confusion.
Would that be OK for you?
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 9994791..9f9b76a 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -5,6 +5,7 @@
#include <linux/static_key.h>
#include <linux/context_tracking.h>
#include "sched.h"
+#include <asm/paravirt.h>
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
On Tue, 25 Mar 2014, Stefano Stabellini wrote:
> Peter,
> is this patch OK for you?
>
> On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> > steal_account_process_tick calls paravirt_steal_clock, but paravirt.h is
> > currently missing among the included header files.
> > Add include asm/paravirt.h.
> >
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > CC: mingo@redhat.com
> > CC: peterz@infradead.org
> > ---
> > kernel/sched/cputime.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> > index 9994791..951833e 100644
> > --- a/kernel/sched/cputime.c
> > +++ b/kernel/sched/cputime.c
> > @@ -5,6 +5,9 @@
> > #include <linux/static_key.h>
> > #include <linux/context_tracking.h>
> > #include "sched.h"
> > +#ifdef CONFIG_PARAVIRT
> > +#include <asm/paravirt.h>
> > +#endif
> >
> >
> > #ifdef CONFIG_IRQ_TIME_ACCOUNTING
> > --
> > 1.7.10.4
> >
>
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 2/5] kernel: missing include in cputime.c Stefano Stabellini
@ 2014-01-09 18:32 ` Stefano Stabellini
2014-01-17 15:24 ` Stefano Stabellini
` (2 more replies)
2014-01-09 18:32 ` [PATCH v9 4/5] arm64: " Stefano Stabellini
` (2 subsequent siblings)
5 siblings, 3 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-09 18:32 UTC (permalink / raw)
To: xen-devel
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Stefano.Stabellini, Ian.Campbell, linux, olof, arnd,
catalin.marinas, Stefano Stabellini, nico, cov
Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM.
The only paravirt interface supported is pv_time_ops.steal_clock, so no
runtime pvops patching needed.
This allows us to make use of steal_account_process_tick for stolen
ticks accounting.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
CC: linux@arm.linux.org.uk
CC: will.deacon@arm.com
CC: nico@linaro.org
CC: marc.zyngier@arm.com
CC: cov@codeaurora.org
CC: arnd@arndb.de
CC: olof@lixom.net
---
Changes in v7:
- ifdef CONFIG_PARAVIRT the content of paravirt.h.
Changes in v3:
- improve commit description and Kconfig help text;
- no need to initialize pv_time_ops;
- add PARAVIRT_TIME_ACCOUNTING.
---
arch/arm/Kconfig | 20 ++++++++++++++++++++
arch/arm/include/asm/paravirt.h | 20 ++++++++++++++++++++
arch/arm/kernel/Makefile | 2 ++
arch/arm/kernel/paravirt.c | 25 +++++++++++++++++++++++++
4 files changed, 67 insertions(+)
create mode 100644 arch/arm/include/asm/paravirt.h
create mode 100644 arch/arm/kernel/paravirt.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c1f1a7e..d6c3ba1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1874,6 +1874,25 @@ config SWIOTLB
config IOMMU_HELPER
def_bool SWIOTLB
+config PARAVIRT
+ bool "Enable paravirtualization code"
+ ---help---
+ This changes the kernel so it can modify itself when it is run
+ under a hypervisor, potentially improving performance significantly
+ over full virtualization.
+
+config PARAVIRT_TIME_ACCOUNTING
+ bool "Paravirtual steal time accounting"
+ select PARAVIRT
+ default n
+ ---help---
+ Select this option to enable fine granularity task steal time
+ accounting. Time spent executing other tasks in parallel with
+ the current vCPU is discounted from the vCPU power. To account for
+ that, there can be a small performance impact.
+
+ If in doubt, say N here.
+
config XEN_DOM0
def_bool y
depends on XEN
@@ -1885,6 +1904,7 @@ config XEN
depends on !GENERIC_ATOMIC64
select ARM_PSCI
select SWIOTLB_XEN
+ select PARAVIRT
help
Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
new file mode 100644
index 0000000..8435ff59
--- /dev/null
+++ b/arch/arm/include/asm/paravirt.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_ARM_PARAVIRT_H
+#define _ASM_ARM_PARAVIRT_H
+
+#ifdef CONFIG_PARAVIRT
+struct static_key;
+extern struct static_key paravirt_steal_enabled;
+extern struct static_key paravirt_steal_rq_enabled;
+
+struct pv_time_ops {
+ unsigned long long (*steal_clock)(int cpu);
+};
+extern struct pv_time_ops pv_time_ops;
+
+static inline u64 paravirt_steal_clock(int cpu)
+{
+ return pv_time_ops.steal_clock(cpu);
+}
+#endif
+
+#endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index a30fc9b..34cf9a6 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o
ifneq ($(CONFIG_ARCH_EBSA110),y)
obj-y += io.o
endif
+obj-$(CONFIG_PARAVIRT) += paravirt.o
head-y := head$(MMUEXT).o
obj-$(CONFIG_DEBUG_LL) += debug.o
@@ -97,5 +98,6 @@ ifeq ($(CONFIG_ARM_PSCI),y)
obj-y += psci.o
obj-$(CONFIG_SMP) += psci_smp.o
endif
+obj-$(CONFIG_PARAVIRT) += paravirt.o
extra-y := $(head-y) vmlinux.lds
diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
new file mode 100644
index 0000000..53f371e
--- /dev/null
+++ b/arch/arm/kernel/paravirt.c
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Copyright (C) 2013 Citrix Systems
+ *
+ * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
+ */
+
+#include <linux/export.h>
+#include <linux/jump_label.h>
+#include <linux/types.h>
+#include <asm/paravirt.h>
+
+struct static_key paravirt_steal_enabled;
+struct static_key paravirt_steal_rq_enabled;
+
+struct pv_time_ops pv_time_ops;
+EXPORT_SYMBOL_GPL(pv_time_ops);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:32 ` [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
@ 2014-01-17 15:24 ` Stefano Stabellini
2014-02-17 12:24 ` Stefano Stabellini
2014-03-25 12:07 ` Stefano Stabellini
2 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-17 15:24 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel, linux-kernel, linux-arm-kernel, konrad.wilk,
marc.zyngier, will.deacon, Ian.Campbell, linux, olof, arnd,
catalin.marinas, nico, cov
On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM.
>
> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> runtime pvops patching needed.
>
> This allows us to make use of steal_account_process_tick for stolen
> ticks accounting.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Acked-by: Christopher Covington <cov@codeaurora.org>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> CC: linux@arm.linux.org.uk
> CC: will.deacon@arm.com
> CC: nico@linaro.org
> CC: marc.zyngier@arm.com
> CC: cov@codeaurora.org
> CC: arnd@arndb.de
> CC: olof@lixom.net
Russell? Do you have an opinion on this?
> Changes in v7:
> - ifdef CONFIG_PARAVIRT the content of paravirt.h.
>
> Changes in v3:
> - improve commit description and Kconfig help text;
> - no need to initialize pv_time_ops;
> - add PARAVIRT_TIME_ACCOUNTING.
> ---
> arch/arm/Kconfig | 20 ++++++++++++++++++++
> arch/arm/include/asm/paravirt.h | 20 ++++++++++++++++++++
> arch/arm/kernel/Makefile | 2 ++
> arch/arm/kernel/paravirt.c | 25 +++++++++++++++++++++++++
> 4 files changed, 67 insertions(+)
> create mode 100644 arch/arm/include/asm/paravirt.h
> create mode 100644 arch/arm/kernel/paravirt.c
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index c1f1a7e..d6c3ba1 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1874,6 +1874,25 @@ config SWIOTLB
> config IOMMU_HELPER
> def_bool SWIOTLB
>
> +config PARAVIRT
> + bool "Enable paravirtualization code"
> + ---help---
> + This changes the kernel so it can modify itself when it is run
> + under a hypervisor, potentially improving performance significantly
> + over full virtualization.
> +
> +config PARAVIRT_TIME_ACCOUNTING
> + bool "Paravirtual steal time accounting"
> + select PARAVIRT
> + default n
> + ---help---
> + Select this option to enable fine granularity task steal time
> + accounting. Time spent executing other tasks in parallel with
> + the current vCPU is discounted from the vCPU power. To account for
> + that, there can be a small performance impact.
> +
> + If in doubt, say N here.
> +
> config XEN_DOM0
> def_bool y
> depends on XEN
> @@ -1885,6 +1904,7 @@ config XEN
> depends on !GENERIC_ATOMIC64
> select ARM_PSCI
> select SWIOTLB_XEN
> + select PARAVIRT
> help
> Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
>
> diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
> new file mode 100644
> index 0000000..8435ff59
> --- /dev/null
> +++ b/arch/arm/include/asm/paravirt.h
> @@ -0,0 +1,20 @@
> +#ifndef _ASM_ARM_PARAVIRT_H
> +#define _ASM_ARM_PARAVIRT_H
> +
> +#ifdef CONFIG_PARAVIRT
> +struct static_key;
> +extern struct static_key paravirt_steal_enabled;
> +extern struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops {
> + unsigned long long (*steal_clock)(int cpu);
> +};
> +extern struct pv_time_ops pv_time_ops;
> +
> +static inline u64 paravirt_steal_clock(int cpu)
> +{
> + return pv_time_ops.steal_clock(cpu);
> +}
> +#endif
> +
> +#endif
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index a30fc9b..34cf9a6 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -87,6 +87,7 @@ obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o
> ifneq ($(CONFIG_ARCH_EBSA110),y)
> obj-y += io.o
> endif
> +obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> head-y := head$(MMUEXT).o
> obj-$(CONFIG_DEBUG_LL) += debug.o
> diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
> new file mode 100644
> index 0000000..53f371e
> --- /dev/null
> +++ b/arch/arm/kernel/paravirt.c
> @@ -0,0 +1,25 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * Copyright (C) 2013 Citrix Systems
> + *
> + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> + */
> +
> +#include <linux/export.h>
> +#include <linux/jump_label.h>
> +#include <linux/types.h>
> +#include <asm/paravirt.h>
> +
> +struct static_key paravirt_steal_enabled;
> +struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops pv_time_ops;
> +EXPORT_SYMBOL_GPL(pv_time_ops);
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:32 ` [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
2014-01-17 15:24 ` Stefano Stabellini
@ 2014-02-17 12:24 ` Stefano Stabellini
2014-03-25 12:07 ` Stefano Stabellini
2 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-02-17 12:24 UTC (permalink / raw)
To: linux
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Ian Campbell, olof, arnd, catalin.marinas, nico, cov,
xen-devel
On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM.
>
> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> runtime pvops patching needed.
>
> This allows us to make use of steal_account_process_tick for stolen
> ticks accounting.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Acked-by: Christopher Covington <cov@codeaurora.org>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> CC: linux@arm.linux.org.uk
> CC: will.deacon@arm.com
> CC: nico@linaro.org
> CC: marc.zyngier@arm.com
> CC: cov@codeaurora.org
> CC: arnd@arndb.de
> CC: olof@lixom.net
Russell, are you happy with this patch (for 3.15)?
>
> Changes in v7:
> - ifdef CONFIG_PARAVIRT the content of paravirt.h.
>
> Changes in v3:
> - improve commit description and Kconfig help text;
> - no need to initialize pv_time_ops;
> - add PARAVIRT_TIME_ACCOUNTING.
> ---
> arch/arm/Kconfig | 20 ++++++++++++++++++++
> arch/arm/include/asm/paravirt.h | 20 ++++++++++++++++++++
> arch/arm/kernel/Makefile | 2 ++
> arch/arm/kernel/paravirt.c | 25 +++++++++++++++++++++++++
> 4 files changed, 67 insertions(+)
> create mode 100644 arch/arm/include/asm/paravirt.h
> create mode 100644 arch/arm/kernel/paravirt.c
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index c1f1a7e..d6c3ba1 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1874,6 +1874,25 @@ config SWIOTLB
> config IOMMU_HELPER
> def_bool SWIOTLB
>
> +config PARAVIRT
> + bool "Enable paravirtualization code"
> + ---help---
> + This changes the kernel so it can modify itself when it is run
> + under a hypervisor, potentially improving performance significantly
> + over full virtualization.
> +
> +config PARAVIRT_TIME_ACCOUNTING
> + bool "Paravirtual steal time accounting"
> + select PARAVIRT
> + default n
> + ---help---
> + Select this option to enable fine granularity task steal time
> + accounting. Time spent executing other tasks in parallel with
> + the current vCPU is discounted from the vCPU power. To account for
> + that, there can be a small performance impact.
> +
> + If in doubt, say N here.
> +
> config XEN_DOM0
> def_bool y
> depends on XEN
> @@ -1885,6 +1904,7 @@ config XEN
> depends on !GENERIC_ATOMIC64
> select ARM_PSCI
> select SWIOTLB_XEN
> + select PARAVIRT
> help
> Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
>
> diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
> new file mode 100644
> index 0000000..8435ff59
> --- /dev/null
> +++ b/arch/arm/include/asm/paravirt.h
> @@ -0,0 +1,20 @@
> +#ifndef _ASM_ARM_PARAVIRT_H
> +#define _ASM_ARM_PARAVIRT_H
> +
> +#ifdef CONFIG_PARAVIRT
> +struct static_key;
> +extern struct static_key paravirt_steal_enabled;
> +extern struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops {
> + unsigned long long (*steal_clock)(int cpu);
> +};
> +extern struct pv_time_ops pv_time_ops;
> +
> +static inline u64 paravirt_steal_clock(int cpu)
> +{
> + return pv_time_ops.steal_clock(cpu);
> +}
> +#endif
> +
> +#endif
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index a30fc9b..34cf9a6 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -87,6 +87,7 @@ obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o
> ifneq ($(CONFIG_ARCH_EBSA110),y)
> obj-y += io.o
> endif
> +obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> head-y := head$(MMUEXT).o
> obj-$(CONFIG_DEBUG_LL) += debug.o
> @@ -97,5 +98,6 @@ ifeq ($(CONFIG_ARM_PSCI),y)
> obj-y += psci.o
> obj-$(CONFIG_SMP) += psci_smp.o
> endif
> +obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> extra-y := $(head-y) vmlinux.lds
> diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
> new file mode 100644
> index 0000000..53f371e
> --- /dev/null
> +++ b/arch/arm/kernel/paravirt.c
> @@ -0,0 +1,25 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * Copyright (C) 2013 Citrix Systems
> + *
> + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> + */
> +
> +#include <linux/export.h>
> +#include <linux/jump_label.h>
> +#include <linux/types.h>
> +#include <asm/paravirt.h>
> +
> +struct static_key paravirt_steal_enabled;
> +struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops pv_time_ops;
> +EXPORT_SYMBOL_GPL(pv_time_ops);
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:32 ` [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
2014-01-17 15:24 ` Stefano Stabellini
2014-02-17 12:24 ` Stefano Stabellini
@ 2014-03-25 12:07 ` Stefano Stabellini
2 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-03-25 12:07 UTC (permalink / raw)
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Ian Campbell, linux, olof, arnd, catalin.marinas,
nico, cov, xen-devel, Stefano Stabellini
On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM.
>
> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> runtime pvops patching needed.
>
> This allows us to make use of steal_account_process_tick for stolen
> ticks accounting.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Acked-by: Christopher Covington <cov@codeaurora.org>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> CC: linux@arm.linux.org.uk
> CC: will.deacon@arm.com
> CC: nico@linaro.org
> CC: marc.zyngier@arm.com
> CC: cov@codeaurora.org
> CC: arnd@arndb.de
> CC: olof@lixom.net
Russell,
it this patch OK for you?
> Changes in v7:
> - ifdef CONFIG_PARAVIRT the content of paravirt.h.
>
> Changes in v3:
> - improve commit description and Kconfig help text;
> - no need to initialize pv_time_ops;
> - add PARAVIRT_TIME_ACCOUNTING.
> ---
> arch/arm/Kconfig | 20 ++++++++++++++++++++
> arch/arm/include/asm/paravirt.h | 20 ++++++++++++++++++++
> arch/arm/kernel/Makefile | 2 ++
> arch/arm/kernel/paravirt.c | 25 +++++++++++++++++++++++++
> 4 files changed, 67 insertions(+)
> create mode 100644 arch/arm/include/asm/paravirt.h
> create mode 100644 arch/arm/kernel/paravirt.c
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index c1f1a7e..d6c3ba1 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1874,6 +1874,25 @@ config SWIOTLB
> config IOMMU_HELPER
> def_bool SWIOTLB
>
> +config PARAVIRT
> + bool "Enable paravirtualization code"
> + ---help---
> + This changes the kernel so it can modify itself when it is run
> + under a hypervisor, potentially improving performance significantly
> + over full virtualization.
> +
> +config PARAVIRT_TIME_ACCOUNTING
> + bool "Paravirtual steal time accounting"
> + select PARAVIRT
> + default n
> + ---help---
> + Select this option to enable fine granularity task steal time
> + accounting. Time spent executing other tasks in parallel with
> + the current vCPU is discounted from the vCPU power. To account for
> + that, there can be a small performance impact.
> +
> + If in doubt, say N here.
> +
> config XEN_DOM0
> def_bool y
> depends on XEN
> @@ -1885,6 +1904,7 @@ config XEN
> depends on !GENERIC_ATOMIC64
> select ARM_PSCI
> select SWIOTLB_XEN
> + select PARAVIRT
> help
> Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
>
> diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
> new file mode 100644
> index 0000000..8435ff59
> --- /dev/null
> +++ b/arch/arm/include/asm/paravirt.h
> @@ -0,0 +1,20 @@
> +#ifndef _ASM_ARM_PARAVIRT_H
> +#define _ASM_ARM_PARAVIRT_H
> +
> +#ifdef CONFIG_PARAVIRT
> +struct static_key;
> +extern struct static_key paravirt_steal_enabled;
> +extern struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops {
> + unsigned long long (*steal_clock)(int cpu);
> +};
> +extern struct pv_time_ops pv_time_ops;
> +
> +static inline u64 paravirt_steal_clock(int cpu)
> +{
> + return pv_time_ops.steal_clock(cpu);
> +}
> +#endif
> +
> +#endif
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index a30fc9b..34cf9a6 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -87,6 +87,7 @@ obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o
> ifneq ($(CONFIG_ARCH_EBSA110),y)
> obj-y += io.o
> endif
> +obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> head-y := head$(MMUEXT).o
> obj-$(CONFIG_DEBUG_LL) += debug.o
> @@ -97,5 +98,6 @@ ifeq ($(CONFIG_ARM_PSCI),y)
> obj-y += psci.o
> obj-$(CONFIG_SMP) += psci_smp.o
> endif
> +obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> extra-y := $(head-y) vmlinux.lds
> diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
> new file mode 100644
> index 0000000..53f371e
> --- /dev/null
> +++ b/arch/arm/kernel/paravirt.c
> @@ -0,0 +1,25 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * Copyright (C) 2013 Citrix Systems
> + *
> + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> + */
> +
> +#include <linux/export.h>
> +#include <linux/jump_label.h>
> +#include <linux/types.h>
> +#include <asm/paravirt.h>
> +
> +struct static_key paravirt_steal_enabled;
> +struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops pv_time_ops;
> +EXPORT_SYMBOL_GPL(pv_time_ops);
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
` (2 preceding siblings ...)
2014-01-09 18:32 ` [PATCH v9 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
@ 2014-01-09 18:32 ` Stefano Stabellini
2014-01-10 17:00 ` Catalin Marinas
2014-02-17 12:25 ` Stefano Stabellini
2014-01-09 18:32 ` [PATCH v9 5/5] xen/arm: account for stolen ticks Stefano Stabellini
2014-02-04 15:07 ` [Xen-devel] [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Konrad Rzeszutek Wilk
5 siblings, 2 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-09 18:32 UTC (permalink / raw)
To: xen-devel
Cc: linux, Ian.Campbell, arnd, Stefano Stabellini, marc.zyngier,
Catalin.Marinas, will.deacon, linux-kernel, nico, olof,
linux-arm-kernel, cov
Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
Necessary duplication of paravirt.h and paravirt.c with ARM.
The only paravirt interface supported is pv_time_ops.steal_clock, so no
runtime pvops patching needed.
This allows us to make use of steal_account_process_tick for stolen
ticks accounting.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: will.deacon@arm.com
CC: nico@linaro.org
CC: marc.zyngier@arm.com
CC: cov@codeaurora.org
CC: arnd@arndb.de
CC: olof@lixom.net
CC: Catalin.Marinas@arm.com
---
Changes in v7:
- ifdef CONFIG_PARAVIRT the content of paravirt.h.
---
arch/arm64/Kconfig | 20 ++++++++++++++++++++
arch/arm64/include/asm/paravirt.h | 20 ++++++++++++++++++++
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/paravirt.c | 25 +++++++++++++++++++++++++
4 files changed, 66 insertions(+)
create mode 100644 arch/arm64/include/asm/paravirt.h
create mode 100644 arch/arm64/kernel/paravirt.c
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 6d4dd22..d1003ba 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -212,6 +212,25 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE
source "mm/Kconfig"
+config PARAVIRT
+ bool "Enable paravirtualization code"
+ ---help---
+ This changes the kernel so it can modify itself when it is run
+ under a hypervisor, potentially improving performance significantly
+ over full virtualization.
+
+config PARAVIRT_TIME_ACCOUNTING
+ bool "Paravirtual steal time accounting"
+ select PARAVIRT
+ default n
+ ---help---
+ Select this option to enable fine granularity task steal time
+ accounting. Time spent executing other tasks in parallel with
+ the current vCPU is discounted from the vCPU power. To account for
+ that, there can be a small performance impact.
+
+ If in doubt, say N here.
+
config XEN_DOM0
def_bool y
depends on XEN
@@ -220,6 +239,7 @@ config XEN
bool "Xen guest support on ARM64 (EXPERIMENTAL)"
depends on ARM64 && OF
select SWIOTLB_XEN
+ select PARAVIRT
help
Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64.
diff --git a/arch/arm64/include/asm/paravirt.h b/arch/arm64/include/asm/paravirt.h
new file mode 100644
index 0000000..fd5f428
--- /dev/null
+++ b/arch/arm64/include/asm/paravirt.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_ARM64_PARAVIRT_H
+#define _ASM_ARM64_PARAVIRT_H
+
+#ifdef CONFIG_PARAVIRT
+struct static_key;
+extern struct static_key paravirt_steal_enabled;
+extern struct static_key paravirt_steal_rq_enabled;
+
+struct pv_time_ops {
+ unsigned long long (*steal_clock)(int cpu);
+};
+extern struct pv_time_ops pv_time_ops;
+
+static inline u64 paravirt_steal_clock(int cpu)
+{
+ return pv_time_ops.steal_clock(cpu);
+}
+#endif
+
+#endif
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 5ba2fd4..1dee735 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -18,6 +18,7 @@ arm64-obj-$(CONFIG_SMP) += smp.o smp_spin_table.o
arm64-obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o
arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT)+= hw_breakpoint.o
arm64-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o
obj-y += $(arm64-obj-y) vdso/
obj-m += $(arm64-obj-m)
diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
new file mode 100644
index 0000000..53f371e
--- /dev/null
+++ b/arch/arm64/kernel/paravirt.c
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Copyright (C) 2013 Citrix Systems
+ *
+ * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
+ */
+
+#include <linux/export.h>
+#include <linux/jump_label.h>
+#include <linux/types.h>
+#include <asm/paravirt.h>
+
+struct static_key paravirt_steal_enabled;
+struct static_key paravirt_steal_rq_enabled;
+
+struct pv_time_ops pv_time_ops;
+EXPORT_SYMBOL_GPL(pv_time_ops);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:32 ` [PATCH v9 4/5] arm64: " Stefano Stabellini
@ 2014-01-10 17:00 ` Catalin Marinas
2014-02-17 12:25 ` Stefano Stabellini
1 sibling, 0 replies; 19+ messages in thread
From: Catalin Marinas @ 2014-01-10 17:00 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com,
Marc Zyngier, Will Deacon, Ian.Campbell@citrix.com,
linux@arm.linux.org.uk, olof@lixom.net, arnd@arndb.de,
nico@linaro.org, cov@codeaurora.org
On Thu, Jan 09, 2014 at 06:32:15PM +0000, Stefano Stabellini wrote:
> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
> Necessary duplication of paravirt.h and paravirt.c with ARM.
>
> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> runtime pvops patching needed.
>
> This allows us to make use of steal_account_process_tick for stolen
> ticks accounting.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: will.deacon@arm.com
> CC: nico@linaro.org
> CC: marc.zyngier@arm.com
> CC: cov@codeaurora.org
> CC: arnd@arndb.de
> CC: olof@lixom.net
> CC: Catalin.Marinas@arm.com
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-01-09 18:32 ` [PATCH v9 4/5] arm64: " Stefano Stabellini
2014-01-10 17:00 ` Catalin Marinas
@ 2014-02-17 12:25 ` Stefano Stabellini
2014-02-17 17:55 ` Catalin Marinas
1 sibling, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2014-02-17 12:25 UTC (permalink / raw)
To: Catalin.Marinas
Cc: xen-devel, linux-kernel, linux-arm-kernel, konrad.wilk,
marc.zyngier, will.deacon, Ian Campbell, linux, olof, arnd,
catalin.marinas, nico, cov
On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
> Necessary duplication of paravirt.h and paravirt.c with ARM.
>
> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> runtime pvops patching needed.
>
> This allows us to make use of steal_account_process_tick for stolen
> ticks accounting.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: will.deacon@arm.com
> CC: nico@linaro.org
> CC: marc.zyngier@arm.com
> CC: cov@codeaurora.org
> CC: arnd@arndb.de
> CC: olof@lixom.net
> CC: Catalin.Marinas@arm.com
Catalin, Will, are you happy with this patch for 3.15?
> Changes in v7:
> - ifdef CONFIG_PARAVIRT the content of paravirt.h.
> ---
> arch/arm64/Kconfig | 20 ++++++++++++++++++++
> arch/arm64/include/asm/paravirt.h | 20 ++++++++++++++++++++
> arch/arm64/kernel/Makefile | 1 +
> arch/arm64/kernel/paravirt.c | 25 +++++++++++++++++++++++++
> 4 files changed, 66 insertions(+)
> create mode 100644 arch/arm64/include/asm/paravirt.h
> create mode 100644 arch/arm64/kernel/paravirt.c
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 6d4dd22..d1003ba 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -212,6 +212,25 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE
>
> source "mm/Kconfig"
>
> +config PARAVIRT
> + bool "Enable paravirtualization code"
> + ---help---
> + This changes the kernel so it can modify itself when it is run
> + under a hypervisor, potentially improving performance significantly
> + over full virtualization.
> +
> +config PARAVIRT_TIME_ACCOUNTING
> + bool "Paravirtual steal time accounting"
> + select PARAVIRT
> + default n
> + ---help---
> + Select this option to enable fine granularity task steal time
> + accounting. Time spent executing other tasks in parallel with
> + the current vCPU is discounted from the vCPU power. To account for
> + that, there can be a small performance impact.
> +
> + If in doubt, say N here.
> +
> config XEN_DOM0
> def_bool y
> depends on XEN
> @@ -220,6 +239,7 @@ config XEN
> bool "Xen guest support on ARM64 (EXPERIMENTAL)"
> depends on ARM64 && OF
> select SWIOTLB_XEN
> + select PARAVIRT
> help
> Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64.
>
> diff --git a/arch/arm64/include/asm/paravirt.h b/arch/arm64/include/asm/paravirt.h
> new file mode 100644
> index 0000000..fd5f428
> --- /dev/null
> +++ b/arch/arm64/include/asm/paravirt.h
> @@ -0,0 +1,20 @@
> +#ifndef _ASM_ARM64_PARAVIRT_H
> +#define _ASM_ARM64_PARAVIRT_H
> +
> +#ifdef CONFIG_PARAVIRT
> +struct static_key;
> +extern struct static_key paravirt_steal_enabled;
> +extern struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops {
> + unsigned long long (*steal_clock)(int cpu);
> +};
> +extern struct pv_time_ops pv_time_ops;
> +
> +static inline u64 paravirt_steal_clock(int cpu)
> +{
> + return pv_time_ops.steal_clock(cpu);
> +}
> +#endif
> +
> +#endif
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 5ba2fd4..1dee735 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -18,6 +18,7 @@ arm64-obj-$(CONFIG_SMP) += smp.o smp_spin_table.o
> arm64-obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o
> arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT)+= hw_breakpoint.o
> arm64-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
> +arm64-obj-$(CONFIG_PARAVIRT) += paravirt.o
>
> obj-y += $(arm64-obj-y) vdso/
> obj-m += $(arm64-obj-m)
> diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
> new file mode 100644
> index 0000000..53f371e
> --- /dev/null
> +++ b/arch/arm64/kernel/paravirt.c
> @@ -0,0 +1,25 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * Copyright (C) 2013 Citrix Systems
> + *
> + * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> + */
> +
> +#include <linux/export.h>
> +#include <linux/jump_label.h>
> +#include <linux/types.h>
> +#include <asm/paravirt.h>
> +
> +struct static_key paravirt_steal_enabled;
> +struct static_key paravirt_steal_rq_enabled;
> +
> +struct pv_time_ops pv_time_ops;
> +EXPORT_SYMBOL_GPL(pv_time_ops);
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-02-17 12:25 ` Stefano Stabellini
@ 2014-02-17 17:55 ` Catalin Marinas
2014-03-25 11:19 ` Stefano Stabellini
0 siblings, 1 reply; 19+ messages in thread
From: Catalin Marinas @ 2014-02-17 17:55 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com,
Marc Zyngier, Will Deacon, Ian Campbell, linux@arm.linux.org.uk,
olof@lixom.net, arnd@arndb.de, nico@linaro.org,
cov@codeaurora.org
On Mon, Feb 17, 2014 at 12:25:42PM +0000, Stefano Stabellini wrote:
> On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> > Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
> > Necessary duplication of paravirt.h and paravirt.c with ARM.
> >
> > The only paravirt interface supported is pv_time_ops.steal_clock, so no
> > runtime pvops patching needed.
> >
> > This allows us to make use of steal_account_process_tick for stolen
> > ticks accounting.
> >
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > CC: will.deacon@arm.com
> > CC: nico@linaro.org
> > CC: marc.zyngier@arm.com
> > CC: cov@codeaurora.org
> > CC: arnd@arndb.de
> > CC: olof@lixom.net
> > CC: Catalin.Marinas@arm.com
>
> Catalin, Will, are you happy with this patch for 3.15?
It's pretty small and looks fine to me. However, I would like someone
with more virtualisation experience than me to ack it (e.g. Marc Z).
Some nitpicks:
> > +config PARAVIRT
> > + bool "Enable paravirtualization code"
> > + ---help---
> > + This changes the kernel so it can modify itself when it is run
> > + under a hypervisor, potentially improving performance significantly
> > + over full virtualization.
> > +
> > +config PARAVIRT_TIME_ACCOUNTING
> > + bool "Paravirtual steal time accounting"
> > + select PARAVIRT
> > + default n
> > + ---help---
For consistency with this file, just use "help" rather than
"---help---".
> > --- /dev/null
> > +++ b/arch/arm64/include/asm/paravirt.h
> > @@ -0,0 +1,20 @@
> > +#ifndef _ASM_ARM64_PARAVIRT_H
> > +#define _ASM_ARM64_PARAVIRT_H
__ASM_PARAVIRT_H for consistency.
--
Catalin
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-02-17 17:55 ` Catalin Marinas
@ 2014-03-25 11:19 ` Stefano Stabellini
2014-03-25 11:48 ` Marc Zyngier
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2014-03-25 11:19 UTC (permalink / raw)
To: Marc.Zyngier
Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com,
Will Deacon, Ian Campbell, linux@arm.linux.org.uk, olof@lixom.net,
arnd@arndb.de, nico@linaro.org, cov@codeaurora.org,
catalin.marinas
On Mon, 17 Feb 2014, Catalin Marinas wrote:
> On Mon, Feb 17, 2014 at 12:25:42PM +0000, Stefano Stabellini wrote:
> > On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> > > Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
> > > Necessary duplication of paravirt.h and paravirt.c with ARM.
> > >
> > > The only paravirt interface supported is pv_time_ops.steal_clock, so no
> > > runtime pvops patching needed.
> > >
> > > This allows us to make use of steal_account_process_tick for stolen
> > > ticks accounting.
> > >
> > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > > CC: will.deacon@arm.com
> > > CC: nico@linaro.org
> > > CC: marc.zyngier@arm.com
> > > CC: cov@codeaurora.org
> > > CC: arnd@arndb.de
> > > CC: olof@lixom.net
> > > CC: Catalin.Marinas@arm.com
> >
> > Catalin, Will, are you happy with this patch for 3.15?
>
> It's pretty small and looks fine to me. However, I would like someone
> with more virtualisation experience than me to ack it (e.g. Marc Z).
Ping? Marc, could you please give it a review?
> Some nitpicks:
>
> > > +config PARAVIRT
> > > + bool "Enable paravirtualization code"
> > > + ---help---
> > > + This changes the kernel so it can modify itself when it is run
> > > + under a hypervisor, potentially improving performance significantly
> > > + over full virtualization.
> > > +
> > > +config PARAVIRT_TIME_ACCOUNTING
> > > + bool "Paravirtual steal time accounting"
> > > + select PARAVIRT
> > > + default n
> > > + ---help---
>
> For consistency with this file, just use "help" rather than
> "---help---".
>
> > > --- /dev/null
> > > +++ b/arch/arm64/include/asm/paravirt.h
> > > @@ -0,0 +1,20 @@
> > > +#ifndef _ASM_ARM64_PARAVIRT_H
> > > +#define _ASM_ARM64_PARAVIRT_H
>
> __ASM_PARAVIRT_H for consistency.
>
> --
> Catalin
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-03-25 11:19 ` Stefano Stabellini
@ 2014-03-25 11:48 ` Marc Zyngier
2014-03-25 12:12 ` Stefano Stabellini
0 siblings, 1 reply; 19+ messages in thread
From: Marc Zyngier @ 2014-03-25 11:48 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com,
Will Deacon, Ian Campbell, linux@arm.linux.org.uk, olof@lixom.net,
arnd@arndb.de, nico@linaro.org, cov@codeaurora.org,
Catalin Marinas
On 25/03/14 11:19, Stefano Stabellini wrote:
> On Mon, 17 Feb 2014, Catalin Marinas wrote:
>> On Mon, Feb 17, 2014 at 12:25:42PM +0000, Stefano Stabellini wrote:
>>> On Thu, 9 Jan 2014, Stefano Stabellini wrote:
>>>> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
>>>> Necessary duplication of paravirt.h and paravirt.c with ARM.
>>>>
>>>> The only paravirt interface supported is pv_time_ops.steal_clock, so no
>>>> runtime pvops patching needed.
>>>>
>>>> This allows us to make use of steal_account_process_tick for stolen
>>>> ticks accounting.
>>>>
>>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>>>> CC: will.deacon@arm.com
>>>> CC: nico@linaro.org
>>>> CC: marc.zyngier@arm.com
>>>> CC: cov@codeaurora.org
>>>> CC: arnd@arndb.de
>>>> CC: olof@lixom.net
>>>> CC: Catalin.Marinas@arm.com
>>>
>>> Catalin, Will, are you happy with this patch for 3.15?
>>
>> It's pretty small and looks fine to me. However, I would like someone
>> with more virtualisation experience than me to ack it (e.g. Marc Z).
>
> Ping? Marc, could you please give it a review?
Yup, that looks OK to me. It's a generic feature anyway, so I don't see
any harm in enabling it for Xen. We may also use it for KVM at some point.
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v9 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2014-03-25 11:48 ` Marc Zyngier
@ 2014-03-25 12:12 ` Stefano Stabellini
0 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-03-25 12:12 UTC (permalink / raw)
To: Marc Zyngier
Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com,
Will Deacon, Ian Campbell, linux@arm.linux.org.uk, olof@lixom.net,
arnd@arndb.de, nico@linaro.org, cov@codeaurora.org,
Catalin Marinas
On Tue, 25 Mar 2014, Marc Zyngier wrote:
> On 25/03/14 11:19, Stefano Stabellini wrote:
> > On Mon, 17 Feb 2014, Catalin Marinas wrote:
> >> On Mon, Feb 17, 2014 at 12:25:42PM +0000, Stefano Stabellini wrote:
> >>> On Thu, 9 Jan 2014, Stefano Stabellini wrote:
> >>>> Introduce CONFIG_PARAVIRT and PARAVIRT_TIME_ACCOUNTING on ARM64.
> >>>> Necessary duplication of paravirt.h and paravirt.c with ARM.
> >>>>
> >>>> The only paravirt interface supported is pv_time_ops.steal_clock, so no
> >>>> runtime pvops patching needed.
> >>>>
> >>>> This allows us to make use of steal_account_process_tick for stolen
> >>>> ticks accounting.
> >>>>
> >>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> >>>> CC: will.deacon@arm.com
> >>>> CC: nico@linaro.org
> >>>> CC: marc.zyngier@arm.com
> >>>> CC: cov@codeaurora.org
> >>>> CC: arnd@arndb.de
> >>>> CC: olof@lixom.net
> >>>> CC: Catalin.Marinas@arm.com
> >>>
> >>> Catalin, Will, are you happy with this patch for 3.15?
> >>
> >> It's pretty small and looks fine to me. However, I would like someone
> >> with more virtualisation experience than me to ack it (e.g. Marc Z).
> >
> > Ping? Marc, could you please give it a review?
>
> Yup, that looks OK to me. It's a generic feature anyway, so I don't see
> any harm in enabling it for Xen. We may also use it for KVM at some point.
>
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v9 5/5] xen/arm: account for stolen ticks
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
` (3 preceding siblings ...)
2014-01-09 18:32 ` [PATCH v9 4/5] arm64: " Stefano Stabellini
@ 2014-01-09 18:32 ` Stefano Stabellini
2014-02-04 15:07 ` [Xen-devel] [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Konrad Rzeszutek Wilk
5 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-01-09 18:32 UTC (permalink / raw)
To: xen-devel
Cc: linux-kernel, linux-arm-kernel, konrad.wilk, marc.zyngier,
will.deacon, Stefano.Stabellini, Ian.Campbell, linux, olof, arnd,
catalin.marinas, Stefano Stabellini
Register the runstate_memory_area with the hypervisor.
Use pv_time_ops.steal_clock to account for stolen ticks.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Changes in v4:
- don't use paravirt_steal_rq_enabled: we do not support retrieving
stolen ticks for vcpus other than one we are running on.
Changes in v3:
- use BUG_ON and smp_processor_id.
---
arch/arm/xen/enlighten.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 8550123..fa8bdc0 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -14,7 +14,10 @@
#include <xen/xen-ops.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
+#include <asm/arch_timer.h>
#include <asm/system_misc.h>
+#include <asm/paravirt.h>
+#include <linux/jump_label.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
#include <linux/module.h>
@@ -154,6 +157,19 @@ int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
}
EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
+unsigned long long xen_stolen_accounting(int cpu)
+{
+ struct vcpu_runstate_info state;
+
+ BUG_ON(cpu != smp_processor_id());
+
+ xen_get_runstate_snapshot(&state);
+
+ WARN_ON(state.state != RUNSTATE_running);
+
+ return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
+}
+
static void __init xen_percpu_init(void *unused)
{
struct vcpu_register_vcpu_info info;
@@ -171,6 +187,8 @@ static void __init xen_percpu_init(void *unused)
BUG_ON(err);
per_cpu(xen_vcpu, cpu) = vcpup;
+ xen_setup_runstate_info(cpu);
+
enable_percpu_irq(xen_events_irq, 0);
put_cpu();
}
@@ -313,6 +331,9 @@ static int __init xen_init_events(void)
on_each_cpu(xen_percpu_init, NULL, 0);
+ pv_time_ops.steal_clock = xen_stolen_accounting;
+ static_key_slow_inc(¶virt_steal_enabled);
+
return 0;
}
postcore_initcall(xen_init_events);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [Xen-devel] [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting
2014-01-09 18:15 [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
` (4 preceding siblings ...)
2014-01-09 18:32 ` [PATCH v9 5/5] xen/arm: account for stolen ticks Stefano Stabellini
@ 2014-02-04 15:07 ` Konrad Rzeszutek Wilk
2014-02-17 12:22 ` Stefano Stabellini
5 siblings, 1 reply; 19+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-02-04 15:07 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel@lists.xensource.com, Russell King - ARM Linux,
Ian Campbell, arnd, marc.zyngier@arm.com, Catalin Marinas,
Will Deacon, linux-kernel@vger.kernel.org, Olof Johansson,
linux-arm-kernel@lists.infradead.org
On Thu, Jan 09, 2014 at 06:15:07PM +0000, Stefano Stabellini wrote:
> Hi all,
> this patch series introduces stolen ticks accounting for Xen on ARM and
> ARM64.
> Stolen ticks are clocksource ticks that have been "stolen" from the cpu,
> typically because Linux is running in a virtual machine and the vcpu has
> been descheduled.
> To account for these ticks we introduce CONFIG_PARAVIRT and pv_time_ops
> so that we can make use of:
>
> kernel/sched/cputime.c:steal_account_process_tick
>
>
> Changes in v9:
> - added back missing new files from patches;
> - fix compilation on avr32 (remove patch #5, revert to previous version
> of patch #2).
>
>
>
> Stefano Stabellini (5):
> xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
> kernel: missing include in cputime.c
> arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
> arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
> xen/arm: account for stolen ticks
>
> arch/arm/Kconfig | 20 ++++++++
> arch/arm/include/asm/paravirt.h | 20 ++++++++
> arch/arm/kernel/Makefile | 2 +
> arch/arm/kernel/paravirt.c | 25 ++++++++++
> arch/arm/xen/enlighten.c | 21 +++++++++
> arch/arm64/Kconfig | 20 ++++++++
> arch/arm64/include/asm/paravirt.h | 20 ++++++++
> arch/arm64/kernel/Makefile | 1 +
> arch/arm64/kernel/paravirt.c | 25 ++++++++++
> arch/ia64/xen/time.c | 48 +++----------------
> arch/x86/xen/time.c | 76 +------------------------------
> drivers/xen/Makefile | 2 +-
> drivers/xen/time.c | 91 +++++++++++++++++++++++++++++++++++++
> include/xen/xen-ops.h | 5 ++
> kernel/sched/cputime.c | 3 ++
> 15 files changed, 261 insertions(+), 118 deletions(-)
> create mode 100644 arch/arm/include/asm/paravirt.h
> create mode 100644 arch/arm/kernel/paravirt.c
> create mode 100644 arch/arm64/include/asm/paravirt.h
> create mode 100644 arch/arm64/kernel/paravirt.c
> create mode 100644 drivers/xen/time.c
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git lost_ticks_9
I tried to merge it on top of 3.14-rc1 + stable/for-linus-3.14 (which
has the revert of " xen/grant-table: Avoid m2p_override during mapping"
And I get:
konrad@phenom:~/linux$ git merge stefano/lost_ticks_9
Auto-merging drivers/xen/Makefile
CONFLICT (content): Merge conflict in drivers/xen/Makefile
Auto-merging arch/x86/xen/time.c
CONFLICT (modify/delete): arch/ia64/xen/time.c deleted in HEAD and
modified in stefano/lost_ticks_9. Version stefano/lost_ticks_9 of
arch/ia64/xen/time.c left in tree.
Auto-merging arch/arm64/kernel/Makefile
CONFLICT (content): Merge conflict in arch/arm64/kernel/Makefile
Auto-merging arch/arm64/Kconfig
Auto-merging arch/arm/xen/enlighten.c
CONFLICT (content): Merge conflict in arch/arm/xen/enlighten.c
Auto-merging arch/arm/Kconfig
CONFLICT (content): Merge conflict in arch/arm/Kconfig
Automatic merge failed; fix conflicts and then commit the result.
I presume that is mostly due to David's FIFO queue patches.
Could you kindly rebase it on top 3.14-rc1 and also tack on
Catalin Marinas Ack on the patches?
Thank you!
>
>
> Cheers,
>
> Stefano
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [Xen-devel] [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting
2014-02-04 15:07 ` [Xen-devel] [PATCH v9 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Konrad Rzeszutek Wilk
@ 2014-02-17 12:22 ` Stefano Stabellini
0 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2014-02-17 12:22 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
Russell King - ARM Linux, Ian Campbell, arnd,
marc.zyngier@arm.com, Catalin Marinas, Will Deacon,
linux-kernel@vger.kernel.org, Olof Johansson,
linux-arm-kernel@lists.infradead.org
On Tue, 4 Feb 2014, Konrad Rzeszutek Wilk wrote:
> On Thu, Jan 09, 2014 at 06:15:07PM +0000, Stefano Stabellini wrote:
> > Hi all,
> > this patch series introduces stolen ticks accounting for Xen on ARM and
> > ARM64.
> > Stolen ticks are clocksource ticks that have been "stolen" from the cpu,
> > typically because Linux is running in a virtual machine and the vcpu has
> > been descheduled.
> > To account for these ticks we introduce CONFIG_PARAVIRT and pv_time_ops
> > so that we can make use of:
> >
> > kernel/sched/cputime.c:steal_account_process_tick
> >
> >
> > Changes in v9:
> > - added back missing new files from patches;
> > - fix compilation on avr32 (remove patch #5, revert to previous version
> > of patch #2).
> >
> >
> >
> > Stefano Stabellini (5):
> > xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
> > kernel: missing include in cputime.c
> > arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
> > arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
> > xen/arm: account for stolen ticks
> >
> > arch/arm/Kconfig | 20 ++++++++
> > arch/arm/include/asm/paravirt.h | 20 ++++++++
> > arch/arm/kernel/Makefile | 2 +
> > arch/arm/kernel/paravirt.c | 25 ++++++++++
> > arch/arm/xen/enlighten.c | 21 +++++++++
> > arch/arm64/Kconfig | 20 ++++++++
> > arch/arm64/include/asm/paravirt.h | 20 ++++++++
> > arch/arm64/kernel/Makefile | 1 +
> > arch/arm64/kernel/paravirt.c | 25 ++++++++++
> > arch/ia64/xen/time.c | 48 +++----------------
> > arch/x86/xen/time.c | 76 +------------------------------
> > drivers/xen/Makefile | 2 +-
> > drivers/xen/time.c | 91 +++++++++++++++++++++++++++++++++++++
> > include/xen/xen-ops.h | 5 ++
> > kernel/sched/cputime.c | 3 ++
> > 15 files changed, 261 insertions(+), 118 deletions(-)
> > create mode 100644 arch/arm/include/asm/paravirt.h
> > create mode 100644 arch/arm/kernel/paravirt.c
> > create mode 100644 arch/arm64/include/asm/paravirt.h
> > create mode 100644 arch/arm64/kernel/paravirt.c
> > create mode 100644 drivers/xen/time.c
> >
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git lost_ticks_9
>
> I tried to merge it on top of 3.14-rc1 + stable/for-linus-3.14 (which
> has the revert of " xen/grant-table: Avoid m2p_override during mapping"
>
>
> And I get:
> konrad@phenom:~/linux$ git merge stefano/lost_ticks_9
> Auto-merging drivers/xen/Makefile
> CONFLICT (content): Merge conflict in drivers/xen/Makefile
> Auto-merging arch/x86/xen/time.c
> CONFLICT (modify/delete): arch/ia64/xen/time.c deleted in HEAD and
> modified in stefano/lost_ticks_9. Version stefano/lost_ticks_9 of
> arch/ia64/xen/time.c left in tree.
> Auto-merging arch/arm64/kernel/Makefile
> CONFLICT (content): Merge conflict in arch/arm64/kernel/Makefile
> Auto-merging arch/arm64/Kconfig
> Auto-merging arch/arm/xen/enlighten.c
> CONFLICT (content): Merge conflict in arch/arm/xen/enlighten.c
> Auto-merging arch/arm/Kconfig
> CONFLICT (content): Merge conflict in arch/arm/Kconfig
> Automatic merge failed; fix conflicts and then commit the result.
Sorry for the delay, the series rebased on 3.14-rc3 is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git lost_ticks_10
> I presume that is mostly due to David's FIFO queue patches.
>
> Could you kindly rebase it on top 3.14-rc1 and also tack on
> Catalin Marinas Ack on the patches?
I will.
^ permalink raw reply [flat|nested] 19+ messages in thread