All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] UAPI: perf fixes
@ 2012-11-08 12:51 David Howells
  2012-11-12 20:23 ` Josh Boyer
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ 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] 21+ 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
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 21+ 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] 21+ 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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 21+ 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] 21+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
@ 2012-11-13 11:12   ` David Howells
  2012-11-13 11:11 ` David Howells
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 21+ 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] 21+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
@ 2012-11-13 11:12   ` David Howells
  0 siblings, 0 replies; 21+ 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] 21+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  2012-11-13 11:12   ` David Howells
  (?)
@ 2012-11-13 12:51   ` Josh Boyer
  -1 siblings, 0 replies; 21+ 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] 21+ 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
  2012-12-01 11:15 ` [tip:perf/urgent] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 21+ 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] 21+ 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 16:34     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 21+ 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] 21+ messages in thread

* Re: [GIT PULL] UAPI: perf fixes
  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
  0 siblings, 2 replies; 21+ 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] 21+ 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; 21+ 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] 21+ 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
                           ` (2 more replies)
  1 sibling, 3 replies; 21+ 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] 21+ 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
  2012-12-01 11:20         ` [tip:perf/urgent] perf kvm: Rename perf_kvm to perf_kvm_stat tip-bot for Xiao Guangrong
  2 siblings, 0 replies; 21+ 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] 21+ 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           ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC David Howells
  2012-12-01 11:20         ` [tip:perf/urgent] perf kvm: Rename perf_kvm to perf_kvm_stat tip-bot for Xiao Guangrong
  2 siblings, 2 replies; 21+ 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] 21+ 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-12-01 11:21             ` [tip:perf/urgent] perf kvm: Fix building perf kvm on non x86 arches tip-bot for Xiao Guangrong
  2012-11-19 22:22           ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC David Howells
  1 sibling, 1 reply; 21+ 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] 21+ 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; 21+ 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] 21+ messages in thread

* [tip:perf/urgent] tools: Define a Makefile function to do subdir processing
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
                   ` (3 preceding siblings ...)
  2012-11-13 15:24 ` David Howells
@ 2012-12-01 11:15 ` tip-bot for David Howells
  2012-12-01 11:16 ` [tip:perf/urgent] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 21+ messages in thread
From: tip-bot for David Howells @ 2012-12-01 11:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	dhowells, tglx

Commit-ID:  ca9dfc6cc45a8ae0297188f5fed23af242cc8a8d
Gitweb:     http://git.kernel.org/tip/ca9dfc6cc45a8ae0297188f5fed23af242cc8a8d
Author:     David Howells <dhowells@redhat.com>
AuthorDate: Mon, 5 Nov 2012 15:15:24 +0000
Committer:  David Howells <dhowells@redhat.com>
CommitDate: Mon, 19 Nov 2012 22:10:14 +0000

tools: Define a Makefile function to do subdir processing

Define a Makefile function that can be called with $(call ...) to wrap
the subdir make invocations in tools/Makefile.

This will allow us in the next patch to insert bits in there to honour
O= flags when called from the top-level Makefile.

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1378.1352379110@warthog.procyon.org.uk
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/Makefile                 | 24 ++++++++++++------------
 tools/scripts/Makefile.include |  8 ++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index 3ae4394..1f9a529 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -31,44 +31,44 @@ help:
 	@echo '  clean: a summary clean target to clean _all_ folders'
 
 cpupower: FORCE
-	$(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/$@)
 
 firewire lguest perf usb virtio vm: FORCE
-	$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
+	$(call descend,$@)
 
 selftests: FORCE
-	$(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1)
+	$(call descend,testing/$@)
 
 turbostat x86_energy_perf_policy: FORCE
-	$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/x86/$@)
 
 cpupower_install:
-	$(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/$(@:_install=),install)
 
 firewire_install lguest_install perf_install usb_install virtio_install vm_install:
-	$(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,$(@:_install=),install)
 
 selftests_install:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install
+	$(call descend,testing/$(@:_clean=),install)
 
 turbostat_install x86_energy_perf_policy_install:
-	$(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/x86/$(@:_install=),install)
 
 install: cpupower_install firewire_install lguest_install perf_install \
 		selftests_install turbostat_install usb_install virtio_install \
 		vm_install x86_energy_perf_policy_install
 
 cpupower_clean:
-	$(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/cpupower,clean)
 
 firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
-	$(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,testing/$(@:_clean=),clean)
 
 turbostat_clean x86_energy_perf_policy_clean:
-	$(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/x86/$(@:_clean=),clean)
 
 clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
 		turbostat_clean usb_clean virtio_clean vm_clean \
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 96ce80a..4a9e317 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -41,6 +41,14 @@ else
 NO_SUBDIR = :
 endif
 
+#
+# Define a callable command for descending to a new directory
+#
+# Call by doing: $(call descend,directory[,target])
+#
+descend = \
+	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+
 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 

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

* [tip:perf/urgent] tools: Honour the O= flag when tool build called from a higher Makefile
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
                   ` (4 preceding siblings ...)
  2012-12-01 11:15 ` [tip:perf/urgent] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
@ 2012-12-01 11:16 ` tip-bot for David Howells
  2012-12-08 15:07 ` [tip:perf/core] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
  2012-12-08 15:08 ` [tip:perf/core] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells
  7 siblings, 0 replies; 21+ messages in thread
