Skip to contentSkip to conversation

PMU: make {acquire, release}_pmu_ownership names consistent

PATCH In review Doug Goldstein 5 participants 11 messages Feb 17, 2016 – Feb 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 PMU: make {acquire, release}_pmu_ownership names consistent

The function names were inconsistent with acquire and release being called acquire_pmu_ownership() and release_pmu_ownship() respectively. Function prototypes were available for both spellings so this change makes them consistent and drops the dual function prototypes. Additionally change the internal variable names within those functions to ownership as well.

---
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Aravind Gopalakrishnan <[email protected]>
CC: Keir Fraser <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

change since v2:
- new in this series based on review

---
 xen/arch/x86/cpu/vpmu_amd.c   |  4 ++--
 xen/arch/x86/cpu/vpmu_intel.c |  4 ++--
 xen/common/xenoprof.c         | 12 ++++++------
 xen/include/asm-x86/vpmu.h    |  3 ---
 xen/include/xen/xenoprof.h    |  4 ++--
 5 files changed, 12 insertions(+), 15 deletions(-)
xen/arch/x86/cpu/vpmu_amd.c +2 -2
index 990e6f3..55d03b3 100644
@@ -393,7 +393,7 @@ 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);
+        release_pmu_ownership(PMU_OWNER_HVM);
     }
 
     if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED)
@@ -442,7 +442,7 @@ static void amd_vpmu_destroy(struct vcpu *v)
     vpmu->priv_context = NULL;
 
     if ( vpmu_is_set(vpmu, VPMU_RUNNING) )
-        release_pmu_ownship(PMU_OWNER_HVM);
+        release_pmu_ownership(PMU_OWNER_HVM);
 
     vpmu_clear(vpmu);
 }
xen/arch/x86/cpu/vpmu_intel.c +2 -2
index 50b5831..e8049ed 100644
@@ -517,7 +517,7 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)
     return 1;
 
 out_err:
-    release_pmu_ownship(PMU_OWNER_HVM);
+    release_pmu_ownership(PMU_OWNER_HVM);
 
     xfree(core2_vpmu_cxt);
     xfree(p);
@@ -892,7 +892,7 @@ 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);
+    release_pmu_ownership(PMU_OWNER_HVM);
     vpmu_clear(vpmu);
 }
 
xen/common/xenoprof.c +6 -6
index 19b4605..7a3fc86 100644
@@ -50,16 +50,16 @@ static u64 passive_samples;
 static u64 idle_samples;
 static u64 others_samples;
 
-int acquire_pmu_ownership(int pmu_ownship)
+int acquire_pmu_ownership(int pmu_ownership)
 {
     spin_lock(&pmu_owner_lock);
     if ( pmu_owner == PMU_OWNER_NONE )
     {
-        pmu_owner = pmu_ownship;
+        pmu_owner = pmu_ownership;
         goto out;
     }
 
-    if ( pmu_owner == pmu_ownship )
+    if ( pmu_owner == pmu_ownership )
         goto out;
 
     spin_unlock(&pmu_owner_lock);
@@ -71,10 +71,10 @@ int acquire_pmu_ownership(int pmu_ownship)
     return 1;
 }
 
-void release_pmu_ownship(int pmu_ownship)
+void release_pmu_ownership(int pmu_ownership)
 {
     spin_lock(&pmu_owner_lock);
-    if ( pmu_ownship == PMU_OWNER_HVM )
+    if ( pmu_ownership == PMU_OWNER_HVM )
         pmu_hvm_refcount--;
     if ( !pmu_hvm_refcount )
         pmu_owner = PMU_OWNER_NONE;
@@ -847,7 +847,7 @@ ret_t do_xenoprof_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
             break;
         x = current->domain->xenoprof;
         unshare_xenoprof_page_with_guest(x);
-        release_pmu_ownship(PMU_OWNER_XENOPROF);
+        release_pmu_ownership(PMU_OWNER_XENOPROF);
         break;
     }
 
