diff mbox series

perf kvm: move HAVE_KVM_STAT_SUPPORT down

Message ID 20240809115335.540947-1-xu.yang_2@nxp.com (mailing list archive)
State New
Headers show
Series perf kvm: move HAVE_KVM_STAT_SUPPORT down | expand

Commit Message

Xu Yang Aug. 9, 2024, 11:53 a.m. UTC
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.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 tools/perf/util/kvm-stat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Namhyung Kim Aug. 16, 2024, 5:31 p.m. UTC | #1
On Fri, Aug 09, 2024 at 07:53:35PM +0800, Xu Yang wrote:
> 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

> 
> This will try to move HAVE_KVM_STAT_SUPPORT down, so normal header files
> can be exported to source files on other arch too.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
>  tools/perf/util/kvm-stat.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
> index 3e9ac754c3d1..92f1191cd462 100644
> --- a/tools/perf/util/kvm-stat.h
> +++ b/tools/perf/util/kvm-stat.h
> @@ -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;
> -- 
> 2.34.1
>
Xu Yang Aug. 19, 2024, 2:14 a.m. UTC | #2
On Fri, Aug 16, 2024 at 10:31:39AM -0700, Namhyung Kim wrote:
> On Fri, Aug 09, 2024 at 07:53:35PM +0800, Xu Yang wrote:
> > 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.

Sure. I'll send v2.

Thanks,
Xu Yang

> 
> Thanks,
> Namhyung
> 
> > 
> > This will try to move HAVE_KVM_STAT_SUPPORT down, so normal header files
> > can be exported to source files on other arch too.
> > 
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> >  tools/perf/util/kvm-stat.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
> > index 3e9ac754c3d1..92f1191cd462 100644
> > --- a/tools/perf/util/kvm-stat.h
> > +++ b/tools/perf/util/kvm-stat.h
> > @@ -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;
> > -- 
> > 2.34.1
> >
diff mbox series

Patch

diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
index 3e9ac754c3d1..92f1191cd462 100644
--- a/tools/perf/util/kvm-stat.h
+++ b/tools/perf/util/kvm-stat.h
@@ -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;