From: tip-bot for David Howells @ 2012-12-01 11:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	dhowells, tglx

Commit-ID:  bf35182ffcd00d8b36d56210ffdac110e5624d7d
Gitweb:     http://git.kernel.org/tip/bf35182ffcd00d8b36d56210ffdac110e5624d7d
Author:     David Howells <dhowells@redhat.com>
AuthorDate: Mon, 5 Nov 2012 21:02:08 +0000
Committer:  David Howells <dhowells@redhat.com>
CommitDate: Mon, 19 Nov 2012 22:10:30 +0000

tools: Honour the O= flag when tool build called from a higher Makefile

Honour the O= flag that was passed to a higher level Makefile and then passed
down as part of a tool build.

To make this work, the top-level Makefile passes the original O= flag and
subdir=tools to the tools/Makefile, and that in turn passes
subdir=$(O)/$(subdir)/foodir when building tool foo in directory
$(O)/$(subdir)/foodir (where the intervening slashes aren't added if an
element is missing).

For example, take perf.  This is found in tools/perf/.  Assume we're building
into directory ~/zebra/, so we pass O=~/zebra to make.  Dependening on where
we run the build from, we see:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			~/zebra/tools/perf/
	linux/tools		~/zebra/perf/
	linux/tools/perf	~/zebra/

and if O= is not set, we get:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			linux/tools/perf/
	linux/tools		linux/tools/perf/
	linux/tools/perf	linux/tools/perf/

The output directories are created by the descend function if they don't
already exist.

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1378.1352379110@warthog.procyon.org.uk
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 Makefile                       |  6 ++++--
 tools/scripts/Makefile.include | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 42d0e56..71dc31e 100644
--- a/Makefile
+++ b/Makefile
@@ -1321,10 +1321,12 @@ kernelversion:
 
 # Clear a bunch of variables before executing the submake
 tools/: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
 
 tools/%: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $*
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
 
 # Single targets
 # ---------------------------------------------------------------------------
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 4a9e317..87467b1 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,8 +1,11 @@
-ifeq ("$(origin O)", "command line")
+ifeq ($(origin O), command line)
 	dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
 	ABSOLUTE_O := $(shell cd $(O) ; pwd)
-	OUTPUT := $(ABSOLUTE_O)/
+	OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
 	COMMAND_O := O=$(ABSOLUTE_O)
+ifeq ($(objtree),)
+	objtree := $(O)
+endif
 endif
 
 ifneq ($(OUTPUT),)
@@ -47,9 +50,10 @@ endif
 # Call by doing: $(call descend,directory[,target])
 #
 descend = \
-	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+	+mkdir -p $(OUTPUT)$(1) && \
+	$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
 
-QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 
 ifneq ($(findstring $(MAKEFLAGS),s),s)
@@ -64,5 +68,10 @@ ifndef V
 			 $(MAKE) $(PRINT_DIR) -C $$subdir
 	QUIET_FLEX     = @echo '   ' FLEX $@;
 	QUIET_BISON    = @echo '   ' BISON $@;
+
+	descend = \
+		@echo '   ' DESCEND $(1); \
+		mkdir -p $(OUTPUT)$(1) && \
+		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
 endif
 endif

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

