linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] UAPI: perf fixes
@ 2012-11-08 12:51 David Howells
  2012-11-12 20:23 ` Josh Boyer
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: David Howells @ 2012-11-08 12:51 UTC (permalink / raw)
  To: acme
  Cc: dhowells, mingo, tglx, bp, namhyung, torvalds, paulus,
	linux-arch, linux-kernel, x86


Hi Arnaldo,

Assuming my patches should be based on your perf/core branch, could you pull
from my git tree at tag perf-uapi-20121108 into your perf/core branch?

Note the tree also contains a uapi-perf-x86-20121108 tag that has the UAPI
disintegration branch for x86 merged on top for reference.

There are six commits, three preliminary patches:

 (1) A patch to export asm/svm.h, asm/vmx.h and asm/perf_regs.h to UAPI.

 (2) A merge for (1) - the patch in (1) is premerged by the UAPI disintegration
     for x86 also, and I'd rather not include your perf/core branch in that if
     I can avoid it.

 (3) A patch to export and disintegrate linux/hw_breakpoint.h.  It looks like
     it should perhaps have been exported already, given the __KERNEL__ markers
     in it.

and then the main three patches:

 (4) Use a makefile $(call ...) function in tools/Makefile to make it easier
     to deal with.

 (5) Fix handling of O= with a relative path when doing something like:

	make tools/perf O=foo

     from the top-level directory in the kernel source tree for all tools.

 (6) Make perf work for x86 by adding -I flags and changing long #includes
     with "../../include" in them into short <asm/foo.h> type things.

David
---
The following changes since commit 8dfec403e39b7c37fd6e8813bacc01da1e1210ab:

  perf tests: Removing 'optional' field (2012-11-05 14:03:59 -0300)

are available in the git repository at:

  git://git.infradead.org/users/dhowells/linux-headers.git tags/perf-uapi-20121108

for you to fetch changes up to 028c2c390c71d3d37f91291ac8e827f5028f7975:

  perf: Make perf build for x86 with UAPI disintegration applied (2012-11-08 11:55:58 +0000)

----------------------------------------------------------------
perf fixes 2012-11-08

----------------------------------------------------------------
David Howells (6):
      x86: Export asm/{svm.h,vmx.h,perf_regs.h}
      UAPI: Merge pre-disintegration bits for x86
      UAPI: Export and disintegrate linux/hw_breakpoint.h
      tools: Define a Makefile function to do subdir processing
      tools: Honour the O= flag when tool build called from a higher Makefile
      perf: Make perf build for x86 with UAPI disintegration applied

 Makefile                                |  6 ++++--
 arch/x86/include/asm/Kbuild             |  3 +++
 include/linux/hw_breakpoint.h           | 31 +------------------------------
 include/uapi/linux/Kbuild               |  1 +
 include/uapi/linux/hw_breakpoint.h      | 30 ++++++++++++++++++++++++++++++
 tools/Makefile                          | 24 ++++++++++++------------
 tools/perf/Makefile                     | 28 +++++++++++++++++++++++++++-
 tools/perf/arch/x86/include/perf_regs.h |  2 +-
 tools/perf/builtin-kvm.c                |  6 +++---
 tools/perf/perf.h                       | 16 +++-------------
 tools/perf/tests/builtin-test.c         |  2 +-
 tools/perf/tests/parse-events.c         |  2 +-
 tools/perf/util/evsel.c                 |  4 ++--
 tools/perf/util/evsel.h                 |  2 +-
 tools/perf/util/header.h                |  2 +-
 tools/perf/util/parse-events.c          |  2 +-
 tools/perf/util/parse-events.h          |  2 +-
 tools/perf/util/pmu.h                   |  2 +-
 tools/perf/util/session.h               |  2 +-
 tools/scripts/Makefile.include          | 23 ++++++++++++++++++++---
 20 files changed, 115 insertions(+), 75 deletions(-)
 create mode 100644 include/uapi/linux/hw_breakpoint.h

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
@ 2012-11-12 20:23 ` Josh Boyer
  2012-11-13 11:11 ` David Howells
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Josh Boyer @ 2012-11-12 20:23 UTC (permalink / raw)
  To: David Howells
  Cc: acme, mingo, tglx, bp, namhyung, torvalds, paulus, linux-arch,
	linux-kernel, x86

On Thu, Nov 8, 2012 at 7:51 AM, David Howells <dhowells@redhat.com> wrote:
>
>  (6) Make perf work for x86 by adding -I flags and changing long #includes
>      with "../../include" in them into short <asm/foo.h> type things.

This patch seems to break building perf on ppc64.  It fails with:

+ make -j16 -C tools/perf -s V=1 WERROR=0 HAVE_CPLUS_DEMANGLE=1 prefix=/usr all

<snip>

builtin-kvm.c:25:21: fatal error: asm/svm.h: No such file or directory
compilation terminated.
make: *** [builtin-kvm.o] Error 1
make: *** Waiting for unfinished jobs....

And that is indeed because arch/powerpc/include/asm/svm.h doesn't exist
(and therefore can't be exported like the first patch for x86 in this
series does).  You can find full build logs with this patch series
applied here: http://ppc.koji.fedoraproject.org/koji/taskinfo?taskID=781782

However, without some form of fix for the ../.. includes, perf still
fails to build on arches like ARM and powerpc with errors like this:

In file included from util/../perf.h:29:0,
                 from util/cache.h:7,
                 from util/quote.c:1:
util/../../../arch/powerpc/include/asm/unistd.h:12:29: fatal error:
uapi/asm/unistd.h: No such file or directory
compilation terminated.
make: *** [util/parse-events-test.o] Error 1

Full build logs here:
http://ppc.koji.fedoraproject.org/koji/taskinfo?taskID=781076

So.  Something else might need to be done to fix perf builds for non-x86
arches.

josh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
  2012-11-12 20:23 ` Josh Boyer
