xenoprof: fix up ability to disable it
PATCH 1/2 xenoprof: fix up ability to disable it
Allow Xenoprof to be fully disabled when toggling the option off.
--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 2 ++ xen/arch/x86/cpu/vpmu_amd.c | 9 ++++++--- xen/arch/x86/cpu/vpmu_intel.c | 9 ++++++--- xen/arch/x86/hvm/svm/svm.c | 4 +++- xen/arch/x86/hvm/vmx/vmx.c | 12 ++++++++---- xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - 9 files changed, 34 insertions(+), 13 deletions(-)
xen/arch/x86/Makefile +1 -1
@@ -3,7 +3,7 @@ subdir-y += cpu subdir-y += genapic subdir-y += hvm subdir-y += mm -subdir-y += oprofile +subdir-$(xenoprof) += oprofile subdir-y += x86_64 obj-bin-y += alternative.init.o
xen/arch/x86/Rules.mk +2 -0
@@ -10,6 +10,8 @@ CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' +CFLAGS-$(xenoprof) += -DCONFIG_XENOPROF + # Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float
xen/arch/x86/cpu/vpmu_amd.c +6 -3
@@ -22,6 +22,7 @@*/ #include <xen/config.h> +#include <xen/kconfig.h> #include <xen/xenoprof.h> #include <xen/hvm/save.h> #include <xen/sched.h>
@@ -378,7 +379,8 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,if ( (type ==MSR_TYPE_CTRL ) &&is_pmu_enabled (msr_content) && !vpmu_is_set (vpmu,VPMU_RUNNING ) ) { -if ( !acquire_pmu_ownership (PMU_OWNER_HVM ) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && + !acquire_pmu_ownership (PMU_OWNER_HVM ) )return 0 ;vpmu_set (vpmu,VPMU_RUNNING );
@@ -393,7 +395,8 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,vpmu_reset (vpmu,VPMU_RUNNING );if (has_hvm_container_vcpu (v) &&is_msr_bitmap_on (vpmu) )amd_vpmu_unset_msr_bitmap (v); -release_pmu_ownship (PMU_OWNER_HVM ); +if (IS_ENABLED (CONFIG_XENOPROF ) ) +release_pmu_ownship (PMU_OWNER_HVM ); } if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED)
@@ -441,7 +444,7 @@ static void amd_vpmu_destroy(struct vcpu *v) vpmu->context =NULL ; vpmu->priv_context =NULL ; -if (vpmu_is_set (vpmu,VPMU_RUNNING ) ) +if (IS_ENABLED (CONFIG_XENOPROF ) &&vpmu_is_set (vpmu,VPMU_RUNNING ) )release_pmu_ownship (PMU_OWNER_HVM );vpmu_clear (vpmu);
xen/arch/x86/cpu/vpmu_intel.c +6 -3
@@ -19,6 +19,7 @@*/ #include <xen/config.h> +#include <xen/kconfig.h> #include <xen/sched.h> #include <xen/xenoprof.h> #include <xen/irq.h>
@@ -476,7 +477,7 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)struct xen_pmu_intel_ctxt *core2_vpmu_cxt =NULL ;uint64_t *p =NULL ; -if ( !acquire_pmu_ownership (PMU_OWNER_HVM ) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && !acquire_pmu_ownership (PMU_OWNER_HVM ) )return 0 ;if (has_hvm_container_vcpu (v) )
@@ -517,7 +518,8 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)return 1 ; out_err: -release_pmu_ownship (PMU_OWNER_HVM ); +if (IS_ENABLED (CONFIG_XENOPROF ) ) +release_pmu_ownship (PMU_OWNER_HVM );xfree (core2_vpmu_cxt);xfree (p);
@@ -892,7 +894,8 @@ static void core2_vpmu_destroy(struct vcpu *v) vpmu->priv_context =NULL ;if (has_hvm_container_vcpu (v) && cpu_has_vmx_msr_bitmap )core2_vpmu_unset_msr_bitmap (v->arch.hvm_vmx.msr_bitmap); -release_pmu_ownship (PMU_OWNER_HVM ); +if (IS_ENABLED (CONFIG_XENOPROF ) ) +release_pmu_ownship (PMU_OWNER_HVM );vpmu_clear (vpmu); }
xen/arch/x86/hvm/svm/svm.c +3 -1
@@ -17,6 +17,7 @@*/ #include <xen/config.h> +#include <xen/kconfig.h> #include <xen/init.h> #include <xen/lib.h> #include <xen/trace.h>
@@ -1214,7 +1215,8 @@ static void svm_vcpu_destroy(struct vcpu *v) {vpmu_destroy (v);svm_destroy_vmcb (v); -passive_domain_destroy (v); +if (IS_ENABLED (CONFIG_XENOPROF ) ) +passive_domain_destroy (v); }static void svm_inject_trap (const struct hvm_trap *trap)
xen/arch/x86/hvm/vmx/vmx.c +8 -4
@@ -16,6 +16,7 @@*/ #include <xen/config.h> +#include <xen/kconfig.h> #include <xen/init.h> #include <xen/lib.h> #include <xen/trace.h>
@@ -173,7 +174,8 @@ static void vmx_vcpu_destroy(struct vcpu *v)vmx_vcpu_disable_pml (v);vmx_destroy_vmcs (v);vpmu_destroy (v); -passive_domain_destroy (v); +if (IS_ENABLED (CONFIG_XENOPROF ) ) +passive_domain_destroy (v); } static DEFINE_PER_CPU(struct vmx_msr_state, host_msr_state);
@@ -2447,7 +2449,8 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) goto gp_fault;break ;default : -if (passive_domain_do_rdmsr (msr, msr_content) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && +passive_domain_do_rdmsr (msr, msr_content) ) goto done;switch (long_mode_do_msr_read (msr, msr_content) ) {
@@ -2666,10 +2669,11 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) goto gp_fault;break ;default : -if (passive_domain_do_wrmsr (msr, msr_content) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && +passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ; -if (wrmsr_viridian_regs (msr, msr_content) ) +if (wrmsr_viridian_regs (msr, msr_content) )break ; switch ( long_mode_do_msr_write(msr, msr_content) )
xen/arch/x86/x86_64/compat/entry.S +4 -0
@@ -394,6 +394,10 @@ compat_crash_page_fault: #define compat_kexec_op do_ni_hypercall #endif +#ifndef CONFIG_XENOPROF +#define compat_xenoprof_op do_ni_hypercall +#endif + ENTRY(compat_hypercall_table) .quad compat_set_trap_table /* 0 */ .quad do_mmu_update
xen/arch/x86/x86_64/entry.S +4 -0
@@ -727,6 +727,10 @@ ENTRY(exception_table) #define do_kexec_op do_ni_hypercall #endif +#ifndef CONFIG_XENOPROF +#define do_xenoprof_op do_ni_hypercall +#endif + ENTRY(hypercall_table) .quad do_set_trap_table /* 0 */ .quad do_mmu_update
xen/include/asm-x86/config.h +0 -1
@@ -47,7 +47,6 @@#define CONFIG_VGA 1#define CONFIG_VIDEO 1 -#define CONFIG_XENOPROF 1#define CONFIG_WATCHDOG 1#define CONFIG_MULTIBOOT 1
Signature · 1 line
2.4.10
PATCH 2/2 build: convert xenoprof to Kconfig
Convert the xenoprof x86 build time option to Kconfig.
--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 3 --- xen/common/Kconfig | 13 +++++++++++++ xen/common/Makefile | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-)
xen/arch/x86/Makefile +1 -1
@@ -3,7 +3,7 @@ subdir-y += cpu subdir-y += genapic subdir-y += hvm subdir-y += mm -subdir-$(xenoprof) += oprofile +subdir-$(CONFIG_XENOPROF) += oprofile subdir-y += x86_64 obj-bin-y += alternative.init.o
xen/arch/x86/Rules.mk +0 -3
@@ -3,15 +3,12 @@ HAS_NUMA := y HAS_CORE_PARKING := y -xenoprof := y CFLAGS += -I$(BASEDIR)/include CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' -CFLAGS-$(xenoprof) += -DCONFIG_XENOPROF - # Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float
xen/common/Kconfig +13 -0
@@ -84,6 +84,19 @@ config LATE_HWDOM If unsure, say N. +# Adds support for Xenoprof +config XENOPROF + bool "Xenoprof support" + default y + depends on X86 + ---help--- + Xenoprof is a system-wide profiler for Xen virtual machine + environments, capable of profiling the Xen virtual machine monitor, + multiple Linux guest operating systems, and applications running on + them. + + If unsure, say Y. + # Enable/Disable XSM support config XSM bool "Xen Security Modules support"
xen/common/Makefile +1 -1
@@ -62,7 +62,7 @@ obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o -obj-$(xenoprof) += xenoprof.o +obj-$(CONFIG_XENOPROF) += xenoprof.o obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o tmem_xen.o xlat.o)
Signature · 1 line
2.4.10
Re: [PATCH 2/2] build: convert xenoprof to Kconfig
xen/common/Kconfig config LATE_HWDOM · line 89
Quoted 11 lines · Doug Goldstein
xen/common/Kconfig +3
-0@@ -84,6 +84,19 @@ config LATE_HWDOM If unsure, say N. +# Adds support for Xenoprof +config XENOPROF + bool "Xenoprof support"
Despite the awkward CONFIG name, this is Xen Oprofile Support
With the bits of text updated appropriately, Reviewed-by: Andrew Cooper <[email protected]>
Quoted 26 lines
xen/common/Kconfig +10
-0+ default y + depends on X86 + ---help--- + Xenoprof is a system-wide profiler for Xen virtual machine + environments, capable of profiling the Xen virtual machine monitor, + multiple Linux guest operating systems, and applications running on + them. + + If unsure, say Y. + # Enable/Disable XSM support config XSM bool "Xen Security Modules support"xen/common/Makefile +1
-1@@ -62,7 +62,7 @@ obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o -obj-$(xenoprof) += xenoprof.o +obj-$(CONFIG_XENOPROF) += xenoprof.o obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o tmem_xen.o xlat.o)
Quoted 15 lines · Doug Goldstein
Allow Xenoprof to be fully disabled when toggling the option off.
CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Andrew Cooper <[email protected]>CC Boris Ostrovsky <[email protected]>CC Suravee Suthikulpanit <[email protected]>CC Aravind Gopalakrishnan <[email protected]>CC Jun Nakajima <[email protected]>CC Kevin Tian <[email protected]>Signed-off-by Doug Goldstein <[email protected]>xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -2666,10 +2669,11 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) goto gp_fault;
xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) · line 2677
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-2break ;default : -if (passive_domain_do_wrmsr (msr, msr_content) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && +passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ; -if (wrmsr_viridian_regs (msr, msr_content) ) +if (wrmsr_viridian_regs (msr, msr_content) )break ;
Looks like a stray change.
Other than that,
While at it --- I think we should put VPMU code under CONFIG option too, especially given its support status. I can do that (unless Doug wants to).
-boris
Quoted 31 lines · Boris Ostrovsky
Quoted 15 lines · Doug Goldstein
Allow Xenoprof to be fully disabled when toggling the option off.
CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Andrew Cooper <[email protected]>CC Boris Ostrovsky <[email protected]>CC Suravee Suthikulpanit <[email protected]>CC Aravind Gopalakrishnan <[email protected]>CC Jun Nakajima <[email protected]>CC Kevin Tian <[email protected]>Signed-off-by Doug Goldstein <[email protected]>xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -2666,10 +2669,11 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content)xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_write_intercept(unsigned · line 2678
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-1goto gp_fault;break ;default : -if (passive_domain_do_wrmsr (msr, msr_content) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && +passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ; - if ( wrmsr_viridian_regs(msr, msr_content) ) +if (wrmsr_viridian_regs (msr, msr_content) )break ;Looks like a stray change.
Quoted 8 lines
Other than that,
Reviewed-by Boris Ostrovsky <[email protected]>While at it --- I think we should put VPMU code under CONFIG option too, especially given its support status. I can do that (unless Doug wants to).
-boris
Boris,
Thanks for the review. I didn't add your Reviewed-by because I've reworked this patch to take into account Andrew Cooper's suggestion to provide dummy function calls instead of wrapping everything with IS_ENABLED().
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 31 lines · Boris Ostrovsky
Quoted 15 lines · Doug Goldstein
Allow Xenoprof to be fully disabled when toggling the option off.
CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Andrew Cooper <[email protected]>CC Boris Ostrovsky <[email protected]>CC Suravee Suthikulpanit <[email protected]>CC Aravind Gopalakrishnan <[email protected]>CC Jun Nakajima <[email protected]>CC Kevin Tian <[email protected]>Signed-off-by Doug Goldstein <[email protected]>xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -2666,10 +2669,11 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content)xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_write_intercept(unsigned · line 2678
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-1goto gp_fault;break ;default : -if (passive_domain_do_wrmsr (msr, msr_content) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && +passive_domain_do_wrmsr (msr, msr_content) )return X86EMUL_OKAY ; - if ( wrmsr_viridian_regs(msr, msr_content) ) +if (wrmsr_viridian_regs (msr, msr_content) )break ;Looks like a stray change.
Quoted 8 lines
Other than that,
Reviewed-by Boris Ostrovsky <[email protected]>While at it --- I think we should put VPMU code under CONFIG option too, especially given its support status. I can do that (unless Doug wants to).
-boris
Boris,
I forgot to answer the VPMU part. If you have the bandwidth to do that I'll happily test it. Otherwise I'm not sure when I'll have a chance to wrap it with Kconfig.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines · Doug Goldstein
Quoted 4 lines · Boris Ostrovsky
While at it --- I think we should put VPMU code under CONFIG option too, especially given its support status. I can do that (unless Doug wants to).
I forgot to answer the VPMU part. If you have the bandwidth to do that I'll happily test it. Otherwise I'm not sure when I'll have a chance to wrap it with
Kconfig.
Sure, I'll do that once I get a few other things cleared.
-boris
Quoted 13 lines · Doug Goldstein
xen/arch/x86/cpu/vpmu_amd.c +1
-0@@ -22,6 +22,7 @@*/ #include <xen/config.h> +#include <xen/kconfig.h> #include <xen/xenoprof.h> #include <xen/hvm/save.h> #include <xen/sched.h>
xen/arch/x86/cpu/vpmu_amd.c static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, · line 386
Quoted 9 lines
xen/arch/x86/cpu/vpmu_amd.c +2
-1@@ -378,7 +379,8 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,if ( (type ==MSR_TYPE_CTRL ) &&is_pmu_enabled (msr_content) && !vpmu_is_set (vpmu,VPMU_RUNNING ) ) { -if ( !acquire_pmu_ownership (PMU_OWNER_HVM ) ) +if (IS_ENABLED (CONFIG_XENOPROF ) && + !acquire_pmu_ownership (PMU_OWNER_HVM ) )return 0 ;vpmu_set (vpmu,VPMU_RUNNING );
Instead of modifying each caller into the oprofile code like this, I wonder whether it would be neater to produce an empty set of static inlines in xenoprof.h when !CONFIG_XENOPROF, similar to CONFIG_SHADOW_PAGING in xen/include/asm-x86/shadow.h
~Andrew