xenoprof: fix up ability to disable it
PATCH v4 1/2 xenoprof: fix up ability to disable it
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]>
change since v3:
- drop (void)var; from static inlines
- fix typo that broke build (must have forgotten to do XEN_CONFIG_EXPERT=y make change since v2:
- move all functions in xenoprof.h inside CONFIG_XENOPROF as suggested by Andrew Cooper
change since v1:
- switch to #define empty 'functions' as suggested by Andrew Cooper
--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 2 ++ xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - xen/include/asm-x86/xenoprof.h | 19 +++++++++++++++++++ xen/include/xen/xenoprof.h | 25 +++++++++++++++++++------ 7 files changed, 49 insertions(+), 8 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/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
xen/include/asm-x86/xenoprof.h +19 -0
@@ -67,9 +67,28 @@ void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *,"xenoprof/x86 with autotranslated mode enabled" \ "isn't supported yet\n"); \ } while (0) + +#ifdef CONFIG_XENOPROF int passive_domain_do_rdmsr (unsigned int msr,uint64_t *msr_content);int passive_domain_do_wrmsr (unsigned int msr,uint64_t msr_content);void passive_domain_destroy (struct vcpu *v); +#else +static inline int passive_domain_do_rdmsr (unsigned int msr, +uint64_t *msr_content) +{ +return 0 ; +} + +static inline int passive_domain_do_wrmsr (unsigned int msr, +uint64_t msr_content) +{ +return 0 ; +} + +static inline void passive_domain_destroy (struct vcpu *v) +{ +} +#endif #endif /* __ASM_X86_XENOPROF_H__ */
xen/include/xen/xenoprof.h +19 -6
@@ -64,19 +64,32 @@ struct xenoprof {#endif struct domain ; -int is_active (struct domain *d); -int is_passive (struct domain *d); -void free_xenoprof_pages (struct domain *d); - -int xenoprof_add_trace (struct vcpu *,uint64_t pc,int mode); -#define PMU_OWNER_NONE 0#define PMU_OWNER_XENOPROF 1#define PMU_OWNER_HVM 2 + +#ifdef CONFIG_XENOPROF int acquire_pmu_ownership (int pmu_ownership);void release_pmu_ownership (int pmu_ownership); +int is_active (struct domain *d); +int is_passive (struct domain *d); +void free_xenoprof_pages (struct domain *d); + +int xenoprof_add_trace (struct vcpu *,uint64_t pc,int mode); +void xenoprof_log_event (struct vcpu *,const struct cpu_user_regs *,uint64_t pc,int mode,int event); +#else +static inline int acquire_pmu_ownership (int pmu_ownership) +{ +return 1 ; +} + +static inline void release_pmu_ownership (int pmu_ownership) +{ +} +#endif +#endif /* __XEN__XENOPROF_H__ */
Signature · 1 line
2.4.10
PATCH v4 2/2 build: convert xenoprof to Kconfig
Convert the xenoprof x86 build time option to Kconfig.
---
CC: Keir Fraser <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
change since v3:
- move xenoprof entry to the main sources list
- combine 'default' and 'bool' into 'def_bool' change since v2:
- require EXPERT for XENOPROF as suggested by Jan Beulich change since v1:
- fix name of Kconfig entry as suggested by Andrew Cooper
--- 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 + def_bool y + prompt "Xen Oprofile Support" if EXPERT = "y" + depends on X86 + ---help--- + Xen OProfile (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
@@ -57,13 +57,13 @@ obj-y += vm_event.o obj-y += vmap.o obj-y += vsprintf.o obj-y += wait.o +obj-$(CONFIG_XENOPROF) += xenoprof.o obj-y += xmalloc_tlsf.o obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 earlycpio,$(n).init.o) obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o -obj-$(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
Quoted 99 lines · Doug Goldstein
Allow Xenoprof to be fully disabled when toggling the option off.
Signed-off-by Doug Goldstein <[email protected]>---
CC: Keir Fraser <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>change since v3:
- drop (void)var; from static inlines
- fix typo that broke build (must have forgotten to do XEN_CONFIG_EXPERT=y make change since v2:
- move all functions inxenoprof.hinsideCONFIG_XENOPROFas suggested by Andrew Cooper
change since v1:
- switch to #define empty 'functions' as suggested by Andrew Cooper--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 2 ++ xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - xen/include/asm-x86/xenoprof.h | 19 +++++++++++++++++++ xen/include/xen/xenoprof.h | 25 +++++++++++++++++++------ 7 files changed, 49 insertions(+), 8 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.oxen/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-floatxen/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_updatexen/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_updatexen/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 1xen/include/asm-x86/xenoprof.h +0
-0
xen/include/asm-x86/xenoprof.h void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *, · line 71
Quoted 5 lines
xen/include/asm-x86/xenoprof.h +2
-0@@ -67,9 +67,28 @@ void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *,"xenoprof/x86 with autotranslated mode enabled" \ "isn't supported yet\n"); \ }while (0 ) + +#ifdef CONFIG_XENOPROF
Sorry for not commenting before you resubmitted.
I would suggest having this #ifdef immediately under this files inclusion guard. That way you hide all symbols and declarations in the !CONFIG_XENOPROF case. Given that this patch compiles, I don't expect you will encounter any issues from moving it.
xen/include/asm-x86/xenoprof.h void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *, · line 75
Quoted 4 lines
xen/include/asm-x86/xenoprof.h +1
-0int passive_domain_do_rdmsr (unsigned int msr,uint64_t *msr_content);int passive_domain_do_wrmsr (unsigned int msr,uint64_t msr_content);void passive_domain_destroy (struct vcpu *v); +#else
As a matter of style, please put newlines around here to space it out a bit, and /* CONFIG_XENOPROF */ after the else, as the original #if is a long way away.
xen/include/asm-x86/xenoprof.h void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *, · line 88
Quoted 13 lines
xen/include/asm-x86/xenoprof.h +13
-0+static inline int passive_domain_do_rdmsr (unsigned int msr, +uint64_t *msr_content) +{ +return 0 ; +} + +static inline int passive_domain_do_wrmsr (unsigned int msr, +uint64_t msr_content) +{ +return 0 ; +} + +static inline void passive_domain_destroy (struct vcpu *v)
For brevity, "static inline void passive_domain_destroy(struct vcpu *v) {}" is perfectly fine here.
Quoted 15 lines
xen/include/asm-x86/xenoprof.h +3
-0+{ +} +#endif #endif /* __ASM_X86_XENOPROF_H__ */ xen/include/xen/xenoprof.h +0
-1@@ -64,19 +64,32 @@ struct xenoprof {#endif struct domain ; -int is_active (struct domain *d);
xen/include/xen/xenoprof.h struct xenoprof { · line 71
Quoted 10 lines
xen/include/xen/xenoprof.h +2
-5-int is_passive (struct domain *d); -void free_xenoprof_pages (struct domain *d); - -int xenoprof_add_trace (struct vcpu *,uint64_t pc,int mode); -#define PMU_OWNER_NONE 0#define PMU_OWNER_XENOPROF 1#define PMU_OWNER_HVM 2 + +#ifdef CONFIG_XENOPROF
Same comment concerning the position of this #ifdef. I can't see any symbols which will cause an issue.
With these issues addressed, Reviewed-by: Andrew Cooper <[email protected]>