* [PATCH v10 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
2015-11-03 16:18 [PATCH v10 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
@ 2015-11-03 16:21 ` Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c Stefano Stabellini
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 16:21 UTC (permalink / raw)
To: linux-arm-kernel
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 at oracle.com
---
Changes in v10:
- rebase
- remove ia64 changes
---
arch/x86/xen/time.c | 76 +----------------------------------------
drivers/xen/Makefile | 2 +-
drivers/xen/time.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
include/xen/xen-ops.h | 5 +++
4 files changed, 98 insertions(+), 76 deletions(-)
create mode 100644 drivers/xen/time.c
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index f1ba6a0..041d4cd 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 = this_cpu_ptr(&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 e293bc5..943fb1c 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 balloon.o manage.o preempt.o
+obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
obj-y += events/
obj-y += xenbus/
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
new file mode 100644
index 0000000..433fe24
--- /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 = this_cpu_ptr(&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 e4e214a..86abe07 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -5,6 +5,7 @@
#include <linux/notifier.h>
#include <linux/efi.h>
#include <asm/xen/interface.h>
+#include <xen/interface/vcpu.h>
DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
@@ -18,6 +19,10 @@ void xen_arch_suspend(void);
void xen_resume_notifier_register(struct notifier_block *nb);
void xen_resume_notifier_unregister(struct notifier_block *nb);
+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] 9+ messages in thread* [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c
2015-11-03 16:18 [PATCH v10 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c Stefano Stabellini
@ 2015-11-03 16:21 ` Stefano Stabellini
2015-11-03 17:17 ` kbuild test robot
2015-11-03 18:25 ` kbuild test robot
2015-11-03 16:21 ` [PATCH v10 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
` (2 subsequent siblings)
4 siblings, 2 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 16:21 UTC (permalink / raw)
To: linux-arm-kernel
ifdef CONFIG_PARAVIRT in sched/core.c is redundant, as asm/paravirt.h
is already protected by #ifdef CONFIG_PARAVIRT.
Add include asm/paravirt.h to cputime.c, as steal_account_process_tick
calls paravirt_steal_clock, which is defined in paravirt.h.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: mingo at redhat.com
CC: peterz at infradead.org
---
kernel/sched/core.c | 2 --
kernel/sched/cputime.c | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bcd214e..395fad9 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -79,9 +79,7 @@
#include <asm/tlb.h>
#include <asm/irq_regs.h>
#include <asm/mutex.h>
-#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
-#endif
#include "sched.h"
#include "../workqueue_internal.h"
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 8cbc3db..a1426fa 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
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c
2015-11-03 16:21 ` [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c Stefano Stabellini
@ 2015-11-03 17:17 ` kbuild test robot
2015-11-03 17:56 ` Stefano Stabellini
2015-11-03 18:25 ` kbuild test robot
1 sibling, 1 reply; 9+ messages in thread
From: kbuild test robot @ 2015-11-03 17:17 UTC (permalink / raw)
To: linux-arm-kernel
Hi Stefano,
[auto build test ERROR on arm64/for-next/core]
[cannot apply to: xen-tip/linux-next]
[also ERROR on: v4.3 next-20151103]
url: https://github.com/0day-ci/linux/commits/Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
base: https://github.com/0day-ci/linux Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
config: mips-jz4740 (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips
All errors (new ones prefixed by >>):
>> kernel/sched/core.c:82:26: fatal error: asm/paravirt.h: No such file or directory
compilation terminated.
--
>> kernel/sched/cputime.c:8:26: fatal error: asm/paravirt.h: No such file or directory
compilation terminated.
vim +82 kernel/sched/core.c
52f5684c kernel/sched/core.c Gideon Israel Dsouza 2014-04-07 76 #include <linux/compiler.h>
^1da177e kernel/sched.c Linus Torvalds 2005-04-16 77
96f951ed kernel/sched/core.c David Howells 2012-03-28 78 #include <asm/switch_to.h>
5517d86b kernel/sched.c Eric Dumazet 2007-05-08 79 #include <asm/tlb.h>
838225b4 kernel/sched.c Satyam Sharma 2007-10-24 80 #include <asm/irq_regs.h>
db7e527d kernel/sched/core.c Christian Borntraeger 2012-01-11 81 #include <asm/mutex.h>
e6e6685a kernel/sched.c Glauber Costa 2011-07-11 @82 #include <asm/paravirt.h>
^1da177e kernel/sched.c Linus Torvalds 2005-04-16 83
029632fb kernel/sched.c Peter Zijlstra 2011-10-25 84 #include "sched.h"
ea138446 kernel/sched/core.c Tejun Heo 2013-01-18 85 #include "../workqueue_internal.h"
:::::: The code at line 82 was first introduced by commit
:::::: e6e6685accfa81f509fadfc9624bc7c3862d75c4 KVM guest: Steal time accounting
:::::: TO: Glauber Costa <glommer@redhat.com>
:::::: CC: Avi Kivity <avi@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 17582 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151104/90f9f698/attachment-0001.obj>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c
2015-11-03 17:17 ` kbuild test robot
@ 2015-11-03 17:56 ` Stefano Stabellini
0 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 17:56 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 4 Nov 2015, kbuild test robot wrote:
> Hi Stefano,
>
> [auto build test ERROR on arm64/for-next/core]
> [cannot apply to: xen-tip/linux-next]
> [also ERROR on: v4.3 next-20151103]
>
> url: https://github.com/0day-ci/linux/commits/Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
> base: https://github.com/0day-ci/linux Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
> config: mips-jz4740 (attached as .config)
Ah, of course! I only tested x86, arm and arm64, but this wouldn't work
on any arches without arm/paravirt.h. Damn.
I guess we'll have to keep
#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
#endif
BTW this auto build test is awesome.
> reproduce:
> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=mips
>
> All errors (new ones prefixed by >>):
>
> >> kernel/sched/core.c:82:26: fatal error: asm/paravirt.h: No such file or directory
> compilation terminated.
> --
> >> kernel/sched/cputime.c:8:26: fatal error: asm/paravirt.h: No such file or directory
> compilation terminated.
>
> vim +82 kernel/sched/core.c
>
> 52f5684c kernel/sched/core.c Gideon Israel Dsouza 2014-04-07 76 #include <linux/compiler.h>
> ^1da177e kernel/sched.c Linus Torvalds 2005-04-16 77
> 96f951ed kernel/sched/core.c David Howells 2012-03-28 78 #include <asm/switch_to.h>
> 5517d86b kernel/sched.c Eric Dumazet 2007-05-08 79 #include <asm/tlb.h>
> 838225b4 kernel/sched.c Satyam Sharma 2007-10-24 80 #include <asm/irq_regs.h>
> db7e527d kernel/sched/core.c Christian Borntraeger 2012-01-11 81 #include <asm/mutex.h>
> e6e6685a kernel/sched.c Glauber Costa 2011-07-11 @82 #include <asm/paravirt.h>
> ^1da177e kernel/sched.c Linus Torvalds 2005-04-16 83
> 029632fb kernel/sched.c Peter Zijlstra 2011-10-25 84 #include "sched.h"
> ea138446 kernel/sched/core.c Tejun Heo 2013-01-18 85 #include "../workqueue_internal.h"
>
> :::::: The code at line 82 was first introduced by commit
> :::::: e6e6685accfa81f509fadfc9624bc7c3862d75c4 KVM guest: Steal time accounting
>
> :::::: TO: Glauber Costa <glommer@redhat.com>
> :::::: CC: Avi Kivity <avi@redhat.com>
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c
2015-11-03 16:21 ` [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c Stefano Stabellini
2015-11-03 17:17 ` kbuild test robot
@ 2015-11-03 18:25 ` kbuild test robot
1 sibling, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2015-11-03 18:25 UTC (permalink / raw)
To: linux-arm-kernel
Hi Stefano,
[auto build test ERROR on arm64/for-next/core]
[cannot apply to: xen-tip/linux-next]
[also ERROR on: v4.3 next-20151103]
url: https://github.com/0day-ci/linux/commits/Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
base: https://github.com/0day-ci/linux Stefano-Stabellini/xen-arm-arm64-CONFIG_PARAVIRT-and-stolen-ticks-accounting/20151104-002433
config: avr32-atngw100_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=avr32
All errors (new ones prefixed by >>):
>> kernel/sched/core.c:82:26: error: asm/paravirt.h: No such file or directory
--
>> kernel/sched/cputime.c:8:26: error: asm/paravirt.h: No such file or directory
vim +82 kernel/sched/core.c
52f5684c kernel/sched/core.c Gideon Israel Dsouza 2014-04-07 76 #include <linux/compiler.h>
^1da177e kernel/sched.c Linus Torvalds 2005-04-16 77
96f951ed kernel/sched/core.c David Howells 2012-03-28 78 #include <asm/switch_to.h>
5517d86b kernel/sched.c Eric Dumazet 2007-05-08 79 #include <asm/tlb.h>
838225b4 kernel/sched.c Satyam Sharma 2007-10-24 80 #include <asm/irq_regs.h>
db7e527d kernel/sched/core.c Christian Borntraeger 2012-01-11 81 #include <asm/mutex.h>
e6e6685a kernel/sched.c Glauber Costa 2011-07-11 @82 #include <asm/paravirt.h>
^1da177e kernel/sched.c Linus Torvalds 2005-04-16 83
029632fb kernel/sched.c Peter Zijlstra 2011-10-25 84 #include "sched.h"
ea138446 kernel/sched/core.c Tejun Heo 2013-01-18 85 #include "../workqueue_internal.h"
:::::: The code at line 82 was first introduced by commit
:::::: e6e6685accfa81f509fadfc9624bc7c3862d75c4 KVM guest: Steal time accounting
:::::: TO: Glauber Costa <glommer@redhat.com>
:::::: CC: Avi Kivity <avi@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 11783 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151104/89e802ff/attachment.obj>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v10 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2015-11-03 16:18 [PATCH v10 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 2/5] missing include in cputime.c, remove #ifdef CONFIG_PARAVIRT from sched/core.c Stefano Stabellini
@ 2015-11-03 16:21 ` Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 4/5] arm64: " Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 5/5] xen/arm: account for stolen ticks Stefano Stabellini
4 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 16:21 UTC (permalink / raw)
To: linux-arm-kernel
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 at arm.linux.org.uk
CC: will.deacon at arm.com
CC: nico at linaro.org
CC: marc.zyngier at arm.com
CC: cov at codeaurora.org
CC: arnd at arndb.de
CC: olof at lixom.net
---
Changes in v10:
- replace "---help---" with "help"
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 | 1 +
arch/arm/kernel/paravirt.c | 25 +++++++++++++++++++++++++
4 files changed, 66 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 639411f..8dfdaa6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1819,6 +1819,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
@@ -1832,6 +1851,7 @@ config XEN
select ARCH_DMA_ADDR_T_64BIT
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 af9e59b..3e6e937 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_VDSO) += vdso.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 related [flat|nested] 9+ messages in thread* [PATCH v10 4/5] arm64: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops
2015-11-03 16:18 [PATCH v10 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
` (2 preceding siblings ...)
2015-11-03 16:21 ` [PATCH v10 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
@ 2015-11-03 16:21 ` Stefano Stabellini
2015-11-03 16:21 ` [PATCH v10 5/5] xen/arm: account for stolen ticks Stefano Stabellini
4 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 16:21 UTC (permalink / raw)
To: linux-arm-kernel
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>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
CC: will.deacon at arm.com
CC: nico at linaro.org
CC: marc.zyngier at arm.com
CC: cov at codeaurora.org
CC: arnd at arndb.de
CC: olof at lixom.net
CC: Catalin.Marinas at arm.com
---
Changes in v10:
- replace "---help---" with "help"
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 07d1811..c8bd7dc 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -491,6 +491,25 @@ config SECCOMP
and the task is only allowed to execute a few safe syscalls
defined by each seccomp mode.
+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
@@ -499,6 +518,7 @@ config XEN
bool "Xen guest support on ARM64"
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 22dc9bc..54fda9a 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -36,6 +36,7 @@ arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
arm64-obj-$(CONFIG_PCI) += pci.o
arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
arm64-obj-$(CONFIG_ACPI) += acpi.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] 9+ messages in thread* [PATCH v10 5/5] xen/arm: account for stolen ticks
2015-11-03 16:18 [PATCH v10 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
` (3 preceding siblings ...)
2015-11-03 16:21 ` [PATCH v10 4/5] arm64: " Stefano Stabellini
@ 2015-11-03 16:21 ` Stefano Stabellini
4 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2015-11-03 16:21 UTC (permalink / raw)
To: linux-arm-kernel
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 eeeab07..7dd2cc0 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>
@@ -79,6 +82,19 @@ int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
}
EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range);
+static 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 xen_percpu_init(void)
{
struct vcpu_register_vcpu_info info;
@@ -96,6 +112,8 @@ static void xen_percpu_init(void)
BUG_ON(err);
per_cpu(xen_vcpu, cpu) = vcpup;
+ xen_setup_runstate_info(cpu);
+
enable_percpu_irq(xen_events_irq, 0);
put_cpu();
}
@@ -259,6 +277,9 @@ static int __init xen_guest_init(void)
register_cpu_notifier(&xen_cpu_notifier);
+ pv_time_ops.steal_clock = xen_stolen_accounting;
+ static_key_slow_inc(¶virt_steal_enabled);
+
return 0;
}
early_initcall(xen_guest_init);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread