From 8d928648fd816f97ba3ebe98ab5d4b4a7def58ff Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 4 May 2020 11:51:47 +0200 Subject: [PATCH] xenoprof: limit scope of types and #define-s Quite a few of the items are used by xenoprof.c only, so move them there to limit their visibility as well as the amount of re-building needed in case of changes. Also drop the inclusion of the public header there. Signed-off-by: Jan Beulich Acked-by: Wei Liu --- xen/arch/x86/oprofile/nmi_int.c | 2 +- xen/common/xenoprof.c | 26 ++++++++++++++++++++++++++ xen/include/asm-x86/xenoprof.h | 2 ++ xen/include/xen/xenoprof.h | 33 ++------------------------------- xen/xsm/flask/hooks.c | 1 + 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c index 2969db47fc..0f103d80a6 100644 --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index 8a78957fbe..1926a92fe4 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -23,6 +23,32 @@ #undef virt_to_mfn #define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) +#define XENOPROF_DOMAIN_IGNORED 0 +#define XENOPROF_DOMAIN_ACTIVE 1 +#define XENOPROF_DOMAIN_PASSIVE 2 + +#define XENOPROF_IDLE 0 +#define XENOPROF_INITIALIZED 1 +#define XENOPROF_COUNTERS_RESERVED 2 +#define XENOPROF_READY 3 +#define XENOPROF_PROFILING 4 + +#ifndef CONFIG_COMPAT +#define XENOPROF_COMPAT(x) false +typedef struct xenoprof_buf xenoprof_buf_t; +#define xenoprof_buf(d, b, field) ACCESS_ONCE((b)->field) +#else +#include +#define XENOPROF_COMPAT(x) ((x)->is_compat) +typedef union { + struct xenoprof_buf native; + struct compat_oprof_buf compat; +} xenoprof_buf_t; +#define xenoprof_buf(d, b, field) ACCESS_ONCE(*(!(d)->xenoprof->is_compat \ + ? &(b)->native.field \ + : &(b)->compat.field)) +#endif + /* Limit amount of pages used for shared buffer (per domain) */ #define MAX_OPROF_SHARED_PAGES 32 diff --git a/xen/include/asm-x86/xenoprof.h b/xen/include/asm-x86/xenoprof.h index eeac9f2ca1..1026ba2e1f 100644 --- a/xen/include/asm-x86/xenoprof.h +++ b/xen/include/asm-x86/xenoprof.h @@ -26,6 +26,8 @@ struct vcpu; #ifdef CONFIG_XENOPROF +#include + int nmi_reserve_counters(void); int nmi_setup_events(void); int nmi_enable_virq(void); diff --git a/xen/include/xen/xenoprof.h b/xen/include/xen/xenoprof.h index 35f3ea107b..101514c148 100644 --- a/xen/include/xen/xenoprof.h +++ b/xen/include/xen/xenoprof.h @@ -11,7 +11,6 @@ #define __XEN_XENOPROF_H__ #include -#include #include #define PMU_OWNER_NONE 0 @@ -20,37 +19,9 @@ #ifdef CONFIG_XENOPROF -#define XENOPROF_DOMAIN_IGNORED 0 -#define XENOPROF_DOMAIN_ACTIVE 1 -#define XENOPROF_DOMAIN_PASSIVE 2 - -#define XENOPROF_IDLE 0 -#define XENOPROF_INITIALIZED 1 -#define XENOPROF_COUNTERS_RESERVED 2 -#define XENOPROF_READY 3 -#define XENOPROF_PROFILING 4 - -#ifndef CONFIG_COMPAT -typedef struct xenoprof_buf xenoprof_buf_t; -#else -#include -typedef union { - struct xenoprof_buf native; - struct compat_oprof_buf compat; -} xenoprof_buf_t; -#endif - -#ifndef CONFIG_COMPAT -#define XENOPROF_COMPAT(x) 0 -#define xenoprof_buf(d, b, field) ACCESS_ONCE((b)->field) -#else -#define XENOPROF_COMPAT(x) ((x)->is_compat) -#define xenoprof_buf(d, b, field) ACCESS_ONCE(*(!(d)->xenoprof->is_compat \ - ? &(b)->native.field \ - : &(b)->compat.field)) -#endif - struct domain; +struct vcpu; +struct cpu_user_regs; int acquire_pmu_ownership(int pmu_ownership); void release_pmu_ownership(int pmu_ownership); diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 8af8602b46..4649e6fd95 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include -- 2.30.2