xen/perfc: Cleanup, and wire up for RISCV/PPC
cover xen/perfc: Cleanup, and wire up for RISCV/PPC
This started as just patch 3 fixing a header tangle with FRED on x86, but grew somewhat.
It's simple, straight forward, and gets perf counters working uniformly on all architectures, and a net reduction in code.
It's low risk, and should be considered for 4.20 at this juncture.
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1609450793
Andrew Cooper (5):
xen/perfc: Drop arch_perfc_{gather,reset}()
xen/perfc: Add perfc_defn.h to asm-generic
xen/perfc: Trim includes
xen/perfc: Cleanup
xen/perfc: COMPILE TEST
automation/gitlab-ci/build.yaml | 1 - xen/Kconfig.debug | 14 ++++---------- xen/arch/arm/include/asm/perfc.h | 21 --------------------- xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/arch/x86/include/asm/perfc.h | 12 ------------ xen/common/perfc.c | 26 ++++++++++---------------- xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc.h | 26 ++++++++++++-------------- xen/include/xen/perfc_defn.h | 2 ++ 10 files changed, 35 insertions(+), 74 deletions(-) delete mode 100644 xen/arch/arm/include/asm/perfc.h delete mode 100644 xen/arch/x86/include/asm/perfc.h create mode 100644 xen/include/asm-generic/perfc_defn.h
base-commit: a1746cd4434dd27ca2da8430dfb10edc76264bb3
Signature · 1 line
2.39.5
PATCH 1/5 xen/perfc: Drop arch_perfc_{gather,reset}()
These were only ever used by the IA64 port, which was droped in commit 570c311ca2c7 ("remove ia64").
Remove them, and clean up the arm/x86 stub headers.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- xen/arch/arm/include/asm/perfc.h | 21 --------------------- xen/arch/x86/include/asm/perfc.h | 12 ------------ xen/common/perfc.c | 6 ------ 3 files changed, 39 deletions(-) delete mode 100644 xen/arch/arm/include/asm/perfc.h delete mode 100644 xen/arch/x86/include/asm/perfc.h
xen/arch/arm/include/asm/perfc.h deleted +0 -21
@@ -1,21 +0,0 @@ -#ifndef __ASM_PERFC_H__ -#define __ASM_PERFC_H__ - -static inline void arch_perfc_reset (void ) -{ -} - -static inline void arch_perfc_gather (void ) -{ -} - -#endif - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/
xen/arch/x86/include/asm/perfc.h deleted +0 -12
@@ -1,12 +0,0 @@ -#ifndef __ASM_PERFC_H__ -#define __ASM_PERFC_H__ - -static inline void arch_perfc_reset (void ) -{ -} - -static inline void arch_perfc_gather (void ) -{ -} - -#endif
xen/common/perfc.c +0 -6
@@ -8,7 +8,6 @@#include <xen/mm.h> #include <xen/guest_access.h> #include <public/sysctl.h> -#include <asm/perfc.h> #define PERFCOUNTER ( var, name ) { name, TYPE_SINGLE, 0 },#define PERFCOUNTER_ARRAY ( var, name, size ) { name, TYPE_ARRAY, size },
@@ -148,8 +147,6 @@ void cf_check perfc_reset(unsigned char key)break ; } } - -arch_perfc_reset (); }static struct xen_sysctl_perfc_desc perfc_d[NR_PERFCTRS ];
@@ -199,9 +196,6 @@ static int perfc_copy_info(XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc,if ( perfc_vals ==NULL )return -ENOMEM ; -/* Architecture may fill counters from hardware. */ -arch_perfc_gather (); -/* We gather the counts together every time. */ for ( i = j = v =0 ; i <NR_PERFCTRS ; i++ ) {
Signature · 1 line
2.39.5
Re: [PATCH 1/5] xen/perfc: Drop arch_perfc_{gather,reset}()
Quoted 6 lines · Andrew Cooper
These were only ever used by the IA64 port, which was droped in commit
570c311ca2c7("remove ia64").Remove them, and clean up the arm/x86 stub headers.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 97 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- xen/arch/arm/include/asm/perfc.h | 21 --------------------- xen/arch/x86/include/asm/perfc.h | 12 ------------ xen/common/perfc.c | 6 ------ 3 files changed, 39 deletions(-) delete mode 100644 xen/arch/arm/include/asm/perfc.h delete mode 100644 xen/arch/x86/include/asm/perfc.hxen/arch/arm/include/asm/perfc.h deleted +0
-21@@ -1,21 +0,0 @@ -#ifndef __ASM_PERFC_H__ -#define __ASM_PERFC_H__ - -static inline void arch_perfc_reset (void ) -{ -} - -static inline void arch_perfc_gather (void ) -{ -} - -#endif - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/ xen/arch/x86/include/asm/perfc.h deleted +0
-12@@ -1,12 +0,0 @@ -#ifndef __ASM_PERFC_H__ -#define __ASM_PERFC_H__ - -static inline void arch_perfc_reset (void ) -{ -} - -static inline void arch_perfc_gather (void ) -{ -} - -#endif xen/common/perfc.c +0
-6@@ -8,7 +8,6 @@#include <xen/mm.h> #include <xen/guest_access.h> #include <public/sysctl.h> -#include <asm/perfc.h> #define PERFCOUNTER ( var, name ) { name, TYPE_SINGLE, 0 },#define PERFCOUNTER_ARRAY ( var, name, size ) { name, TYPE_ARRAY, size },@@ -148,8 +147,6 @@ void cf_check perfc_reset(unsigned char key)break ; } } - -arch_perfc_reset (); }static struct xen_sysctl_perfc_desc perfc_d[NR_PERFCTRS ];@@ -199,9 +196,6 @@ static int perfc_copy_info(XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc,if ( perfc_vals ==NULL )return -ENOMEM ; -/* Architecture may fill counters from hardware. */ -arch_perfc_gather (); -/* We gather the counts together every time. */ for ( i = j = v =0 ; i <NR_PERFCTRS ; i++ ) {Signature · 1 line
2.39.5
PATCH 2/5 xen/perfc: Add perfc_defn.h to asm-generic
In reply to Andrew Cooper... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in errno.h, so include it explicitly.
Guard the hypercalls array declaration based on NR_hypercalls existing. This is sufficient to get PERF_COUNTERS fully working on RISC-V and PPC, so drop the randconfig override.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- automation/gitlab-ci/build.yaml | 1 - xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/common/perfc.c | 1 + xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc_defn.h | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 xen/include/asm-generic/perfc_defn.h
automation/gitlab-ci/build.yaml +0 -1
@@ -734,7 +734,6 @@ debian-12-riscv64-gcc: CONFIG_GRANT_TABLE=n CONFIG_LIVEPATCH=n CONFIG_MEM_ACCESS=n - CONFIG_PERF_COUNTERS=n CONFIG_QEMU_PLATFORM=y CONFIG_XSM=n
xen/arch/ppc/include/asm/Makefile +1 -0
@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.h
xen/arch/riscv/include/asm/Makefile +1 -0
@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.h
xen/common/perfc.c +1 -0
@@ -1,4 +1,5 @@ +#include <xen/errno.h> #include <xen/lib.h> #include <xen/smp.h> #include <xen/time.h>
xen/include/asm-generic/perfc_defn.h new file +5 -0
@@ -0,0 +1,5 @@ +/* This file is legitimately included multiple times. */ +/* #ifndef ASM_GENERIC_PERFC_DEFN_H */ +/* #define ASM_GENERIC_PERFC_DEFN_H */ + +/* #endif ASM_GENERIC_PERFC_DEFN_H */
xen/include/xen/perfc_defn.h +2 -0
@@ -4,7 +4,9 @@#include <asm/perfc_defn.h> +#ifdef NR_hypercalls PERFCOUNTER_ARRAY(hypercalls, "hypercalls", NR_hypercalls) +#endif PERFCOUNTER (calls_from_multicall,"calls from multicall" )
Signature · 1 line
2.39.5
Re: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
Quoted 82 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop the randconfig override.Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- automation/gitlab-ci/build.yaml | 1 - xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/common/perfc.c | 1 + xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc_defn.h | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 xen/include/asm-generic/perfc_defn.hautomation/gitlab-ci/build.yaml +0
-1@@ -734,7 +734,6 @@ debian-12-riscv64-gcc: CONFIG_GRANT_TABLE=n CONFIG_LIVEPATCH=n CONFIG_MEM_ACCESS=n - CONFIG_PERF_COUNTERS=n CONFIG_QEMU_PLATFORM=y CONFIG_XSM=nxen/arch/ppc/include/asm/Makefile +1
-0@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.hxen/arch/riscv/include/asm/Makefile +1
-0@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.hxen/common/perfc.c +1
-0@@ -1,4 +1,5 @@ +#include <xen/errno.h> #include <xen/lib.h> #include <xen/smp.h> #include <xen/time.h> xen/include/asm-generic/perfc_defn.h new file +0
-0
xen/include/asm-generic/perfc_defn.h line 1
Quoted 1 line
xen/include/asm-generic/perfc_defn.h new file +1
-0@@ -0,0 +1,5 @@ +/* This file is legitimately included multiple times. */
It is a good idea to add comment here to explain. This is effectively the same as a deviation of MISRA D4.10. SAF-8-safe is defined as "Headers that deliberatively leave the responsability of their correct inclusion to the caller are allowed". I think it applies, please add SAF-8-safe to this comment and also the other perfc_defn.h, e.g.:
/* SAF-8-safe This file is legitimately included multiple times. */
Quoted 21 lines
xen/include/asm-generic/perfc_defn.h new file +4
-0+/* #ifndef ASM_GENERIC_PERFC_DEFN_H */ +/* #define ASM_GENERIC_PERFC_DEFN_H */ + +/* #endif ASM_GENERIC_PERFC_DEFN_H */ xen/include/xen/perfc_defn.h +2
-0@@ -4,7 +4,9 @@#include <asm/perfc_defn.h> +#ifdef NR_hypercalls PERFCOUNTER_ARRAY(hypercalls, "hypercalls", NR_hypercalls) +#endif PERFCOUNTER (calls_from_multicall,"calls from multicall" )Signature · 1 line
2.39.5
Re: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
Quoted 46 lines · Stefano Stabellini
Quoted 37 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop the randconfig override.Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- automation/gitlab-ci/build.yaml | 1 - xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/common/perfc.c | 1 + xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc_defn.h | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 xen/include/asm-generic/perfc_defn.hxen/include/asm-generic/perfc_defn.h new file +0
-0xen/include/asm-generic/perfc_defn.h line 1
Quoted 1 line
xen/include/asm-generic/perfc_defn.h new file +1
-0@@ -0,0 +1,5 @@ +/* This file is legitimately included multiple times. */ It is a good idea to add comment here to explain. This is effectively the same as a deviation of MISRA D4.10. SAF-8-safe is defined as "Headers that deliberatively leave the responsability of their correct inclusion to the caller are allowed". I think it applies, please add SAF-8-safe to this comment and also the other
perfc_defn.h, e.g.:
Quoted 2 lines
/* SAF-8-safe This file is legitimately included multiple times. */
There is already a deviation in place for this kind of files, so I think that's good as is, no need for a SAF tag.
-doc_begin="Files that are intended to be included more than once do not need to
conform to the directive."
-config=MC3A2.D4.10,reports+={safe, "first_area(text(^/\\* This file is legitimately included multiple times\\. \\*/$, begin-4))"}
Quoted 22 lines
Quoted 22 lines
xen/include/asm-generic/perfc_defn.h new file +4
-0+/* #ifndef ASM_GENERIC_PERFC_DEFN_H */ +/* #define ASM_GENERIC_PERFC_DEFN_H */ + +/* #endif ASM_GENERIC_PERFC_DEFN_H */ xen/include/xen/perfc_defn.h +2
-1@@ -4,7 +4,9 @@#include <asm/perfc_defn.h> +#ifdef NR_hypercalls PERFCOUNTER_ARRAY(hypercalls, "hypercalls", NR_hypercalls) +#endif PERFCOUNTER (calls_from_multicall,"calls from multicall" ) --2.39.5
Signature · 4 lines
Nicola Vetrini, B.Sc. Software Engineer BUGSENG (https://bugseng.com) LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
Stefano Stabellini
Reviewed-byRe: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
Quoted 54 lines · Nicola Vetrini
Quoted 50 lines · Stefano Stabellini
Quoted 41 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it
explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This
is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop
the randconfig override.Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- automation/gitlab-ci/build.yaml | 1 - xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/common/perfc.c | 1 + xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc_defn.h | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 xen/include/asm-generic/perfc_defn.hxen/include/asm-generic/perfc_defn.h new file +0
-0xen/include/asm-generic/perfc_defn.h line 1
Quoted 1 line
xen/include/asm-generic/perfc_defn.h new file +1
-0@@ -0,0 +1,5 @@ +/* This file is legitimately included multiple times. */ It is a good idea to add comment here to explain. This is effectively the same as a deviation of MISRA D4.10. SAF-8-safe is defined as "Headers that deliberatively leave the responsability of their correct inclusion to the caller are allowed". I think it applies, please add SAF-8-safe to this comment and also the other
perfc_defn.h, e.g.:Quoted 2 lines
/* SAF-8-safe This file is legitimately included multiple times. */
Quoted 8 lines
There is already a deviation in place for this kind of files, so I think that's good as is, no need for a SAF tag.
-doc_begin="Files that are intended to be included more than once do not need to
conform to the directive."
-config=MC3A2.D4.10,reports+={safe, "first_area(text(^/\\* This file is legitimately included multiple times\\. \\*/$, begin-4))"}
Thanks Nicola, I didn't realize that.
In that case:
Re: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
In reply to Andrew CooperQuoted 8 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop the randconfig override.
And then perhaps also that from riscv64_defconfig?
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>
Preferably with the added change:
Jan
Re: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
Quoted 10 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop the randconfig override.And then perhaps also that from
riscv64_defconfig?
Oh, quite possibly.
I'm not entirely sure what the point of negatives like that are in the defconfig.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Andrew Cooper <[email protected]>Preferably with the added change:
Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
Re: [PATCH 2/5] xen/perfc: Add perfc_defn.h to asm-generic
In reply to Andrew CooperQuoted 10 lines · Andrew Cooper
... and hook it up for RISC-V and PPC.
On RISC-V at least, no combination of headers pulls in
errno.h, so include it explicitly.Guard the hypercalls array declaration based on
NR_hypercallsexisting. This is sufficient to getPERF_COUNTERSfully working on RISC-V and PPC, so drop the randconfig override.Signed-off-by Andrew Cooper <[email protected]>
LKGTM: Acked-by: Oleksii Kurohcko <[email protected]>
~ Oleksii
Quoted 91 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- automation/gitlab-ci/build.yaml | 1 - xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/common/perfc.c | 1 + xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc_defn.h | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-)create mode 100644
xen/include/asm-generic/perfc_defn.hautomation/gitlab-ci/build.yaml +0
-1@@ -734,7 +734,6 @@ debian-12-riscv64-gcc: CONFIG_GRANT_TABLE=n CONFIG_LIVEPATCH=n CONFIG_MEM_ACCESS=n - CONFIG_PERF_COUNTERS=n CONFIG_QEMU_PLATFORM=y CONFIG_XSM=nxen/arch/ppc/include/asm/Makefile +1
-0@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.hxen/arch/riscv/include/asm/Makefile +1
-0@@ -7,6 +7,7 @@ generic-y += hypercall.h generic-y += iocap.h generic-y += paging.h generic-y += percpu.h +generic-y += perfc_defn.h generic-y += random.h generic-y += softirq.h generic-y += vm_event.hxen/common/perfc.c +1
-0@@ -1,4 +1,5 @@ +#include <xen/errno.h> #include <xen/lib.h> #include <xen/smp.h> #include <xen/time.h> xen/include/asm-generic/perfc_defn.h new file +5
-0@@ -0,0 +1,5 @@ +/* This file is legitimately included multiple times. */ +/* #ifndef ASM_GENERIC_PERFC_DEFN_H */ +/* #define ASM_GENERIC_PERFC_DEFN_H */ + +/* #endif ASM_GENERIC_PERFC_DEFN_H */ xen/include/xen/perfc_defn.h +2
-0@@ -4,7 +4,9 @@#include <asm/perfc_defn.h> +#ifdef NR_hypercalls PERFCOUNTER_ARRAY(hypercalls, "hypercalls", NR_hypercalls) +#endif PERFCOUNTER (calls_from_multicall,"calls from multicall" )
PATCH 3/5 xen/perfc: Trim includes
In reply to Andrew CooperThis is mostly for the removal of xen/lib.h and xen/smp.h from perfc.h. All that is needed is xen/macros.h.
Trim and sort the includes for perfc.c too. There's no need for smp.h, keyhandler.h or mm.h, but cpumask.h is needed.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- xen/common/perfc.c | 9 ++++----- xen/include/xen/perfc.h | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-)
xen/common/perfc.c +4 -5
@@ -1,13 +1,12 @@ +#include <xen/cpumask.h> #include <xen/errno.h> +#include <xen/guest_access.h> #include <xen/lib.h> -#include <xen/smp.h> -#include <xen/time.h> #include <xen/perfc.h> -#include <xen/keyhandler.h> #include <xen/spinlock.h> -#include <xen/mm.h> -#include <xen/guest_access.h> +#include <xen/time.h> +#include <public/sysctl.h> #define PERFCOUNTER ( var, name ) { name, TYPE_SINGLE, 0 },
xen/include/xen/perfc.h +1 -2
@@ -3,8 +3,7 @@#ifdef CONFIG_PERF_COUNTERS -#include <xen/lib.h> -#include <xen/smp.h> +#include <xen/macros.h> #include <xen/percpu.h> /*
Signature · 1 line
2.39.5
Re: [PATCH 3/5] xen/perfc: Trim includes
Quoted 7 lines · Andrew Cooper
This is mostly for the removal of
xen/lib.handxen/smp.hfromperfc.h. All that is needed isxen/macros.h.Trim and sort the includes for
perfc.ctoo. There's no need forsmp.h,keyhandler.hormm.h, butcpumask.his needed.Signed-off-by Andrew Cooper <[email protected]>
Quoted 54 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- xen/common/perfc.c | 9 ++++----- xen/include/xen/perfc.h | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-)xen/common/perfc.c +4
-5@@ -1,13 +1,12 @@ +#include <xen/cpumask.h> #include <xen/errno.h> +#include <xen/guest_access.h> #include <xen/lib.h> -#include <xen/smp.h> -#include <xen/time.h> #include <xen/perfc.h> -#include <xen/keyhandler.h> #include <xen/spinlock.h> -#include <xen/mm.h> -#include <xen/guest_access.h> +#include <xen/time.h> +#include <public/sysctl.h> #define PERFCOUNTER ( var, name ) { name, TYPE_SINGLE, 0 },xen/include/xen/perfc.h +1
-2@@ -3,8 +3,7 @@#ifdef CONFIG_PERF_COUNTERS -#include <xen/lib.h> -#include <xen/smp.h> +#include <xen/macros.h> #include <xen/percpu.h> /* Signature · 1 line
2.39.5
PATCH 4/5 xen/perfc: Cleanup
In reply to Andrew Cooper * Strip trailing whitspace.
* Remove PRIperfc. It has never been used and isn't useful.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- xen/common/perfc.c | 10 +++++----- xen/include/xen/perfc.h | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 17 deletions(-)
xen/common/perfc.c +5 -5
@@ -46,7 +46,7 @@ void cf_check perfc_printall(unsigned char key)case TYPE_S_SINGLE :for_each_online_cpu ( cpu ) sum += per_cpu(perfcounters, cpu)[j]; -if ( perfc_info[i].type ==TYPE_S_SINGLE ) +if ( perfc_info[i].type ==TYPE_S_SINGLE ) sum = (perfc_t ) sum;printk ("TOTAL[%12Lu]" , sum);if ( sum )
@@ -56,7 +56,7 @@ void cf_check perfc_printall(unsigned char key) {if ( k >0 && (k %4 ) ==0 )printk ("\n%53s" ,"" ); -printk (" CPU%02u[%10" PRIperfc"u]" , cpu,per_cpu (perfcounters, cpu)[j]); +printk (" CPU%02u[%10u]" , cpu,per_cpu (perfcounters, cpu)[j]); ++k; } }
@@ -71,7 +71,7 @@ void cf_check perfc_printall(unsigned char key)for ( k =0 ; k < perfc_info[i].nr_elements; k++ ) sum += counters[k]; } -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;printk ("TOTAL[%12Lu]" , sum);if (sum)
@@ -82,7 +82,7 @@ void cf_check perfc_printall(unsigned char key) sum =0 ;for_each_online_cpu ( cpu ) sum += per_cpu(perfcounters, cpu)[j + k]; -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;if ( (k %4 ) ==0 )printk ("\n%16s" ,"" );
@@ -98,7 +98,7 @@ void cf_check perfc_printall(unsigned char key) sum =0 ;for ( n =0 ; n < perfc_info[i].nr_elements; n++ ) sum += counters[n]; -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;if ( k >0 && (k %4 ) ==0 )printk ("\n%53s" ,"" );
xen/include/xen/perfc.h +11 -12
@@ -8,24 +8,24 @@/* * NOTE: new counters must be defined in perfc_defn.h -* +* * Counter declarations: * PERFCOUNTER (counter, string) define a new performance counter * PERFCOUNTER_ARRAY (counter, string, size) define an array of counters -* +* * Unlike counters, status variables do not reset: * PERFSTATUS (counter, string) define a new performance stauts * PERFSTATUS_ARRAY (counter, string, size) define an array of status vars -* -* unsigned long perfc_value (counter) get value of a counter +* +* unsigned long perfc_value (counter) get value of a counter * unsigned long perfc_valuea (counter, index) get value of an array counter -* unsigned long perfc_set (counter, val) set value of a counter +* unsigned long perfc_set (counter, val) set value of a counter * unsigned long perfc_seta (counter, index, val) set value of an array counter -* void perfc_incr (counter) increment a counter +* void perfc_incr (counter) increment a counter * void perfc_decr (counter) decrement a status -* void perfc_incra (counter, index) increment an array counter -* void perfc_add (counter, value) add a value to a counter -* void perfc_adda (counter, index, value) add a value to array counter +* void perfc_incra (counter, index) increment an array counter +* void perfc_add (counter, value) add a value to a counter +* void perfc_adda (counter, index, value) add a value to array counter * void perfc_print (counter) print out the counter */
@@ -49,7 +49,6 @@ enum {#undef PERFSTATUS_ARRAYtypedef unsigned int perfc_t ; -#define PRIperfc ""DECLARE_PER_CPU (perfc_t[NUM_PERFCOUNTERS ], perfcounters);
@@ -72,7 +71,7 @@ DECLARE_PER_CPU(perfc_t[NUM_PERFCOUNTERS], perfcounters); this_cpu(perfcounters)[PERFC_ ## x + (y)] = (v) : (v) )/* -* Histogram: special treatment for 0 and 1 count. After that equally spaced +* Histogram: special treatment for 0 and 1 count. After that equally spaced * with last bucket taking the rest. */ #ifdef CONFIG_PERF_ARRAYS
@@ -98,7 +97,7 @@ int perfc_control(struct xen_sysctl_perfc_op *pc); extern void cf_check perfc_printall(unsigned char key); extern void cf_check perfc_reset(unsigned char key); - +#else /* CONFIG_PERF_COUNTERS */ #define perfc_value (x) (0)
Signature · 1 line
2.39.5
Re: [PATCH 4/5] xen/perfc: Cleanup
Quoted 4 lines · Andrew Cooper
* Strip trailing whitspace.
* Remove PRIperfc. It has never been used and isn't useful.Signed-off-by Andrew Cooper <[email protected]>
Quoted 131 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- xen/common/perfc.c | 10 +++++----- xen/include/xen/perfc.h | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 17 deletions(-)xen/common/perfc.c +5
-5@@ -46,7 +46,7 @@ void cf_check perfc_printall(unsigned char key)case TYPE_S_SINGLE :for_each_online_cpu ( cpu ) sum += per_cpu(perfcounters, cpu)[j]; -if ( perfc_info[i].type ==TYPE_S_SINGLE ) +if ( perfc_info[i].type ==TYPE_S_SINGLE ) sum = (perfc_t ) sum;printk ("TOTAL[%12Lu]" , sum);if ( sum )@@ -56,7 +56,7 @@ void cf_check perfc_printall(unsigned char key) {if ( k >0 && (k %4 ) ==0 )printk ("\n%53s" ,"" ); -printk (" CPU%02u[%10" PRIperfc"u]" , cpu,per_cpu (perfcounters, cpu)[j]); +printk (" CPU%02u[%10u]" , cpu,per_cpu (perfcounters, cpu)[j]); ++k; } }@@ -71,7 +71,7 @@ void cf_check perfc_printall(unsigned char key)for ( k =0 ; k < perfc_info[i].nr_elements; k++ ) sum += counters[k]; } -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;printk ("TOTAL[%12Lu]" , sum);if (sum)@@ -82,7 +82,7 @@ void cf_check perfc_printall(unsigned char key) sum =0 ;for_each_online_cpu ( cpu ) sum += per_cpu(perfcounters, cpu)[j + k]; -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;if ( (k %4 ) ==0 )printk ("\n%16s" ,"" );@@ -98,7 +98,7 @@ void cf_check perfc_printall(unsigned char key) sum =0 ;for ( n =0 ; n < perfc_info[i].nr_elements; n++ ) sum += counters[n]; -if ( perfc_info[i].type ==TYPE_S_ARRAY ) +if ( perfc_info[i].type ==TYPE_S_ARRAY ) sum = (perfc_t ) sum;if ( k >0 && (k %4 ) ==0 )printk ("\n%53s" ,"" );xen/include/xen/perfc.h +11
-12@@ -8,24 +8,24 @@/* * NOTE: new counters must be defined in perfc_defn.h -* +* * Counter declarations: * PERFCOUNTER (counter, string) define a new performance counter * PERFCOUNTER_ARRAY (counter, string, size) define an array of counters -* +* * Unlike counters, status variables do not reset: * PERFSTATUS (counter, string) define a new performance stauts * PERFSTATUS_ARRAY (counter, string, size) define an array of status vars -* -* unsigned long perfc_value (counter) get value of a counter +* +* unsigned long perfc_value (counter) get value of a counter * unsigned long perfc_valuea (counter, index) get value of an array counter -* unsigned long perfc_set (counter, val) set value of a counter +* unsigned long perfc_set (counter, val) set value of a counter * unsigned long perfc_seta (counter, index, val) set value of an array counter -* void perfc_incr (counter) increment a counter +* void perfc_incr (counter) increment a counter * void perfc_decr (counter) decrement a status -* void perfc_incra (counter, index) increment an array counter -* void perfc_add (counter, value) add a value to a counter -* void perfc_adda (counter, index, value) add a value to array counter +* void perfc_incra (counter, index) increment an array counter +* void perfc_add (counter, value) add a value to a counter +* void perfc_adda (counter, index, value) add a value to array counter * void perfc_print (counter) print out the counter */ @@ -49,7 +49,6 @@ enum {#undef PERFSTATUS_ARRAYtypedef unsigned int perfc_t ; -#define PRIperfc ""DECLARE_PER_CPU (perfc_t[NUM_PERFCOUNTERS ], perfcounters);@@ -72,7 +71,7 @@ DECLARE_PER_CPU(perfc_t[NUM_PERFCOUNTERS], perfcounters); this_cpu(perfcounters)[PERFC_ ## x + (y)] = (v) : (v) )/* -* Histogram: special treatment for 0 and 1 count. After that equally spaced +* Histogram: special treatment for 0 and 1 count. After that equally spaced * with last bucket taking the rest. */ #ifdef CONFIG_PERF_ARRAYS @@ -98,7 +97,7 @@ int perfc_control(struct xen_sysctl_perfc_op *pc); extern void cf_check perfc_printall(unsigned char key); extern void cf_check perfc_reset(unsigned char key); - +#else /* CONFIG_PERF_COUNTERS */ #define perfc_value (x) (0)Signature · 1 line
2.39.5
PATCH 5/5 xen/perfc: COMPILE TEST
In reply to Andrew Cooper--- xen/Kconfig.debug | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
xen/Kconfig.debug +4 -10
@@ -60,18 +60,12 @@ config DEBUG_LOCKS checks will be performed when acquiring and releasing locks. config PERF_COUNTERS - bool "Performance Counters" - help - Enables software performance counters that allows you to analyze - bottlenecks in the system. To access this data you can use serial - console to print (and reset) using 'p' and 'P' respectively, or - the 'xenperf' tool. + bool + default y config PERF_ARRAYS - bool "Performance Counter Array Histograms" - depends on PERF_COUNTERS - help - Enables software performance counter array histograms. + bool + default y config VERBOSE_DEBUG
Signature · 1 line
2.39.5
[PATCH 6/4] x86/pv: Fix build with Clang and CONFIG_PERF_COUNTERS
In reply to Andrew CooperClang, of at least verion 17 complains:
arch/x86/pv/hypercall.c:30:10: error: variable 'eax' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
30 | if ( !compat )
| ^~~~~~~
arch/x86/pv/hypercall.c:87:29: note: uninitialized use occurs here
87 | perfc_incra(hypercalls, eax);
| ^~~This function is forced always_inline to cause compat to be constant-propagated through, but that is only a heuristic to try and get the compiler to do what we want, not a gurantee that it does.
Clang doesn't appear to be able to see that the only case where compat is true (and therefore the if() is false) is when there's an else clause on the end which sets eax too.
Initialise eax to -1, which ought to be optimised out, but if for whatever reason it happens not to be, then perfc_incra() will fail it's bounds check and do nothing.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/pv/hypercall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/pv/hypercall.c +1 -1
@@ -21,7 +21,7 @@ static void always_inline _pv_hypercall(struct cpu_user_regs *regs, bool compat) {struct vcpu *curr = current; -unsigned long eax; +unsigned long eax =-1 ;/* Clang -Wsometimes-uninitialized */ ASSERT (guest_kernel_mode (curr, regs));
base-commit: a1746cd4434dd27ca2da8430dfb10edc76264bb3
prerequisite-patch-id: c0c647c3d465fc11e039b5de751da060f2599fff
prerequisite-patch-id: 675a622887bb1721684e574fc7755af79463f67b
prerequisite-patch-id: 4bc07a7aa6e0f769ed7c89dc56db25091d810760
prerequisite-patch-id: b23c07e16495387ee6cb70edcbcb13f6b42246ac
prerequisite-patch-id: fe09857284f3a17ff116de1f0a20d3916e8dda90
Signature · 1 line
2.39.5
Jan Beulich
Acked-byRe: [PATCH 6/4] x86/pv: Fix build with Clang and CONFIG_PERF_COUNTERS
Quoted 18 lines · Andrew Cooper
Clang, of at least verion 17 complains:
arch/x86/pv/hypercall.c:30:10: error: variable 'eax' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]30 | if ( !compat ) | ^~~~~~~ arch/x86/pv/hypercall.c:87:29: note: uninitialized use occurs here 87 | perfc_incra(hypercalls, eax); | ^~~This function is forced
always_inlineto cause compat to be constant-propagated through, but that is only a heuristic to try and get the compiler to do what we want, not a gurantee that it does.Clang doesn't appear to be able to see that the only case where compat is true (and therefore the
if()is false) is when there's an else clause on the end which sets eax too.
Quoted 5 lines
Initialise eax to -1, which ought to be optimised out, but if for whatever reason it happens not to be, then
perfc_incra()will fail it's bounds check and do nothing.Signed-off-by Andrew Cooper <[email protected]>
Quoted 7 lines · Andrew Cooper
This started as just patch 3 fixing a header tangle with FRED on x86, but grew somewhat.
It's simple, straight forward, and gets perf counters working uniformly on all architectures, and a net reduction in code.
It's low risk, and should be considered for 4.20 at this juncture.
Agree, we could consider to be in 4.20.
Feel free to commit these patch series.
Thanks.
~ Oleksii
Quoted 27 lines
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1609450793
Andrew Cooper (5):
xen/perfc: Drop arch_perfc_{gather,reset}()
xen/perfc: Addperfc_defn.hto asm-generic
xen/perfc: Trim includes
xen/perfc: Cleanup
xen/perfc: COMPILE TESTautomation/gitlab-ci/build.yaml | 1 - xen/Kconfig.debug | 14 ++++---------- xen/arch/arm/include/asm/perfc.h | 21 --------------------- xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/riscv/include/asm/Makefile | 1 + xen/arch/x86/include/asm/perfc.h | 12 ------------ xen/common/perfc.c | 26 ++++++++++---------------- xen/include/asm-generic/perfc_defn.h | 5 +++++ xen/include/xen/perfc.h | 26 ++++++++++++-------------- xen/include/xen/perfc_defn.h | 2 ++ 10 files changed, 35 insertions(+), 74 deletions(-)delete mode 100644
xen/arch/arm/include/asm/perfc.hdelete mode 100644xen/arch/x86/include/asm/perfc.hcreate mode 100644xen/include/asm-generic/perfc_defn.hbase-commit:
a1746cd4434dd27ca2da8430dfb10edc76264bb3