xen/include/asm-x86/vpmu.h +0 -3
index 67e73dc..ed9ec07 100644
@@ -121,9 +121,6 @@ static inline int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
     return vpmu_do_msr(msr, msr_content, 0, 0);
 }
 
-extern int acquire_pmu_ownership(int pmu_ownership);
-extern void release_pmu_ownership(int pmu_ownership);
-
 extern unsigned int vpmu_mode;
 extern unsigned int vpmu_features;
 
xen/include/xen/xenoprof.h +2 -2
index 7804e69..9b9ef56 100644
@@ -73,8 +73,8 @@ 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
-int acquire_pmu_ownship(int pmu_ownership);
-void release_pmu_ownship(int pmu_ownership);
+int acquire_pmu_ownership(int pmu_ownership);
+void release_pmu_ownership(int pmu_ownership);
 
 void xenoprof_log_event(struct vcpu *, const struct cpu_user_regs *,
                         uint64_t pc, int mode, int event);
Signature · 1 line
2.4.10
#1 lore raw

PATCH v3 1/3 PMU: make {acquire, release}_pmu_ownership names consistent

The function names were inconsistent with acquire and release being called acquire_pmu_ownership() and release_pmu_ownship() respectively. Function prototypes were available for both spellings so this change makes them consistent and drops the dual function prototypes. Additionally change the internal variable names within those functions to ownership as well.

---
change since v2:
- new in this series based on review

---
 xen/arch/x86/cpu/vpmu_amd.c   |  4 ++--
 xen/arch/x86/cpu/vpmu_intel.c |  4 ++--
 xen/common/xenoprof.c         | 12 ++++++------
 xen/include/asm-x86/vpmu.h    |  3 ---
 xen/include/xen/xenoprof.h    |  4 ++--
 5 files changed, 12 insertions(+), 15 deletions(-)
xen/arch/x86/cpu/vpmu_amd.c +2 -2
index 990e6f3..55d03b3 100644
@@ -393,7 +393,7 @@ 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);
+        release_pmu_ownership(PMU_OWNER_HVM);
     }
 
     if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED)
@@ -442,7 +442,7 @@ static void amd_vpmu_destroy(struct vcpu *v)
     vpmu->priv_context = NULL;
 
     if ( vpmu_is_set(vpmu, VPMU_RUNNING) )
-        release_pmu_ownship(PMU_OWNER_HVM);
+        release_pmu_ownership(PMU_OWNER_HVM);
 
     vpmu_clear(vpmu);
 }
xen/arch/x86/cpu/vpmu_intel.c +2 -2
index 50b5831..e8049ed 100644
@@ -517,7 +517,7 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)
     return 1;
 
 out_err:
-    release_pmu_ownship(PMU_OWNER_HVM);
+    release_pmu_ownership(PMU_OWNER_HVM);
 
     xfree(core2_vpmu_cxt);
     xfree(p);
@@ -892,7 +892,7 @@ 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);
+    release_pmu_ownership(PMU_OWNER_HVM);
     vpmu_clear(vpmu);
 }
 
xen/common/xenoprof.c +6 -6
index 19b4605..7a3fc86 100644
@@ -50,16 +50,16 @@ static u64 passive_samples;
 static u64 idle_samples;
 static u64 others_samples;
 
-int acquire_pmu_ownership(int pmu_ownship)
+int acquire_pmu_ownership(int pmu_ownership)
 {
     spin_lock(&pmu_owner_lock);
     if ( pmu_owner == PMU_OWNER_NONE )
     {
-        pmu_owner = pmu_ownship;
+        pmu_owner = pmu_ownership;
         goto out;
     }
 
-    if ( pmu_owner == pmu_ownship )
+    if ( pmu_owner == pmu_ownership )
         goto out;
 
     spin_unlock(&pmu_owner_lock);
@@ -71,10 +71,10 @@ int acquire_pmu_ownership(int pmu_ownship)
     return 1;
 }
 