@ 2012-11-13 11:11 ` David Howells
  2012-11-13 11:12 ` David Howells
  2012-11-13 15:24 ` David Howells
  3 siblings, 0 replies; 15+ messages in thread
From: David Howells @ 2012-11-13 11:11 UTC (permalink / raw)
  To: Josh Boyer
  Cc: dhowells, acme, mingo, tglx, bp, namhyung, torvalds, paulus,
	linux-arch, linux-kernel, x86

Josh Boyer <jwboyer@gmail.com> wrote:

> This patch seems to break building perf on ppc64.  It fails with:

Hmmm...  Getting my hands on an ARM or ppc/ppc64 box running Fedora is a
problem, and as far as I know, this needs to be built natively or maybe
cross-compiled with a full environment (including graphics libs).

David

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
  2012-11-12 20:23 ` Josh Boyer
  2012-11-13 11:11 ` David Howells
@ 2012-11-13 11:12 ` David Howells
  2012-11-13 12:51   ` Josh Boyer
  2012-11-13 15:24 ` David Howells
  3 siblings, 1 reply; 15+ messages in thread
From: David Howells @ 2012-11-13 11:12 UTC (permalink / raw)
  Cc: dhowells, Josh Boyer, acme, mingo, tglx, bp, namhyung, torvalds,
	paulus, linux-arch, linux-kernel, x86

David Howells <dhowells@redhat.com> wrote:

> Josh Boyer <jwboyer@gmail.com> wrote:
> 
> > This patch seems to break building perf on ppc64.  It fails with:
> 
> Hmmm...  Getting my hands on an ARM or ppc/ppc64 box running Fedora is a
> problem, and as far as I know, this needs to be built natively or maybe
> cross-compiled with a full environment (including graphics libs).

Actually, having said that, it doesn't need to run Fedora specifically - only
a sufficiently recent environment that it can build a cutting-edge kernel.

David

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 11:12 ` David Howells
@ 2012-11-13 12:51   ` Josh Boyer
  0 siblings, 0 replies; 15+ messages in thread
From: Josh Boyer @ 2012-11-13 12:51 UTC (permalink / raw)
  To: David Howells
  Cc: acme, mingo, tglx, bp, namhyung, torvalds, paulus, linux-arch,
	linux-kernel, x86

On Tue, Nov 13, 2012 at 6:12 AM, David Howells <dhowells@redhat.com> wrote:
> David Howells <dhowells@redhat.com> wrote:
>
>> Josh Boyer <jwboyer@gmail.com> wrote:
>>
>> > This patch seems to break building perf on ppc64.  It fails with:
>>
>> Hmmm...  Getting my hands on an ARM or ppc/ppc64 box running Fedora is a
>> problem, and as far as I know, this needs to be built natively or maybe
>> cross-compiled with a full environment (including graphics libs).
>
> Actually, having said that, it doesn't need to run Fedora specifically - only
> a sufficiently recent environment that it can build a cutting-edge kernel.

You can just use koji scratch builds if you want to test Fedora kernels
Either arm-koji or ppc-koji should work.  If you want actual access to a
machine, I'm sure we can find one.

The error that is hitting ARM and ppc before your patch seemed to also
be hit with sparc and was fixed by David Miller with commit 776260818
by just pointing to "../../arch/sparc/include/uapi/asm/unistd.h".  That
might be a temporary solution.

josh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
                   ` (2 preceding siblings ...)
  2012-11-13 11:12 ` David Howells
@ 2012-11-13 15:24 ` David Howells
  2012-11-13 15:42   ` Josh Boyer
  3 siblings, 1 reply; 15+ messages in thread
From: David Howells @ 2012-11-13 15:24 UTC (permalink / raw)
  To: acme, Josh Boyer, xiaoguangrong
  Cc: dhowells, mingo, haodong, runzhen, dsahern, tglx, bp, namhyung,
	torvalds, paulus, linux-arch, linux-kernel, x86

