Skip to contentSkip to conversation

perf kvm: move HAVE_KVM_STAT_SUPPORT down

PATCH In review Xu Yang 2 participants 3 messages Aug 9, 2024 – Aug 19, 2024

Subsystems (2)
lore
Share & tools
lore

Xu Yang

author
#0 lore raw

PATCH 1/1 perf kvm: move HAVE_KVM_STAT_SUPPORT down

The 32-bit arm build system will complain:

tools/perf/util/python.c:75:28: error: field ‘sample’ has incomplete type
75 | struct perf_sample sample;

However, arm64 build system doesn't complain this.

The root cause is arm64 define "HAVE_KVM_STAT_SUPPORT := 1" in tools/perf/arch/arm64/Makefile, but arm arch doesn't define this. This will lead to kvm-stat.h include other header files on arm64 build system, especially "sort.h" for util/python.c.

This will try to move HAVE_KVM_STAT_SUPPORT down, so normal header files can be exported to source files on other arch too.

---
 tools/perf/util/kvm-stat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/kvm-stat.h +2 -2
index 3e9ac754c3d1..92f1191cd462 100644
@@ -2,8 +2,6 @@
 #ifndef __PERF_KVM_STAT_H
 #define __PERF_KVM_STAT_H
 
-#ifdef HAVE_KVM_STAT_SUPPORT
-
 #include "tool.h"
 #include "sort.h"
 #include "stat.h"
@@ -13,6 +11,8 @@
 #include <stdlib.h>
 #include <linux/zalloc.h>
 
+#ifdef HAVE_KVM_STAT_SUPPORT
+
 #define KVM_EVENT_NAME_LEN	40
 
 struct evsel;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 11 lines · Xu Yang

The 32-bit arm build system will complain:

tools/perf/util/python.c:75:28: error: field ‘sample’ has incomplete type
75 | struct perf_sample sample;

However, arm64 build system doesn't complain this.

The root cause is arm64 define "HAVE_KVM_STAT_SUPPORT := 1" in tools/perf/arch/arm64/Makefile, but arm arch doesn't define this. This will lead to kvm-stat.h include other header files on arm64 build system, especially "sort.h" for util/python.c.

But it's not intuitive. I think you can include "util/sample.h" in the util/python.c.

Thanks,
Namhyung

Quoted 34 lines

This will try to move HAVE_KVM_STAT_SUPPORT down, so normal header files can be exported to source files on other arch too.

---
 tools/perf/util/kvm-stat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/kvm-stat.h +2 -2
index 3e9ac754c3d1..92f1191cd462 100644
@@ -2,8 +2,6 @@
 #ifndef __PERF_KVM_STAT_H
 #define __PERF_KVM_STAT_H
 
-#ifdef HAVE_KVM_STAT_SUPPORT
-
 #include "tool.h"
 #include "sort.h"
 #include "stat.h"
@@ -13,6 +11,8 @@
 #include <stdlib.h>
 #include <linux/zalloc.h>
 
+#ifdef HAVE_KVM_STAT_SUPPORT
+
 #define KVM_EVENT_NAME_LEN	40
 
 struct evsel;
Signature · 1 line
2.34.1
author
#2 lore raw
Quoted 8 lines · Namhyung Kim
Quoted 7 lines · Xu Yang

The 32-bit arm build system will complain:

tools/perf/util/python.c:75:28: error: field ‘sample’ has incomplete type
75 | struct perf_sample sample;

However, arm64 build system doesn't complain this.

Quoted 7 lines
Quoted 4 lines

The root cause is arm64 define "HAVE_KVM_STAT_SUPPORT := 1" in tools/perf/arch/arm64/Makefile, but arm arch doesn't define this. This will lead to kvm-stat.h include other header files on arm64 build system, especially "sort.h" for util/python.c.

But it's not intuitive. I think you can include "util/sample.h" in the util/python.c.

Sure. I'll send v2.

Thanks,
Xu Yang

Quoted 38 lines

Thanks,
Namhyung

Quoted 34 lines

This will try to move HAVE_KVM_STAT_SUPPORT down, so normal header files can be exported to source files on other arch too.

---
 tools/perf/util/kvm-stat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/kvm-stat.h +2 -2
index 3e9ac754c3d1..92f1191cd462 100644
@@ -2,8 +2,6 @@
 #ifndef __PERF_KVM_STAT_H
 #define __PERF_KVM_STAT_H
 
-#ifdef HAVE_KVM_STAT_SUPPORT
-
 #include "tool.h"
 #include "sort.h"
 #include "stat.h"
@@ -13,6 +11,8 @@
 #include <stdlib.h>
 #include <linux/zalloc.h>
 
+#ifdef HAVE_KVM_STAT_SUPPORT
+
 #define KVM_EVENT_NAME_LEN	40
 
 struct evsel;
Signature · 1 line
2.34.1