-void release_pmu_ownship(int pmu_ownship)
+void release_pmu_ownership(int pmu_ownership)
 {
     spin_lock(&pmu_owner_lock);
-    if ( pmu_ownship == PMU_OWNER_HVM )
+    if ( pmu_ownership == PMU_OWNER_HVM )
         pmu_hvm_refcount--;
     if ( !pmu_hvm_refcount )
         pmu_owner = PMU_OWNER_NONE;
@@ -847,7 +847,7 @@ ret_t do_xenoprof_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
             break;
         x = current->domain->xenoprof;
         unshare_xenoprof_page_with_guest(x);
-        release_pmu_ownship(PMU_OWNER_XENOPROF);
+        release_pmu_ownership(PMU_OWNER_XENOPROF);
         break;
     }
 
xen/include/asm-x86/vpmu.h +0 -3
index 67e73dc..ed9ec07 100644
@@ -121,9 +121,6 @@ static inline int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
     return vpmu_do_msr(msr, msr_content, 0, 0);
 }
 
-extern int acquire_pmu_ownership(int pmu_ownership);
-extern void release_pmu_ownership(int pmu_ownership);
-
 extern unsigned int vpmu_mode;
 extern unsigned int vpmu_features;
 
xen/include/xen/xenoprof.h +2 -2
index 7804e69..9b9ef56 100644
@@ -73,8 +73,8 @@ 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
-int acquire_pmu_ownship(int pmu_ownership);
-void release_pmu_ownship(int pmu_ownership);
+int acquire_pmu_ownership(int pmu_ownership);
+void release_pmu_ownership(int pmu_ownership);
 
 void xenoprof_log_event(struct vcpu *, const struct cpu_user_regs *,
                         uint64_t pc, int mode, int event);
Signature · 1 line
2.4.10
#2 lore raw

PATCH v3 2/3 xenoprof: fix up ability to disable it

In reply to 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]>

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     | 24 ++++++++++++++++++++++++
 xen/include/xen/xenoprof.h         | 25 +++++++++++++++++++------
 7 files changed, 54 insertions(+), 8 deletions(-)
xen/arch/x86/Makefile +1 -1
index 8e6e901..434d985 100644
@@ -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
index a1cdae0..94e4efd 100644
@@ -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
index 3088aa7..6424ed0 100644
@@ -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
index 94a54aa..0a73878 100644
@@ -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
index d97877d..a45d3ee 100644
@@ -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 +24 -0
index b006ddc..c78e8cf 100644
@@ -67,9 +67,33 @@ 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)
+{
+    (void)msr;
+    (void)msr_content;
+    return 0;
+}
+
+static inline int passive_domain_do_wrmsr(unsigned int msr,
+                                          uint64_t *msr_content)
+{
+    (void)msr;
+    (void)msr_content;
+    return 0;
+}
+
+static inline void passive_domain_destroy(struct vcpu *v)
+{
+    (void)v;
+}
+#endif
 
 #endif /* __ASM_X86_XENOPROF_H__ */
 
xen/include/xen/xenoprof.h +19 -6
index 9b9ef56..1eb3d69 100644
@@ -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 void acquire_pmu_ownership(int pmu_ownership) {
+    (void)pmu_ownership;
+    return 1;
+}
+
+static inline void release_pmu_ownership(int pmu_ownership) {
+    (void)pmu_ownership;
+}
+#endif
+
 #endif  /* __XEN__XENOPROF_H__ */
Signature · 1 line
2.4.10
#3 lore raw

Re: [PATCH v3 2/3] xenoprof: fix up ability to disable it

Quoted 9 lines · Doug Goldstein
xen/include/asm-x86/xenoprof.h +1 -0
index b006ddc..c78e8cf 100644
@@ -67,9 +67,33 @@ void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *,
                  "xenoprof/x86 with autotranslated mode enabled"    \
                  "isn't supported yet\n");                          \
     } while (0)