Josh Boyer <jwboyer@gmail.com> wrote:

> This patch seems to break building perf on ppc64.  It fails with:
> 
> + make -j16 -C tools/perf -s V=1 WERROR=0 HAVE_CPLUS_DEMANGLE=1 prefix=/usr all
> 
> <snip>
> 
> builtin-kvm.c:25:21: fatal error: asm/svm.h: No such file or directory

tools/perf/builtin-kvm.c became x86-only with the following commit:

	commit bcf6edcd6fdb8965290f0b635a530fa3c6c212e1
	Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
	Date:   Mon Sep 17 16:31:15 2012 +0800
	Subject: perf kvm: Events analysis tool

when it added:

	+#include "../../arch/x86/include/asm/svm.h"
	+#include "../../arch/x86/include/asm/vmx.h"
	+#include "../../arch/x86/include/asm/kvm.h"

and my changing these to <asm/foo.h> doesn't matter because of this in the
same file:

	+struct exit_reasons_table vmx_exit_reasons[] = {
	+       VMX_EXIT_REASONS
	+};
	+
	+struct exit_reasons_table svm_exit_reasons[] = {
	+       SVM_EXIT_REASONS
	+};

which use macros only x86 defines.

Should the exported parts of these files be moved to asm-generic?

David

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 15:24 ` David Howells
@ 2012-11-13 15:42   ` Josh Boyer
  2012-11-13 15:42     ` Josh Boyer
  2012-11-13 16:34     ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 15+ messages in thread
From: Josh Boyer @ 2012-11-13 15:42 UTC (permalink / raw)
  To: David Howells
  Cc: acme, xiaoguangrong, mingo, haodong, runzhen, dsahern, tglx, bp,
	namhyung, torvalds, paulus, linux-arch, linux-kernel, x86

On Tue, Nov 13, 2012 at 10:24 AM, David Howells <dhowells@redhat.com> wrote:
> Josh Boyer <jwboyer@gmail.com> wrote:
>
>> This patch seems to break building perf on ppc64.  It fails with:
>>
>> + make -j16 -C tools/perf -s V=1 WERROR=0 HAVE_CPLUS_DEMANGLE=1 prefix=/usr all
>>
>> <snip>
>>
>> builtin-kvm.c:25:21: fatal error: asm/svm.h: No such file or directory
>
> tools/perf/builtin-kvm.c became x86-only with the following commit:
>
>         commit bcf6edcd6fdb8965290f0b635a530fa3c6c212e1
>         Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>         Date:   Mon Sep 17 16:31:15 2012 +0800
>         Subject: perf kvm: Events analysis tool
>
> when it added:
>
>         +#include "../../arch/x86/include/asm/svm.h"
>         +#include "../../arch/x86/include/asm/vmx.h"
>         +#include "../../arch/x86/include/asm/kvm.h"
>
> and my changing these to <asm/foo.h> doesn't matter because of this in the
> same file:
>
>         +struct exit_reasons_table vmx_exit_reasons[] = {
>         +       VMX_EXIT_REASONS
>         +};
>         +
>         +struct exit_reasons_table svm_exit_reasons[] = {
>         +       SVM_EXIT_REASONS
>         +};
>
> which use macros only x86 defines.

Ah.  You are quite right.  So your patches actually fix the unistd.h
error we were seeing early and just got us far enough to hit this other
unrelated problem.  My mistake.

> Should the exported parts of these files be moved to asm-generic?

Good question.

josh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 15:42   ` Josh Boyer
@ 2012-11-13 15:42     ` Josh Boyer
  2012-11-13 16:34     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 15+ messages in thread
From: Josh Boyer @ 2012-11-13 15:42 UTC (permalink / raw)
  To: David Howells
  Cc: acme, xiaoguangrong, mingo, haodong, runzhen, dsahern, tglx, bp,
	namhyung, torvalds, paulus, linux-arch, linux-kernel, x86

On Tue, Nov 13, 2012 at 10:24 AM, David Howells <dhowells@redhat.com> wrote:
> Josh Boyer <jwboyer@gmail.com> wrote:
>
>> This patch seems to break building perf on ppc64.  It fails with:
>>
>> + make -j16 -C tools/perf -s V=1 WERROR=0 HAVE_CPLUS_DEMANGLE=1 prefix=/usr all
>>
>> <snip>
>>
>> builtin-kvm.c:25:21: fatal error: asm/svm.h: No such file or directory
>
> tools/perf/builtin-kvm.c became x86-only with the following commit:
>
>         commit bcf6edcd6fdb8965290f0b635a530fa3c6c212e1
>         Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>         Date:   Mon Sep 17 16:31:15 2012 +0800
>         Subject: perf kvm: Events analysis tool
>
> when it added:
>
>         +#include "../../arch/x86/include/asm/svm.h"
>         +#include "../../arch/x86/include/asm/vmx.h"
>         +#include "../../arch/x86/include/asm/kvm.h"
>
> and my changing these to <asm/foo.h> doesn't matter because of this in the
> same file:
>
>         +struct exit_reasons_table vmx_exit_reasons[] = {
>         +       VMX_EXIT_REASONS
>         +};
>         +
>         +struct exit_reasons_table svm_exit_reasons[] = {
>         +       SVM_EXIT_REASONS
>         +};
>
> which use macros only x86 defines.

Ah.  You are quite right.  So your patches actually fix the unistd.h
error we were seeing early and just got us far enough to hit this other
unrelated problem.  My mistake.

> Should the exported parts of these files be moved to asm-generic?

Good question.

josh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 15:42   ` Josh Boyer
  2012-11-13 15:42     ` Josh Boyer
@ 2012-11-13 16:34     ` Arnaldo Carvalho de Melo
  2012-11-15  2:23       ` Xiao Guangrong
  2012-11-15  6:17       ` [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat Xiao Guangrong
  1 sibling, 2 replies; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-11-13 16:34 UTC (permalink / raw)
  To: Josh Boyer
  Cc: David Howells, xiaoguangrong, mingo, haodong, runzhen, dsahern,
	tglx, bp, namhyung, torvalds, paulus, linux-arch, linux-kernel,
	x86

Em Tue, Nov 13, 2012 at 10:42:02AM -0500, Josh Boyer escreveu:
> On Tue, Nov 13, 2012 at 10:24 AM, David Howells <dhowells@redhat.com> wrote:
> > Josh Boyer <jwboyer@gmail.com> wrote:
> > tools/perf/builtin-kvm.c became x86-only with the following commit:
> >
> >         commit bcf6edcd6fdb8965290f0b635a530fa3c6c212e1
> >         Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
> >         Date:   Mon Sep 17 16:31:15 2012 +0800
> >         Subject: perf kvm: Events analysis tool
> >
> > when it added:
> >
> >         +#include "../../arch/x86/include/asm/svm.h"
> >         +#include "../../arch/x86/include/asm/vmx.h"
> >         +#include "../../arch/x86/include/asm/kvm.h"
> >
> > and my changing these to <asm/foo.h> doesn't matter because of this in the
> > same file:
> >
> >         +struct exit_reasons_table vmx_exit_reasons[] = {
> >         +       VMX_EXIT_REASONS
> >         +};
> >         +
> >         +struct exit_reasons_table svm_exit_reasons[] = {
> >         +       SVM_EXIT_REASONS
> >         +};
> >
> > which use macros only x86 defines.
> 
> Ah.  You are quite right.  So your patches actually fix the unistd.h
> error we were seeing early and just got us far enough to hit this other
> unrelated problem.  My mistake.
> 
> > Should the exported parts of these files be moved to asm-generic?
> 
> Good question.

Probably we should do Makefile changes to build 'perf kvm' only on the
platforms where it makes sense.

- Arnaldo

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 16:34     ` Arnaldo Carvalho de Melo
@ 2012-11-15  2:23       ` Xiao Guangrong
  2012-11-15  6:17       ` [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat Xiao Guangrong
  1 sibling, 0 replies; 15+ messages in thread
From: Xiao Guangrong @ 2012-11-15  2:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Josh Boyer, David Howells, mingo, haodong, runzhen, dsahern,
	tglx, bp, namhyung, torvalds, paulus, linux-arch, linux-kernel,
	x86

On 11/14/2012 12:34 AM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 13, 2012 at 10:42:02AM -0500, Josh Boyer escreveu:
>> On Tue, Nov 13, 2012 at 10:24 AM, David Howells <dhowells@redhat.com> wrote:
>>> Josh Boyer <jwboyer@gmail.com> wrote:
>>> tools/perf/builtin-kvm.c became x86-only with the following commit:
>>>
>>>         commit bcf6edcd6fdb8965290f0b635a530fa3c6c212e1
>>>         Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>>>         Date:   Mon Sep 17 16:31:15 2012 +0800
>>>         Subject: perf kvm: Events analysis tool
>>>
>>> when it added:
>>>
>>>         +#include "../../arch/x86/include/asm/svm.h"
>>>         +#include "../../arch/x86/include/asm/vmx.h"
>>>         +#include "../../arch/x86/include/asm/kvm.h"
>>>
>>> and my changing these to <asm/foo.h> doesn't matter because of this in the
>>> same file:
>>>
>>>         +struct exit_reasons_table vmx_exit_reasons[] = {
>>>         +       VMX_EXIT_REASONS
>>>         +};
>>>         +
>>>         +struct exit_reasons_table svm_exit_reasons[] = {
>>>         +       SVM_EXIT_REASONS
>>>         +};
>>>
>>> which use macros only x86 defines.
>>
>> Ah.  You are quite right.  So your patches actually fix the unistd.h
>> error we were seeing early and just got us far enough to hit this other
>> unrelated problem.  My mistake.
>>
>>> Should the exported parts of these files be moved to asm-generic?
>>
>> Good question.
> 
> Probably we should do Makefile changes to build 'perf kvm' only on the
> platforms where it makes sense.

Only 'perf kvm stat' command is only supported on x86, how about add
"#ifdef ARCH_X86_64" around these code?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat
  2012-11-13 16:34     ` Arnaldo Carvalho de Melo
  2012-11-15  2:23       ` Xiao Guangrong
@ 2012-11-15  6:17       ` Xiao Guangrong
  2012-11-15  6:17         ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC Xiao Guangrong
  2012-11-15 10:46         ` David Howells
  1 sibling, 2 replies; 15+ messages in thread
From: Xiao Guangrong @ 2012-11-15  6:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Josh Boyer, David Howells, mingo, haodong, runzhen, dsahern,
	tglx, bp, namhyung, torvalds, paulus, linux-arch, linux-kernel,
	x86

Then, let it only be used in 'perf kvm stat'

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 tools/perf/builtin-kvm.c |  111 +++++++++++++++++++++++++---------------------
 1 files changed, 60 insertions(+), 51 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 836c82f..7fb426b 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -58,7 +58,7 @@ struct kvm_event_key {
 };


-struct perf_kvm;
+struct perf_kvm_stat;

 struct kvm_events_ops {
 	bool (*is_begin_event)(struct perf_evsel *evsel,
@@ -66,7 +66,7 @@ struct kvm_events_ops {
 			       struct event_key *key);
 	bool (*is_end_event)(struct perf_evsel *evsel,
 			     struct perf_sample *sample, struct event_key *key);
-	void (*decode_key)(struct perf_kvm *kvm, struct event_key *key,
+	void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
 			   char decode[20]);
 	const char *name;
 };
@@ -79,7 +79,7 @@ struct exit_reasons_table {
 #define EVENTS_BITS		12
 #define EVENTS_CACHE_SIZE	(1UL << EVENTS_BITS)

-struct perf_kvm {
+struct perf_kvm_stat {
 	struct perf_tool    tool;
 	struct perf_session *session;

@@ -146,7 +146,7 @@ static struct exit_reasons_table svm_exit_reasons[] = {
 	SVM_EXIT_REASONS
 };

-static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code)
+static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code)
 {
 	int i = kvm->exit_reasons_size;
 	struct exit_reasons_table *tbl = kvm->exit_reasons;
@@ -162,7 +162,7 @@ static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code)
 	return "UNKNOWN";
 }

-static void exit_event_decode_key(struct perf_kvm *kvm,
+static void exit_event_decode_key(struct perf_kvm_stat *kvm,
 				  struct event_key *key,
 				  char decode[20])
 {
@@ -228,7 +228,7 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
 	return false;
 }

-static void mmio_event_decode_key(struct perf_kvm *kvm __maybe_unused,
+static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
 				  struct event_key *key,
 				  char decode[20])
 {
@@ -271,7 +271,7 @@ static bool ioport_event_end(struct perf_evsel *evsel,
 	return kvm_entry_event(evsel);
 }

-static void ioport_event_decode_key(struct perf_kvm *kvm __maybe_unused,
+static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
 				    struct event_key *key,
 				    char decode[20])
 {
@@ -286,7 +286,7 @@ static struct kvm_events_ops ioport_events = {
 	.name = "IO Port Access"
 };

-static bool register_kvm_events_ops(struct perf_kvm *kvm)
+static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
 {
 	bool ret = true;

@@ -311,7 +311,7 @@ struct vcpu_event_record {
 };


-static void init_kvm_event_record(struct perf_kvm *kvm)
+static void init_kvm_event_record(struct perf_kvm_stat *kvm)
 {
 	unsigned int i;

@@ -360,7 +360,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
 	return event;
 }

-static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm,
+static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm,
 					       struct event_key *key)
 {
 	struct kvm_event *event;
@@ -382,7 +382,7 @@ static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm,
 	return event;
 }

-static bool handle_begin_event(struct perf_kvm *kvm,
+static bool handle_begin_event(struct perf_kvm_stat *kvm,
 			       struct vcpu_event_record *vcpu_record,
 			       struct event_key *key, u64 timestamp)
 {
@@ -429,7 +429,7 @@ static bool update_kvm_event(struct kvm_event *event, int vcpu_id,
 	return true;
 }

-static bool handle_end_event(struct perf_kvm *kvm,
+static bool handle_end_event(struct perf_kvm_stat *kvm,
 			     struct vcpu_event_record *vcpu_record,
 			     struct event_key *key,
 			     u64 timestamp)
@@ -496,7 +496,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
 	return thread->priv;
 }

-static bool handle_kvm_event(struct perf_kvm *kvm,
+static bool handle_kvm_event(struct perf_kvm_stat *kvm,
 			     struct thread *thread,
 			     struct perf_evsel *evsel,
 			     struct perf_sample *sample)
@@ -556,7 +556,7 @@ static struct kvm_event_key keys[] = {
 	{ NULL, NULL }
 };

-static bool select_key(struct perf_kvm *kvm)
+static bool select_key(struct perf_kvm_stat *kvm)
 {
 	int i;

@@ -592,7 +592,8 @@ static void insert_to_result(struct rb_root *result, struct kvm_event *event,
 	rb_insert_color(&event->rb, result);
 }

-static void update_total_count(struct perf_kvm *kvm, struct kvm_event *event)
+static void
+update_total_count(struct perf_kvm_stat *kvm, struct kvm_event *event)
 {
 	int vcpu = kvm->trace_vcpu;

@@ -605,7 +606,7 @@ static bool event_is_valid(struct kvm_event *event, int vcpu)
 	return !!get_event_count(event, vcpu);
 }

-static void sort_result(struct perf_kvm *kvm)
+static void sort_result(struct perf_kvm_stat *kvm)
 {
 	unsigned int i;
 	int vcpu = kvm->trace_vcpu;
@@ -644,7 +645,7 @@ static void print_vcpu_info(int vcpu)
 		pr_info("VCPU %d:\n\n", vcpu);
 }

-static void print_result(struct perf_kvm *kvm)
+static void print_result(struct perf_kvm_stat *kvm)
 {
 	char decode[20];
 	struct kvm_event *event;
@@ -687,7 +688,8 @@ static int process_sample_event(struct perf_tool *tool,
 				struct machine *machine)
 {
 	struct thread *thread = machine__findnew_thread(machine, sample->tid);
-	struct perf_kvm *kvm = container_of(tool, struct perf_kvm, tool);
+	struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat,
+						 tool);

 	if (thread == NULL) {
 		pr_debug("problem processing %d event, skipping it.\n",
@@ -718,7 +720,7 @@ static int get_cpu_isa(struct perf_session *session)
 	return isa;
 }

-static int read_events(struct perf_kvm *kvm)
+static int read_events(struct perf_kvm_stat *kvm)
 {
 	int ret;

@@ -767,7 +769,7 @@ static bool verify_vcpu(int vcpu)
 	return true;
 }

-static int kvm_events_report_vcpu(struct perf_kvm *kvm)
+static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm)
 {
 	int ret = -EINVAL;
 	int vcpu = kvm->trace_vcpu;
@@ -815,7 +817,8 @@ static const char * const record_args[] = {
 		_p;			\
 	})

-static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv)
+static int
+kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
 {
 	unsigned int rec_argc, i, j;
 	const char **rec_argv;
@@ -838,7 +841,8 @@ static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv)
 	return cmd_record(i, rec_argv, NULL);
 }

-static int kvm_events_report(struct perf_kvm *kvm, int argc, const char **argv)
+static int
+kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
 {
 	const struct option kvm_events_report_options[] = {
 		OPT_STRING(0, "event", &kvm->report_event, "report event",
@@ -881,24 +885,36 @@ static void print_kvm_stat_usage(void)
 	printf("\nOtherwise, it is the alias of 'perf stat':\n");
 }

-static int kvm_cmd_stat(struct perf_kvm *kvm, int argc, const char **argv)
+static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
 {
+	struct perf_kvm_stat kvm = {
+		.file_name = file_name,
+
+		.trace_vcpu	= -1,
+		.report_event	= "vmexit",
+		.sort_key	= "sample",
+
+		.exit_reasons = svm_exit_reasons,
+		.exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
+		.exit_reasons_isa = "SVM",
+	};
+
 	if (argc == 1) {
 		print_kvm_stat_usage();
 		goto perf_stat;
 	}

 	if (!strncmp(argv[1], "rec", 3))
-		return kvm_events_record(kvm, argc - 1, argv + 1);
+		return kvm_events_record(&kvm, argc - 1, argv + 1);

 	if (!strncmp(argv[1], "rep", 3))
-		return kvm_events_report(kvm, argc - 1 , argv + 1);
+		return kvm_events_report(&kvm, argc - 1 , argv + 1);

 perf_stat:
 	return cmd_stat(argc, argv, NULL);
 }

-static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
+static int __cmd_record(const char *file_name, int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
@@ -907,7 +923,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	rec_argv[i++] = strdup("record");
 	rec_argv[i++] = strdup("-o");
-	rec_argv[i++] = strdup(kvm->file_name);
+	rec_argv[i++] = strdup(file_name);
 	for (j = 1; j < argc; j++, i++)
 		rec_argv[i] = argv[j];

@@ -916,7 +932,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
 	return cmd_record(i, rec_argv, NULL);
 }

-static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
+static int __cmd_report(const char *file_name, int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
@@ -925,7 +941,7 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	rec_argv[i++] = strdup("report");
 	rec_argv[i++] = strdup("-i");
-	rec_argv[i++] = strdup(kvm->file_name);
+	rec_argv[i++] = strdup(file_name);
 	for (j = 1; j < argc; j++, i++)
 		rec_argv[i] = argv[j];

@@ -934,7 +950,8 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
 	return cmd_report(i, rec_argv, NULL);
 }

-static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
+static int
+__cmd_buildid_list(const char *file_name, int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
 	const char **rec_argv;
@@ -943,7 +960,7 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	rec_argv[i++] = strdup("buildid-list");
 	rec_argv[i++] = strdup("-i");
-	rec_argv[i++] = strdup(kvm->file_name);
+	rec_argv[i++] = strdup(file_name);
 	for (j = 1; j < argc; j++, i++)
 		rec_argv[i] = argv[j];

@@ -954,20 +971,12 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)

 int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
 {
-	struct perf_kvm kvm = {
-		.trace_vcpu	= -1,
-		.report_event	= "vmexit",
-		.sort_key	= "sample",
-
-		.exit_reasons = svm_exit_reasons,
-		.exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
-		.exit_reasons_isa = "SVM",
-	};
+	const char *file_name;

 	const struct option kvm_options[] = {
-		OPT_STRING('i', "input", &kvm.file_name, "file",
+		OPT_STRING('i', "input", &file_name, "file",
 			   "Input file name"),
-		OPT_STRING('o', "output", &kvm.file_name, "file",
+		OPT_STRING('o', "output", &file_name, "file",
 			   "Output file name"),
 		OPT_BOOLEAN(0, "guest", &perf_guest,
 			    "Collect guest os data"),
@@ -1002,32 +1011,32 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!perf_host)
 		perf_guest = 1;

-	if (!kvm.file_name) {
+	if (!file_name) {
 		if (perf_host && !perf_guest)
-			kvm.file_name = strdup("perf.data.host");
+			file_name = strdup("perf.data.host");
 		else if (!perf_host && perf_guest)
-			kvm.file_name = strdup("perf.data.guest");
+			file_name = strdup("perf.data.guest");
 		else
-			kvm.file_name = strdup("perf.data.kvm");
+			file_name = strdup("perf.data.kvm");

-		if (!kvm.file_name) {
+		if (!file_name) {
 			pr_err("Failed to allocate memory for filename\n");
 			return -ENOMEM;
 		}
 	}

 	if (!strncmp(argv[0], "rec", 3))
-		return __cmd_record(&kvm, argc, argv);
+		return __cmd_record(file_name, argc, argv);
 	else if (!strncmp(argv[0], "rep", 3))
-		return __cmd_report(&kvm, argc, argv);
+		return __cmd_report(file_name, argc, argv);
 	else if (!strncmp(argv[0], "diff", 4))
 		return cmd_diff(argc, argv, NULL);
 	else if (!strncmp(argv[0], "top", 3))
 		return cmd_top(argc, argv, NULL);
 	else if (!strncmp(argv[0], "buildid-list", 12))
-		return __cmd_buildid_list(&kvm, argc, argv);
+		return __cmd_buildid_list(file_name, argc, argv);
 	else if (!strncmp(argv[0], "stat", 4))
-		return kvm_cmd_stat(&kvm, argc, argv);
+		return kvm_cmd_stat(file_name, argc, argv);
 	else
 		usage_with_options(kvm_usage, kvm_options);

-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC
  2012-11-15  6:17       ` [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat Xiao Guangrong
@ 2012-11-15  6:17         ` Xiao Guangrong
  2012-11-15 10:46         ` David Howells
  1 sibling, 0 replies; 15+ messages in thread
From: Xiao Guangrong @ 2012-11-15  6:17 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Arnaldo Carvalho de Melo, Josh Boyer, David Howells, mingo,
	haodong, runzhen, dsahern, tglx, bp, namhyung, torvalds, paulus,
	linux-arch, linux-kernel, x86

Now, 'perf kvm stat' is only supported on x86, let its code depend
on ARCH_X86 to fix building it on other architectures

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 tools/perf/arch/x86/Makefile |    2 ++
 tools/perf/builtin-kvm.c     |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 815841c..320fb95 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -1,3 +1,5 @@
+ARCH_CFLAGS += -DARCH_X86
+
 ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 7fb426b..75e998a 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -22,6 +22,7 @@
 #include <pthread.h>
 #include <math.h>

+#ifdef ARCH_X86
 #include "../../arch/x86/include/asm/svm.h"
 #include "../../arch/x86/include/asm/vmx.h"
 #include "../../arch/x86/include/asm/kvm.h"
@@ -913,6 +914,7 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
 perf_stat:
 	return cmd_stat(argc, argv, NULL);
 }
+#endif

 static int __cmd_record(const char *file_name, int argc, const char **argv)
 {
@@ -1035,8 +1037,10 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
 		return cmd_top(argc, argv, NULL);
 	else if (!strncmp(argv[0], "buildid-list", 12))
 		return __cmd_buildid_list(file_name, argc, argv);
+#ifdef ARCH_X86
 	else if (!strncmp(argv[0], "stat", 4))
 		return kvm_cmd_stat(file_name, argc, argv);
+#endif
 	else
 		usage_with_options(kvm_usage, kvm_options);

-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC
  2012-11-15  6:17       ` [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat Xiao Guangrong
  2012-11-15  6:17         ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC Xiao Guangrong
@ 2012-11-15 10:46         ` David Howells
  2012-11-19  8:19           ` Xiao Guangrong
  2012-11-19 22:22           ` David Howells
  1 sibling, 2 replies; 15+ messages in thread
From: David Howells @ 2012-11-15 10:46 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: dhowells, Arnaldo Carvalho de Melo, Josh Boyer, mingo, haodong,
	runzhen, dsahern, tglx, bp, namhyung, torvalds, paulus,
	linux-arch, linux-kernel, x86

Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> wrote:

> Now, 'perf kvm stat' is only supported on x86, let its code depend
> on ARCH_X86 to fix building it on other architectures

Other parts of perf do this sort of thing:

	#if defined(__x86_64__) || defined(__i386__)

David

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC
  2012-11-15 10:46         ` David Howells
@ 2012-11-19  8:19           ` Xiao Guangrong
  2012-11-19 22:22           ` David Howells
  1 sibling, 0 replies; 15+ messages in thread
From: Xiao Guangrong @ 2012-11-19  8:19 UTC (permalink / raw)
  To: David Howells
  Cc: Arnaldo Carvalho de Melo, Josh Boyer, mingo, haodong, runzhen,
	dsahern, tglx, bp, namhyung, torvalds, paulus, linux-arch,
	linux-kernel, x86

On 11/15/2012 06:46 PM, David Howells wrote:
> Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> wrote:
> 
>> Now, 'perf kvm stat' is only supported on x86, let its code depend
>> on ARCH_X86 to fix building it on other architectures
> 
> Other parts of perf do this sort of thing:
> 
> 	#if defined(__x86_64__) || defined(__i386__)
> 

Yes, thanks for you point it out, David! How about this one?

Subject: [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC

Now, 'perf kvm stat' is only supported on x86, let its code depend
on ARCH_X86 to fix building it on other architectures

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 tools/perf/builtin-kvm.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 7fb426b..df30ca0 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -22,6 +22,7 @@
 #include <pthread.h>
 #include <math.h>

+#if defined(__i386__) || defined(__x86_64__)
 #include "../../arch/x86/include/asm/svm.h"
 #include "../../arch/x86/include/asm/vmx.h"
 #include "../../arch/x86/include/asm/kvm.h"
@@ -913,6 +914,7 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
 perf_stat:
 	return cmd_stat(argc, argv, NULL);
 }
+#endif

 static int __cmd_record(const char *file_name, int argc, const char **argv)
 {
@@ -1035,8 +1037,10 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
 		return cmd_top(argc, argv, NULL);
 	else if (!strncmp(argv[0], "buildid-list", 12))
 		return __cmd_buildid_list(file_name, argc, argv);
+#if defined(__i386__) || defined(__x86_64__)
 	else if (!strncmp(argv[0], "stat", 4))
 		return kvm_cmd_stat(file_name, argc, argv);
+#endif
 	else
 		usage_with_options(kvm_usage, kvm_options);

-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC
  2012-11-15 10:46         ` David Howells
  2012-11-19  8:19           ` Xiao Guangrong
@ 2012-11-19 22:22           ` David Howells
  1 sibling, 0 replies; 15+ messages in thread
From: David Howells @ 2012-11-19 22:22 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: dhowells, Arnaldo Carvalho de Melo, Josh Boyer, mingo, haodong,
	runzhen, dsahern, tglx, bp, namhyung, torvalds, paulus,
	linux-arch, linux-kernel, x86

Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> wrote:

> Yes, thanks for you point it out, David! How about this one?
> 
> Subject: [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC
> 
> Now, 'perf kvm stat' is only supported on x86, let its code depend
> on ARCH_X86 to fix building it on other architectures
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>

Reviewed-by: David Howells <dhowells@redhat.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-11-19 22:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
2012-11-12 20:23 ` Josh Boyer
2012-11-13 11:11 ` David Howells
2012-11-13 11:12 ` David Howells
2012-11-13 12:51   ` Josh Boyer
2012-11-13 15:24 ` David Howells
2012-11-13 15:42   ` Josh Boyer
2012-11-13 15:42     ` Josh Boyer
2012-11-13 16:34     ` Arnaldo Carvalho de Melo
2012-11-15  2:23       ` Xiao Guangrong
2012-11-15  6:17       ` [PATCH 1/2] perf kvm: rename perf_kvm to perf_kvm_stat Xiao Guangrong
2012-11-15  6:17         ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC Xiao Guangrong
2012-11-15 10:46         ` David Howells
2012-11-19  8:19           ` Xiao Guangrong
2012-11-19 22:22           ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).