* [tip:perf/urgent] perf kvm: Rename perf_kvm to perf_kvm_stat
  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-12-01 11:20         ` tip-bot for Xiao Guangrong
  2 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Xiao Guangrong @ 2012-12-01 11:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	runzhen, dhowells, xiaoguangrong, haodong, dsahern, tglx,
	jwboyer

Commit-ID:  3786063a3c0ba26a2400a04476c0c0ccfd3c6beb
Gitweb:     http://git.kernel.org/tip/3786063a3c0ba26a2400a04476c0c0ccfd3c6beb
Author:     Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
AuthorDate: Thu, 15 Nov 2012 14:17:01 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 23 Nov 2012 19:44:05 -0300

perf kvm: Rename perf_kvm to perf_kvm_stat

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

Preparatory patch to stop trying to build parts of this tool that for
now are only supported on x86.

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Dong Hao <haodong@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/50A488DD.6090106@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-kvm.c | 111 +++++++++++++++++++++++++----------------------
 1 file changed, 60 insertions(+), 51 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index e013bdb..9fa45fa 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)
 {
 	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;
@@ -381,7 +381,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)
 {
@@ -425,7 +425,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)
@@ -486,7 +486,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)
@@ -541,7 +541,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;
 
@@ -577,7 +577,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;
 
@@ -590,7 +591,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;
@@ -627,7 +628,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;
@@ -670,7 +671,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",
@@ -701,7 +703,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;
 
@@ -750,7 +752,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;
@@ -798,7 +800,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;
@@ -821,7 +824,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",
@@ -864,24 +868,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;
@@ -890,7 +906,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];
 
@@ -899,7 +915,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;
@@ -908,7 +924,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];
 
@@ -917,7 +933,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;
@@ -926,7 +943,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];
 
@@ -937,20 +954,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"),
@@ -985,32 +994,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);
 

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

* [tip:perf/urgent] perf kvm: Fix building perf kvm on non x86 arches
  2012-11-19  8:19           ` Xiao Guangrong
@ 2012-12-01 11:21             ` tip-bot for Xiao Guangrong
  0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Xiao Guangrong @ 2012-12-01 11:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	runzhen, dhowells, xiaoguangrong, haodong, dsahern, tglx,
	jwboyer

Commit-ID:  7321090f6751c9987c26a8c81c63680d16a614d7
Gitweb:     http://git.kernel.org/tip/7321090f6751c9987c26a8c81c63680d16a614d7
Author:     Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
AuthorDate: Mon, 19 Nov 2012 16:19:21 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 23 Nov 2012 20:40:17 -0300

perf kvm: Fix building perf kvm on non x86 arches

Now, 'perf kvm stat' is only supported on x86, let its code depend on
(__x86_64__ || __i386__) to fix building it on other architectures.

Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Dong Hao <haodong@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/50A9EB89.70901@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-kvm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 9fa45fa..283b439 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 <asm/svm.h>
 #include <asm/vmx.h>
 #include <asm/kvm.h>
@@ -896,6 +897,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)
 {
@@ -1018,8 +1020,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);
 

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

* [tip:perf/core] tools: Define a Makefile function to do subdir processing
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
                   ` (5 preceding siblings ...)
  2012-12-01 11:16 ` [tip:perf/urgent] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells
@ 2012-12-08 15:07 ` tip-bot for David Howells
  2012-12-08 15:08 ` [tip:perf/core] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells
  7 siblings, 0 replies; 21+ messages in thread
From: tip-bot for David Howells @ 2012-12-08 15:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	dhowells, tglx

Commit-ID:  0bca6cff89c6e7d1e383993cccf0f59146874a34
Gitweb:     http://git.kernel.org/tip/0bca6cff89c6e7d1e383993cccf0f59146874a34
Author:     David Howells <dhowells@redhat.com>
AuthorDate: Mon, 5 Nov 2012 15:15:24 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:53:11 -0300

tools: Define a Makefile function to do subdir processing

Define a Makefile function that can be called with $(call ...) to wrap
the subdir make invocations in tools/Makefile.

This will allow us in the next patch to insert bits in there to honour
O= flags when called from the top-level Makefile.

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1378.1352379110@warthog.procyon.org.uk
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/Makefile                 | 24 ++++++++++++------------
 tools/scripts/Makefile.include |  8 ++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index 3ae4394..1f9a529 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -31,44 +31,44 @@ help:
 	@echo '  clean: a summary clean target to clean _all_ folders'
 
 cpupower: FORCE
-	$(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/$@)
 
 firewire lguest perf usb virtio vm: FORCE
-	$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
+	$(call descend,$@)
 
 selftests: FORCE
-	$(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1)
+	$(call descend,testing/$@)
 
 turbostat x86_energy_perf_policy: FORCE
-	$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/x86/$@)
 
 cpupower_install:
-	$(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/$(@:_install=),install)
 
 firewire_install lguest_install perf_install usb_install virtio_install vm_install:
-	$(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,$(@:_install=),install)
 
 selftests_install:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install
+	$(call descend,testing/$(@:_clean=),install)
 
 turbostat_install x86_energy_perf_policy_install:
-	$(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/x86/$(@:_install=),install)
 
 install: cpupower_install firewire_install lguest_install perf_install \
 		selftests_install turbostat_install usb_install virtio_install \
 		vm_install x86_energy_perf_policy_install
 
 cpupower_clean:
-	$(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/cpupower,clean)
 
 firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
-	$(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,testing/$(@:_clean=),clean)
 
 turbostat_clean x86_energy_perf_policy_clean:
-	$(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/x86/$(@:_clean=),clean)
 
 clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
 		turbostat_clean usb_clean virtio_clean vm_clean \
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 96ce80a..4a9e317 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -41,6 +41,14 @@ else
 NO_SUBDIR = :
 endif
 
+#
+# Define a callable command for descending to a new directory
+#
+# Call by doing: $(call descend,directory[,target])
+#
+descend = \
+	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+
 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 

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

* [tip:perf/core] tools: Honour the O= flag when tool build called from a higher Makefile
  2012-11-08 12:51 [GIT PULL] UAPI: perf fixes David Howells
                   ` (6 preceding siblings ...)
  2012-12-08 15:07 ` [tip:perf/core] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
@ 2012-12-08 15:08 ` tip-bot for David Howells
  7 siblings, 0 replies; 21+ messages in thread