+

xen/include/asm-x86/xenoprof.h void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *, · line 80

Quoted 10 lines
xen/include/asm-x86/xenoprof.h +7 -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)
+{
+    (void)msr;
+    (void)msr_content;

You don't need these inside a static inline. The callsite of the static inline will cause the parameters to be evaluated.

They are needed for macros, as macros end up being a transformation of the text at the callsite itself.

~Andrew

Quoted 19 lines
xen/include/asm-x86/xenoprof.h +16 -0
+    return 0;
+}
+
+static inline int passive_domain_do_wrmsr(unsigned int msr,
+                                          uint64_t *msr_content)
+{
+    (void)msr;
+    (void)msr_content;
+    return 0;
+}
+
+static inline void passive_domain_destroy(struct vcpu *v)
+{
+    (void)v;
+}
+#endif
 
 #endif /* __ASM_X86_XENOPROF_H__ */
 
#4 lore raw

PATCH v3 2/3 xenoprof: fix up ability to disable it

In reply to Doug Goldstein

Allow Xenoprof to be fully disabled when toggling the option off.

---
change since v2:
- move all functions in xenoprof.h inside CONFIG_XENOPROF 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/vpmu.h         |  4 ++++
 xen/include/asm-x86/xenoprof.h     |  7 +++++++
 xen/include/xen/xenoprof.h         | 25 +++++++++++++++++++------
 8 files changed, 41 insertions(+), 8 deletions(-)
xen/arch/x86/Makefile +1 -1
index 8e6e901..434d985 100644
@@ -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
index a1cdae0..94e4efd 100644
@@ -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
index 3088aa7..6424ed0 100644
@@ -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
index 94a54aa..0a73878 100644
@@ -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
index d97877d..a45d3ee 100644
@@ -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/vpmu.h +4 -0
index ed9ec07..bf479c5 100644
@@ -89,10 +89,14 @@ static inline void vpmu_clear(struct vpmu_struct *vpmu)
 {
     vpmu->flags = 0;
 }
+#ifdef CONFIG_XENOPROF
 static inline bool_t vpmu_is_set(const struct vpmu_struct *vpmu, const u32 mask)
 {
     return !!(vpmu->flags & mask);
 }
+#else
+#define vpmu_is_set(x, y) (!!0)
+#endif
 static inline bool_t vpmu_are_all_set(const struct vpmu_struct *vpmu,
                                       const u32 mask)
 {
xen/include/asm-x86/xenoprof.h +7 -0
index b006ddc..9574f33 100644
@@ -67,9 +67,16 @@ 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
+#define passive_domain_do_rdmsr(x, y) (0)
+#define passive_domain_do_wrmsr(x, y) (0)
+#define passive_domain_destroy(x)
+#endif
 
 #endif /* __ASM_X86_XENOPROF_H__ */
 
xen/include/xen/xenoprof.h +19 -6
index 9b9ef56..1eb3d69 100644
@@ -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 void acquire_pmu_ownership(int pmu_ownership) {
+    (void)pmu_ownership;
+    return 1;
+}
+
+static inline void release_pmu_ownership(int pmu_ownership) {
+    (void)pmu_ownership;
+}
+#endif
+
 #endif  /* __XEN__XENOPROF_H__ */
Signature · 1 line
2.4.10
#5 lore raw

PATCH v3 3/3 build: convert xenoprof to Kconfig

In reply to Doug Goldstein

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 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    | 14 ++++++++++++++
 xen/common/Makefile   |  2 +-
 4 files changed, 16 insertions(+), 5 deletions(-)
xen/arch/x86/Makefile +1 -1
index 434d985..1bcb08b 100644
@@ -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
index 94e4efd..14519e3 100644
@@ -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 +14 -0
index 6f404b4..e4ba46d 100644
@@ -84,6 +84,20 @@ config LATE_HWDOM
 
 	  If unsure, say N.
 
+# Adds support for Xenoprof
+config XENOPROF
+	bool
+	prompt "Xen Oprofile Support" if EXPERT = "y"
+	default 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
index 6e82b33..126d373 100644
@@ -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
#6 lore raw

PATCH v3 3/3 build: convert xenoprof to Kconfig

In reply to Doug Goldstein

Convert the xenoprof x86 build time option to Kconfig.

---
 xen/arch/x86/Makefile |  2 +-
 xen/arch/x86/Rules.mk |  3 ---
 xen/common/Kconfig    | 14 ++++++++++++++
 xen/common/Makefile   |  2 +-
 4 files changed, 16 insertions(+), 5 deletions(-)
xen/arch/x86/Makefile +1 -1
index 434d985..1bcb08b 100644
@@ -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
index 94e4efd..14519e3 100644
@@ -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 +14 -0
index 6f404b4..e4ba46d 100644
@@ -84,6 +84,20 @@ config LATE_HWDOM
 
 	  If unsure, say N.
 
+# Adds support for Xenoprof
+config XENOPROF
+	bool
+	prompt "Xen Oprofile Support" if EXPERT = "y"
+	default 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
index 6e82b33..126d373 100644
@@ -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
Acked-by on v3 3/3
#7 lore raw

Re: [PATCH v3 3/3] build: convert xenoprof to Kconfig

xen/common/Kconfig config LATE_HWDOM · line 91

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 17.02.16 at 15:37, <[email protected]> wrote:
xen/common/Kconfig +5 -0
@@ -84,6 +84,20 @@ config LATE_HWDOM
 
 	  If unsure, say N.
 
+# Adds support for Xenoprof
+config XENOPROF
+	bool
+	prompt "Xen Oprofile Support" if EXPERT = "y"
+	default y

Due to the separate "prompt" this could use "def_bool y".

xen/common/Makefile obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 · line 65

Quoted 8 lines
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

Please take the opportunity to add this back at the right slot in the main section listing objects.

With these two adjustments

Jan

Reviewed-by on v3 1/3
#8 lore raw
In reply to Doug Goldstein
Quoted 8 lines · Doug Goldstein

The function names were inconsistent with acquire and release being called acquire_pmu_ownership() and release_pmu_ownship() respectively. Function prototypes were available for both spellings so this change makes them consistent and drops the dual function prototypes. Additionally change the internal variable names within those functions to ownership as well.

Reviewed-by on v3 1/3
#9 lore raw
In reply to Doug Goldstein
Quoted 6 lines · Doug Goldstein

The function names were inconsistent with acquire and release being called acquire_pmu_ownership() and release_pmu_ownship() respectively. Function prototypes were available for both spellings so this change makes them consistent and drops the dual function prototypes. Additionally change the internal variable names within those functions to ownership as well.

although I think

xen/common/xenoprof.c static u64 passive_samples; · line 55

Quoted 13 lines
xen/common/xenoprof.c +1 -1
index 19b4605..7a3fc86 100644
@@ -50,16 +50,16 @@ static u64 passive_samples;
  static u64 idle_samples;
  static u64 others_samples;
 
-int acquire_pmu_ownership(int pmu_ownship)
+int acquire_pmu_ownership(int pmu_ownership)
  {
 

using 'new_pmu_owner' as argument might be slightly better.

-boris

Acked-by on v3 1/3
#10 lore raw
In reply to Doug Goldstein
Quoted 11 lines

From: Doug Goldstein [mailto:[email protected]]
Sent: Wednesday, February 17, 2016 10:38 PM

The function names were inconsistent with acquire and release being called acquire_pmu_ownership() and release_pmu_ownship() respectively. Function prototypes were available for both spellings so this change makes them consistent and drops the dual function prototypes. Additionally change the internal variable names within those functions to ownership as well.