From: tip-bot for David Howells @ 2012-12-08 15:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, torvalds, namhyung, bp,
	dhowells, tglx

Commit-ID:  9db48cd5ccd0d127e991c15509a0241a18043e91
Gitweb:     http://git.kernel.org/tip/9db48cd5ccd0d127e991c15509a0241a18043e91
Author:     David Howells <dhowells@redhat.com>
AuthorDate: Mon, 5 Nov 2012 21:02:08 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 14 Nov 2012 16:53:22 -0300

tools: Honour the O= flag when tool build called from a higher Makefile

Honour the O= flag that was passed to a higher level Makefile and then passed
down as part of a tool build.

To make this work, the top-level Makefile passes the original O= flag and
subdir=tools to the tools/Makefile, and that in turn passes
subdir=$(O)/$(subdir)/foodir when building tool foo in directory
$(O)/$(subdir)/foodir (where the intervening slashes aren't added if an
element is missing).

For example, take perf.  This is found in tools/perf/.  Assume we're building
into directory ~/zebra/, so we pass O=~/zebra to make.  Dependening on where
we run the build from, we see:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			~/zebra/tools/perf/
	linux/tools		~/zebra/perf/
	linux/tools/perf	~/zebra/

and if O= is not set, we get:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			linux/tools/perf/
	linux/tools		linux/tools/perf/
	linux/tools/perf	linux/tools/perf/

The output directories are created by the descend function if they don't
already exist.

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1378.1352379110@warthog.procyon.org.uk
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 Makefile                       |  6 ++++--
 tools/scripts/Makefile.include | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 14c93b3..08a31d8 100644
--- a/Makefile
+++ b/Makefile
@@ -1321,10 +1321,12 @@ kernelversion:
 
 # Clear a bunch of variables before executing the submake
 tools/: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
 
 tools/%: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $*
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
 
 # Single targets
 # ---------------------------------------------------------------------------
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 4a9e317..87467b1 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,8 +1,11 @@
-ifeq ("$(origin O)", "command line")
+ifeq ($(origin O), command line)
 	dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
 	ABSOLUTE_O := $(shell cd $(O) ; pwd)
-	OUTPUT := $(ABSOLUTE_O)/
+	OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
 	COMMAND_O := O=$(ABSOLUTE_O)
+ifeq ($(objtree),)
+	objtree := $(O)
+endif
 endif
 
 ifneq ($(OUTPUT),)
@@ -47,9 +50,10 @@ endif
 # Call by doing: $(call descend,directory[,target])
 #
 descend = \
-	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+	+mkdir -p $(OUTPUT)$(1) && \
+	$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
 
-QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 
 ifneq ($(findstring $(MAKEFLAGS),s),s)
@@ -64,5 +68,10 @@ ifndef V
 			 $(MAKE) $(PRINT_DIR) -C $$subdir
 	QUIET_FLEX     = @echo '   ' FLEX $@;
 	QUIET_BISON    = @echo '   ' BISON $@;
+
+	descend = \
+		@echo '   ' DESCEND $(1); \
+		mkdir -p $(OUTPUT)$(1) && \
+		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
 endif
 endif

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

end of thread, other threads:[~2012-12-08 15:10 UTC | newest]

Thread overview: 21+ 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 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 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-12-01 11:21             ` [tip:perf/urgent] perf kvm: Fix building perf kvm on non x86 arches tip-bot for Xiao Guangrong
2012-11-19 22:22           ` [PATCH 2/2] perf kvm: fix building perf kvm on PowerPC David Howells
2012-12-01 11:20         ` [tip:perf/urgent] perf kvm: Rename perf_kvm to perf_kvm_stat tip-bot for Xiao Guangrong
2012-12-01 11:15 ` [tip:perf/urgent] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
2012-12-01 11:16 ` [tip:perf/urgent] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells
2012-12-08 15:07 ` [tip:perf/core] tools: Define a Makefile function to do subdir processing tip-bot for David Howells
2012-12-08 15:08 ` [tip:perf/core] tools: Honour the O= flag when tool build called from a higher Makefile tip-bot for David Howells

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.