Skip to contentSkip to conversation

perf: persistent events prototype

RFC PATCH In review Borislav Petkov 6 participants 28 messages May 22, 2010 – Jun 17, 2010 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

cover perf: persistent events prototype

Hi,

here is my first stab at persistent events. And since it is a first one, there's no special tricks but simply all subsystems which init before perf and have declared static tracepoints, simply mark some of them as persistent and perf enables them when inits.

I haven't tested this yet and will do so when I get to work next week but I'm sending it out now so that I can get your thoughts on this and whether this is an agreeable direction I'm taking.

Couple of yet unresolved issues I see with this:

* persistent events are enabled unconditionally on all cpus and while this makes sense for MCEs tracing, do we still want to be flexible here and supply a cpumask instead?

* what happens if there's no consumer for the traced data, the easiest would be to do nothing and let it get truncated in the trace buffer with newer data overwriting the oldest sample?

* what about other events, and most importantly, what about hw events for which we take a PMU and want to make them persistent at the same time and it so happens that after making a couple of events persistent, we run out of PMUs and make the perf tool almost useless since persistent events are hogging all the hardware resources?

* btw, perf and ftrace really need to get married :)

/me ducks now...

Thanks.

author maintainer
#1 lore raw

PATCH 2/2 x86, mce: Make MCE tracepoint persistent event

---
 arch/x86/kernel/cpu/mcheck/mce.c |    4 ++++
 include/trace/events/mce.h       |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +4 -0
index 8a6f0af..5f40726 100644
@@ -1668,6 +1668,10 @@ int __init mcheck_init(void)
 
 	mcheck_intel_therm_init();
 
+#ifdef CONFIG_EVENT_TRACING
+	event_mce_record.type = EVENT_PERSISTENT;
+#endif
+
 	return 0;
 }
 
include/trace/events/mce.h +1 -0
index 7eee778..b1ad772 100644
@@ -5,6 +5,7 @@
 #define _TRACE_MCE_H
 
 #include <linux/ktime.h>
+#include <linux/ftrace_event.h>
 #include <linux/tracepoint.h>
 #include <asm/mce.h>
 
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 4 lines · Borislav Petkov

Register and enable events marked as persistent right after perf events has initialized.

Nah, this is totally wrong.

A persistent event would simply be a regular event, but created by the kernel and not tied to a file-desc's lifetime.

author maintainer
#4 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 08:15:13PM +0200

Quoted 10 lines · Borislav Petkov
Quoted 4 lines

Register and enable events marked as persistent right after perf events has initialized.

Nah, this is totally wrong.

A persistent event would simply be a regular event, but created by the kernel and not tied to a file-desc's lifetime.

So you're saying the trace_mce_record() tracepoint for example should be created completely internally in the kernel and cease to be a tracepoint? Will it still be able to be selected by perf -e?

Please elaborate.

Signature · 2 lines
Regards/Gruss,
    Boris.
maintainer
#5 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 9 lines · Borislav Petkov

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 08:15:13PM +0200

Quoted 6 lines · Borislav Petkov
Quoted 4 lines

Register and enable events marked as persistent right after perf events has initialized.

Quoted 8 lines
Quoted 4 lines

Nah, this is totally wrong.

A persistent event would simply be a regular event, but created by the kernel and not tied to a file-desc's lifetime.

So you're saying the trace_mce_record() tracepoint for example should be created completely internally in the kernel and cease to be a tracepoint? Will it still be able to be selected by perf -e?

No, it should be a regular tracepoint as far as tracepoints are concerned.

But the only thing persistence should add is an instance of a perf_event, it should not modify either the perf_event nor the tracepoint code.

author maintainer
#6 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 08:40:47PM +0200

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

A persistent event would simply be a regular event, but created by the kernel and not tied to a file-desc's lifetime.

So you're saying the trace_mce_record() tracepoint for example should be created completely internally in the kernel and cease to be a tracepoint? Will it still be able to be selected by perf -e?

Quoted 6 lines

No, it should be a regular tracepoint as far as tracepoints are concerned.

But the only thing persistence should add is an instance of a perf_event, it should not modify either the perf_event nor the tracepoint code.

which means that subsystems which initialize earlier than perf (mce, for example) should have to be notified when perf is ready so that they could register a persistent event. How does that sound?

Signature · 2 lines
Regards/Gruss,
    Boris.
maintainer
#7 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 13 lines · Borislav Petkov

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 08:40:47PM +0200

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

A persistent event would simply be a regular event, but created by the kernel and not tied to a file-desc's lifetime.

So you're saying the trace_mce_record() tracepoint for example should be created completely internally in the kernel and cease to be a tracepoint? Will it still be able to be selected by perf -e?

No, it should be a regular tracepoint as far as tracepoints are concerned.

Quoted 7 lines
Quoted 3 lines

But the only thing persistence should add is an instance of a perf_event, it should not modify either the perf_event nor the tracepoint code.

which means that subsystems which initialize earlier than perf (mce, for example) should have to be notified when perf is ready so that they could register a persistent event. How does that sound?

Either we add some notifier thing, or we simply add an explicit call in the init sequence after the perf_event subsystem is running. I would suggest we start with some explicit call, and take it from there.

author maintainer
#8 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 09:23:21PM +0200

Quoted 3 lines

Either we add some notifier thing, or we simply add an explicit call in the init sequence after the perf_event subsystem is running. I would suggest we start with some explicit call, and take it from there.

Ok, this couldn't be more straightforward. So I looked at the init sequence we do when booting wrt to perf/ftrace initialization:

start_kernel
...
|-> sched_init

    |-> perf_event_init

...
|-> ftrace_init
rest_init
kernel_init

|-> do_pre_smp_initcalls
|...
|-> smp_int
|-> do_basic_setup
    |-> do_initcalls

and one of the convenient places after both perf is initialized and ftrace has enumerated the tracepoints is do_initcalls() (It cannot be an early_initcall since at that time we're not running SMP yet and we want the MCE event per cpu.)

So I added a core_initcall that registers the mce perf event. This makes it more or less a persistent event without any changes to the perf_event subsystem. I guess this should work - at least it builds here, will give it a run later.

As a further enhancement, the init-function should read out all the logged mce events which survived the warm reboot and those which happen between mce init and the actual event registration so that perf can postprocess those too at a more convenient time.

Thanks.

---

arch/x86/kernel/cpu/mcheck/mce.c +58 -0
index 8a6f0af..e3370a2 100644
@@ -94,6 +94,7 @@ static char			*mce_helper_argv[2] = { mce_helper, NULL };
 
 static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
 static DEFINE_PER_CPU(struct mce, mces_seen);
+static DEFINE_PER_CPU(struct perf_event *, mce_event);
 static int			cpu_missing;
 
 /*
@@ -1996,6 +1997,60 @@ static void __cpuinit mce_reenable_cpu(void *h)
 	}
 }
 
+struct perf_event_attr pattr = {
+	.type	= PERF_TYPE_TRACEPOINT,
+	.size	= sizeof(pattr),
+};
+
+static int mcheck_enable_perf_event_on_cpu(int cpu)
+{
+	struct perf_event *event;
+
+	pattr.config = event_mce_record.id;
+
+	event = perf_event_create_kernel_counter(&pattr, cpu, -1, NULL);
+	if (IS_ERR(event))
+		return -EINVAL;
+
+	perf_event_enable(event);
+	per_cpu(mce_event, cpu) = event;
+
+	return 0;
+}
+
+static void mcheck_disable_perf_event_on_cpu(int cpu)
+{
+	struct perf_event *event = per_cpu(mce_event, cpu);
+
+	if (!event)
+		return;
+
+	perf_event_disable(event);
+	per_cpu(mce_event, cpu) = NULL;
+	perf_event_release_kernel(event);
+}
+
+static int mcheck_init_perf_event(void)
+{
+	int cpu, err;
+
+	get_online_cpus();
+
+	for_each_online_cpu(cpu) {
+		err = mcheck_enable_perf_event_on_cpu(cpu);
+		if (err) {
+			printk(KERN_ERR "mce: error initializing mce tracepoint"
+					" on cpu %d\n", cpu);
+			return err;
+		}
+	}
+
+	put_online_cpus();
+
+	return 0;
+}
+core_initcall(mcheck_init_perf_event);
+
 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
 static int __cpuinit
 mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
@@ -2009,6 +2064,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 		mce_create_device(cpu);
 		if (threshold_cpu_callback)
 			threshold_cpu_callback(action, cpu);
+		mcheck_enable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_DEAD:
 	case CPU_DEAD_FROZEN:
@@ -2020,6 +2076,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 	case CPU_DOWN_PREPARE_FROZEN:
 		del_timer_sync(t);
 		smp_call_function_single(cpu, mce_disable_cpu, &action, 1);
+		mcheck_disable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_DOWN_FAILED:
 	case CPU_DOWN_FAILED_FROZEN:
@@ -2029,6 +2086,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 			add_timer_on(t, cpu);
 		}
 		smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
+		mcheck_enable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_POST_DEAD:
 		/* intentionally ignoring frozen here */
Signature · 2 lines
Regards/Gruss,
    Boris.
maintainer
#9 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 34 lines · Borislav Petkov

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 09:23:21PM +0200

Quoted 3 lines

Either we add some notifier thing, or we simply add an explicit call in the init sequence after the perf_event subsystem is running. I would suggest we start with some explicit call, and take it from there.

Ok, this couldn't be more straightforward. So I looked at the init sequence we do when booting wrt to perf/ftrace initialization:

start_kernel
...
|-> sched_init

    |-> perf_event_init

...
|-> ftrace_init
rest_init
kernel_init

|-> do_pre_smp_initcalls
|...
|-> smp_int
|-> do_basic_setup
    |-> do_initcalls

and one of the convenient places after both perf is initialized and ftrace has enumerated the tracepoints is do_initcalls() (It cannot be an early_initcall since at that time we're not running SMP yet and we want the MCE event per cpu.)

So I added a core_initcall that registers the mce perf event. This makes it more or less a persistent event without any changes to the perf_event subsystem. I guess this should work - at least it builds here, will give it a run later.

Quoted 4 lines

As a further enhancement, the init-function should read out all the logged mce events which survived the warm reboot and those which happen between mce init and the actual event registration so that perf can postprocess those too at a more convenient time.

Right, so that looks good. Now the interesting part is twofold:

1) expose these perf_events to userspace, since they're now created in kernel, there is no user-space access point to them. One way way would be to extend the perf syscall to allow attaching to an existing instance (but that would limit us to a single instance per 'attr'), or create some /debug or /sys iteration of all such events.

2) get these things a buffer, perf_events as created don't actually have an output buffer, normally that is created at mmap() time, but since you cannot mmap() a kernel side event, it doesn't get to have a buffer. This could be done by extracting perf_mmap_data_alloc() into a sensible interface.

#10 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 40 lines · Peter Zijlstra
Quoted 34 lines · Borislav Petkov

From: Peter Zijlstra <[email protected]>
Date: Sun, May 23, 2010 at 09:23:21PM +0200

Quoted 3 lines

Either we add some notifier thing, or we simply add an explicit call in the init sequence after the perf_event subsystem is running. I would suggest we start with some explicit call, and take it from there.

Ok, this couldn't be more straightforward. So I looked at the init sequence we do when booting wrt to perf/ftrace initialization:

start_kernel
...
|-> sched_init

    |-> perf_event_init

...
|-> ftrace_init
rest_init
kernel_init

|-> do_pre_smp_initcalls
|...
|-> smp_int
|-> do_basic_setup
    |-> do_initcalls

and one of the convenient places after both perf is initialized and ftrace has enumerated the tracepoints is do_initcalls() (It cannot be an early_initcall since at that time we're not running SMP yet and we want the MCE event per cpu.)

So I added a core_initcall that registers the mce perf event. This makes it more or less a persistent event without any changes to the perf_event subsystem. I guess this should work - at least it builds here, will give it a run later.

Quoted 4 lines

As a further enhancement, the init-function should read out all the logged mce events which survived the warm reboot and those which happen between mce init and the actual event registration so that perf can postprocess those too at a more convenient time.

Quoted 7 lines

Right, so that looks good. Now the interesting part is twofold:

1) expose these perf_events to userspace, since they're now created in kernel, there is no user-space access point to them. One way way would be to extend the perf syscall to allow attaching to an existing instance (but that would limit us to a single instance per 'attr'), or create some /debug or /sys iteration of all such events.

Yeah.

Quoted 5 lines

2) get these things a buffer, perf_events as created don't actually have an output buffer, normally that is created at mmap() time, but since you cannot mmap() a kernel side event, it doesn't get to have a buffer. This could be done by extracting perf_mmap_data_alloc() into a sensible interface.

#2 could be a new syscall: sys_create_ring_buffer or so?

Ingo

maintainer
#11 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 7 lines · Ingo Molnar
Quoted 5 lines

2) get these things a buffer, perf_events as created don't actually have an output buffer, normally that is created at mmap() time, but since you cannot mmap() a kernel side event, it doesn't get to have a buffer. This could be done by extracting perf_mmap_data_alloc() into a sensible interface.

#2 could be a new syscall: sys_create_ring_buffer or so?

No, they need a buffer in-kernel, syscalls aren't the ideal tool for that :-)

I've got patches refactoring the whole buffer stuff to make it more a self-contained entity.

#12 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Peter Zijlstra <[email protected]>
Date: Fri, May 28, 2010 at 05:17:40PM +0200

Quoted 8 lines · Ingo Molnar
Quoted 7 lines
Quoted 6 lines

2) get these things a buffer, perf_events as created don't actually have an output buffer, normally that is created at mmap() time, but since you cannot mmap() a kernel side event, it doesn't get to have a buffer. This could be done by extracting perf_mmap_data_alloc() into a sensible interface.

Quoted 4 lines
Quoted 1 line

#2 could be a new syscall: sys_create_ring_buffer or so?

No, they need a buffer in-kernel, syscalls aren't the ideal tool for that :-)

Yeah, I need a per-cpu buffer ready at event registration/enable time, maybe even have perf_event_create_kernel_counter() take care of that buffer allocation with a flag or similar prior to enabling the event...

Quoted 2 lines

I've got patches refactoring the whole buffer stuff to make it more a self-contained entity.

Can I see those when you're done so that I can base my stuff on top?

Thanks.

Signature · 5 lines
Regards/Gruss,
Boris.

Operating Systems Research Center
Advanced Micro Devices, Inc.
maintainer
#13 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Quoted 16 lines · Borislav Petkov

From: Peter Zijlstra <[email protected]>
Date: Fri, May 28, 2010 at 05:17:40PM +0200

Quoted 8 lines · Ingo Molnar
Quoted 7 lines
Quoted 6 lines

2) get these things a buffer, perf_events as created don't actually have an output buffer, normally that is created at mmap() time, but since you cannot mmap() a kernel side event, it doesn't get to have a buffer. This could be done by extracting perf_mmap_data_alloc() into a sensible interface.

Quoted 4 lines
Quoted 1 line

#2 could be a new syscall: sys_create_ring_buffer or so?

No, they need a buffer in-kernel, syscalls aren't the ideal tool for that :-)

Quoted 8 lines

Yeah, I need a per-cpu buffer ready at event registration/enable time, maybe even have perf_event_create_kernel_counter() take care of that buffer allocation with a flag or similar prior to enabling the event...

Quoted 2 lines

I've got patches refactoring the whole buffer stuff to make it more a self-contained entity.

Can I see those when you're done so that I can base my stuff on top?

They can be found at:

http://programming.kicks-ass.net/sekrit/patches.tar.bz2

ignore the last 5 patches, those are random hackery.

In particular, look at:

patches/perf-fix-buffer-redirect.patch
patches/perf-buffer.patch
patches/perf-buffer-init.patch

(they won't apply separately in that order, simply push the full queue until the last one or further)

After that you should be able to add:

  buffer = perf_buffer_alloc(nr_pages, watermark, cpu, flags);
  rcu_assign_pointer(event->buffer, buffer);

to allocate and attach a buffer to your event (do so for each cpu's MCE event).

After that we still need a way to expose all that to userspace, but at least the events will be complete and able to record bits ;-)

#14 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Peter Zijlstra <[email protected]>
Date: Fri, May 28, 2010 at 08:07:10PM +0200

Quoted 17 lines

They can be found at:

http://programming.kicks-ass.net/sekrit/patches.tar.bz2

ignore the last 5 patches, those are random hackery.

In particular, look at:

patches/perf-fix-buffer-redirect.patch
patches/perf-buffer.patch
patches/perf-buffer-init.patch

(they won't apply separately in that order, simply push the full queue until the last one or further)

After that you should be able to add:

Quoted 8 lines
  buffer = perf_buffer_alloc(nr_pages, watermark, cpu, flags);
  rcu_assign_pointer(event->buffer, buffer);

to allocate and attach a buffer to your event (do so for each cpu's MCE event).

After that we still need a way to expose all that to userspace, but at least the events will be complete and able to record bits ;-)

Yep, so far so good, the kernel side is almost done - this was the easy part :). So recently I started looking into how the userspace part could be done most efficiently so that, initially, the RAS daemon doesn't suck in all of tools/perf when building and depend unnecessary on libelf etc, and, at the same time, doesn't duplicate functionality like util/debugfs, get_debugfs_mntpt(), parse_events() maybe later etc.

So, the best way to do this, IMHO, is if I start carving out common and generic functionality into tools/lib/ or tools/util/ or similar so that perf and ras can share those. And maybe later even other tools. This could be where we host all the kernel headers stuff which are good for userspace, i.e. those which are in tools/perf/util/include/linux/

Opinions, comments?

Signature · 5 lines
Regards/Gruss,
Boris.

Operating Systems Research Center
Advanced Micro Devices, Inc.
#15 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Em Thu, Jun 03, 2010 at 03:43:01PM +0200, Borislav Petkov escreveu:

Quoted 15 lines

From: Peter Zijlstra <[email protected]>
Date: Fri, May 28, 2010 at 08:07:10PM +0200

Quoted 5 lines

to allocate and attach a buffer to your event (do so for each cpu's MCE event).

After that we still need a way to expose all that to userspace, but at least the events will be complete and able to record bits ;-)

Yep, so far so good, the kernel side is almost done - this was the easy part :). So recently I started looking into how the userspace part could be done most efficiently so that, initially, the RAS daemon doesn't suck in all of tools/perf when building and depend unnecessary on libelf etc, and, at the same time, doesn't duplicate functionality like util/debugfs, get_debugfs_mntpt(), parse_events() maybe later etc.

Quoted 7 lines

So, the best way to do this, IMHO, is if I start carving out common and generic functionality into tools/lib/ or tools/util/ or similar so that perf and ras can share those. And maybe later even other tools. This could be where we host all the kernel headers stuff which are good for userspace, i.e. those which are in tools/perf/util/include/linux/

Opinions, comments?

Right, that has to be done, I have sample code I want to put in samples/ to show how to use the symbol libraries in tools/perf/util/, will take a stab at moving things for tools/lib/.

We'll need a top level Makefile, I guess, so that when asking to build tools/perf, it notices that it has to build tools/lib/, etc.

Probably we'll need tools/lib/symbols/, tools/lib/trace/parser/ things like that, I'll start with the symbols part, using a samples/ file I already wrote.

- Arnaldo

author maintainer
#16 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, Jun 03, 2010 at 02:32:42PM -0300

Quoted 22 lines

Em Thu, Jun 03, 2010 at 03:43:01PM +0200, Borislav Petkov escreveu:

Quoted 21 lines

From: Peter Zijlstra <[email protected]>
Date: Fri, May 28, 2010 at 08:07:10PM +0200

Quoted 5 lines

to allocate and attach a buffer to your event (do so for each cpu's MCE event).

After that we still need a way to expose all that to userspace, but at least the events will be complete and able to record bits ;-)

Yep, so far so good, the kernel side is almost done - this was the easy part :). So recently I started looking into how the userspace part could be done most efficiently so that, initially, the RAS daemon doesn't suck in all of tools/perf when building and depend unnecessary on libelf etc, and, at the same time, doesn't duplicate functionality like util/debugfs, get_debugfs_mntpt(), parse_events() maybe later etc.

So, the best way to do this, IMHO, is if I start carving out common and generic functionality into tools/lib/ or tools/util/ or similar so that perf and ras can share those. And maybe later even other tools. This could be where we host all the kernel headers stuff which are good for userspace, i.e. those which are in tools/perf/util/include/linux/

Quoted 5 lines
Quoted 1 line

Opinions, comments?

Right, that has to be done, I have sample code I want to put in samples/ to show how to use the symbol libraries in tools/perf/util/, will take a stab at moving things for tools/lib/.

Cool.

Quoted 2 lines

We'll need a top level Makefile, I guess, so that when asking to build tools/perf, it notices that it has to build tools/lib/, etc.

Yep.

Quoted 3 lines

Probably we'll need tools/lib/symbols/, tools/lib/trace/parser/ things like that, I'll start with the symbols part, using a samples/ file I already wrote.

Nice, let me know when you have something ready so that we don't duplicate work. Also, I could give it a test run or two and all.

Thanks.

Signature · 2 lines
Regards/Gruss,
    Boris.
#17 lore raw

Re: [PATCH 1/2] perf: Add persistent events

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, Jun 03, 2010 at 02:32:42PM -0300

Quoted 10 lines

Right, that has to be done, I have sample code I want to put in samples/ to show how to use the symbol libraries in tools/perf/util/, will take a stab at moving things for tools/lib/.

We'll need a top level Makefile, I guess, so that when asking to build tools/perf, it notices that it has to build tools/lib/, etc.

Probably we'll need tools/lib/symbols/, tools/lib/trace/parser/ things like that, I'll start with the symbols part, using a samples/ file I already wrote.

Right, so I started playing with this, added a global Makefile to tools/ and from there we descend into lib/ and perf/ in that order to prepare all the modules for the perflib. I've played with the include paths so that you can have #include <util/util.h> for all that generic library stuff.

The patch below carves out the debugfs helpers along with some generic headers, please take a look and let me know if this is an agreeable direction I'm going. Yeah, it is big, I think vger won't be able to swallow it but this is only moving files around so...

Thanks.

--

Quoted 1 line

From 0f391f0acf39d3b2e85145dce389cbf425cb7cdd Mon Sep 17 00:00:00 2001

From: Borislav Petkov <[email protected]>
Date: Mon, 14 Jun 2010 21:14:15 +0200
Subject: [PATCH] perf: rewire generic library stuff

---
 tools/Makefile                                     |   74 +++++
 tools/lib/Makefile                                 |   41 +++
 tools/lib/util/cache.h                             |   86 ++++++
 tools/lib/util/debugfs.c                           |  252 +++++++++++++++++
 tools/lib/util/debugfs.h                           |   31 +++
 tools/lib/util/strbuf.c                            |  133 +++++++++
 tools/lib/util/strbuf.h                            |   92 +++++++
 tools/lib/util/types.h                             |   17 ++
 tools/lib/util/util.h                              |  282 ++++++++++++++++++++
 tools/perf/Makefile                                |   64 +----
 tools/perf/bench/bench.h                           |    2 +
 tools/perf/bench/mem-memcpy.c                      |    2 +-
 tools/perf/bench/sched-messaging.c                 |    2 +-
 tools/perf/bench/sched-pipe.c                      |    2 +-
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
 tools/perf/perf.c                                  |   15 +-
 tools/perf/perf.h                                  |    2 +
 tools/perf/util/abspath.c                          |    2 +-
 tools/perf/util/alias.c                            |    3 +-
 tools/perf/util/build-id.c                         |    2 +-
 tools/perf/util/cache.h                            |   86 ------
 tools/perf/util/callchain.c                        |    2 +-
 tools/perf/util/color.c                            |    2 +-
 tools/perf/util/color.h                            |    2 +
 tools/perf/util/config.c                           |    5 +-
 tools/perf/util/cpumap.c                           |    2 +-
 tools/perf/util/ctype.c                            |    2 +-
 tools/perf/util/debug.c                            |    4 +-
 tools/perf/util/debugfs.c                          |  240 -----------------
 tools/perf/util/debugfs.h                          |   25 --
 tools/perf/util/environment.c                      |    2 +-
 tools/perf/util/exec_cmd.c                         |    2 +-
 tools/perf/util/header.c                           |    2 +-
 tools/perf/util/header.h                           |    2 +-
 tools/perf/util/help.c                             |    4 +-
 tools/perf/util/hist.c                             |    2 +-
 tools/perf/util/levenshtein.c                      |    2 +-
 tools/perf/util/map.h                              |    2 +-
 tools/perf/util/newt.c                             |    2 +-
 tools/perf/util/pager.c                            |    2 +-
 tools/perf/util/parse-events.c                     |    8 +-
 tools/perf/util/parse-events.h                     |    4 +-
 tools/perf/util/parse-options.c                    |    5 +-
 tools/perf/util/path.c                             |    2 +-
 tools/perf/util/probe-event.c                      |    6 +-
 tools/perf/util/probe-finder.c                     |    2 +-
 tools/perf/util/probe-finder.h                     |    2 +-
 tools/perf/util/pstack.c                           |    2 +-
 tools/perf/util/quote.c                            |    2 +-
 tools/perf/util/run-command.c                      |    2 +-
 .../perf/util/scripting-engines/trace-event-perl.c |    2 +-
 .../util/scripting-engines/trace-event-python.c    |    2 +-
 tools/perf/util/session.c                          |    2 +-
 tools/perf/util/sigchain.c                         |    2 +-
 tools/perf/util/sort.h                             |    4 +-
 tools/perf/util/strbuf.c                           |  133 ---------
 tools/perf/util/strbuf.h                           |   92 -------
 tools/perf/util/string.c                           |    2 +-
 tools/perf/util/svghelper.h                        |    2 +-
 tools/perf/util/thread.c                           |    2 +-
 tools/perf/util/trace-event-info.c                 |    2 +-
 tools/perf/util/trace-event-parse.c                |    2 +-
 tools/perf/util/trace-event-read.c                 |    2 +-
 tools/perf/util/trace-event-scripting.c            |    2 +-
 tools/perf/util/types.h                            |   17 --
 tools/perf/util/usage.c                            |    2 +-
 tools/perf/util/util.c                             |    2 +-
 tools/perf/util/util.h                             |  282 --------------------
 tools/perf/util/values.c                           |    2 +-
 tools/perf/util/values.h                           |    2 +-
 tools/perf/util/wrapper.c                          |    3 +-
 72 files changed, 1089 insertions(+), 1009 deletions(-)
 create mode 100644 tools/Makefile
 create mode 100644 tools/lib/Makefile
 create mode 100644 tools/lib/util/cache.h
 create mode 100644 tools/lib/util/debugfs.c
 create mode 100644 tools/lib/util/debugfs.h
 create mode 100644 tools/lib/util/strbuf.c
 create mode 100644 tools/lib/util/strbuf.h
 create mode 100644 tools/lib/util/types.h
 create mode 100644 tools/lib/util/util.h
 delete mode 100644 tools/perf/util/cache.h
 delete mode 100644 tools/perf/util/debugfs.c
 delete mode 100644 tools/perf/util/debugfs.h
 delete mode 100644 tools/perf/util/strbuf.c
 delete mode 100644 tools/perf/util/strbuf.h
 delete mode 100644 tools/perf/util/types.h
 delete mode 100644 tools/perf/util/util.h
tools/Makefile new file +74 -0
new file mode 100644
index 0000000..34642e6
@@ -0,0 +1,74 @@
+# CFLAGS and LDFLAGS are for the users to override from the command line.
+
+#
+# Include saner warnings here, which can catch bugs:
+#
+
+EXTRA_WARNINGS := -Wformat
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
+
+export EXTRA_WARNINGS
+
+ifeq ("$(origin DEBUG)", "command line")
+  PERF_DEBUG = $(DEBUG)
+endif
+ifndef PERF_DEBUG
+  CFLAGS_OPTIMIZE = -O6
+endif
+
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+	QUIET_CC       = @echo '   ' CC $@;
+	QUIET_AR       = @echo '   ' AR $@;
+	QUIET_LINK     = @echo '   ' LINK $@;
+	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
+	QUIET_GEN      = @echo '   ' GEN $@;
+	QUIET_SUBDIR0  = +@subdir=
+	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
+			 $(MAKE) $(PRINT_DIR) -C $$subdir
+	export V
+	export QUIET_CC
+	export QUIET_GEN
+	export QUIET_BUILT_IN
+endif
+endif
+
+#
+# lib includes for submake
+BASIC_CFLAGS = -I$(CURDIR)/lib
+
+export BASIC_CFLAGS
+
+rasd: lib
+
+perf: lib .FORCE
+	$(MAKE) -C perf/
+
+lib: .FORCE
+	$(MAKE) -C lib/
+
+clean:
+	$(MAKE) -C lib/ clean
+	$(MAKE) -C perf/ clean
+
+.PHONY: clean .FORCE
tools/lib/Makefile new file +41 -0

41 lines not on this page · raw message

tools/lib/util/cache.h new file +86 -0

86 lines not on this page · raw message

tools/lib/util/debugfs.c new file +252 -0

252 lines not on this page · raw message

tools/lib/util/debugfs.h new file +31 -0
new file mode 100644
index 0000000..dce74b0
@@ -0,0 +1,31 @@
+#ifndef __DEBUGFS_H__
+#define __DEBUGFS_H__
+
+#include <sys/mount.h>
+#include <sys/param.h>
+
+#ifndef MAX_PATH
+# define MAX_PATH 256
+#endif
+
+#ifndef STR
+# define _STR(x) #x
+# define STR(x) _STR(x)
+#endif
+
+extern char debugfs_path[MAXPATHLEN];
+extern char debugfs_mntpt[MAXPATHLEN];
+
+
+extern const char *debugfs_find_mountpoint(void);
+extern int debugfs_valid_mountpoint(const char *debugfs);
+extern int debugfs_valid_entry(const char *path);
+extern char *debugfs_mount(const char *mountpoint);
+extern int debugfs_umount(void);
+extern int debugfs_write(const char *entry, const char *value);
+extern int debugfs_read(const char *entry, char *buffer, size_t size);
+extern void debugfs_force_cleanup(void);
+extern int debugfs_make_path(const char *element, char *buffer, int size);
+extern void set_debugfs_path(void);
+
+#endif /* __DEBUGFS_H__ */
tools/lib/util/strbuf.c new file +133 -0

133 lines not on this page · raw message

tools/lib/util/strbuf.h new file +92 -0

92 lines not on this page · raw message

tools/lib/util/types.h new file +17 -0
new file mode 100644
index 0000000..7d6b833
@@ -0,0 +1,17 @@
+#ifndef __PERF_TYPES_H
+#define __PERF_TYPES_H
+
+/*
+ * We define u64 as unsigned long long for every architecture
+ * so that we can print it with %Lx without getting warnings.
+ */
+typedef unsigned long long u64;
+typedef signed long long   s64;
+typedef unsigned int	   u32;
+typedef signed int	   s32;
+typedef unsigned short	   u16;
+typedef signed short	   s16;
+typedef unsigned char	   u8;
+typedef signed char	   s8;
+
+#endif /* __PERF_TYPES_H */
tools/lib/util/util.h new file +282 -0

282 lines not on this page · raw message

tools/perf/Makefile +4 -60

118 lines not on this page · raw message

tools/perf/bench/bench.h +2 -0
index f7781c6..0c7ee07 100644
@@ -1,6 +1,8 @@
 #ifndef BENCH_H
 #define BENCH_H
 
+#include <linux/compiler.h>
+
 extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
 extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
 extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
tools/perf/bench/mem-memcpy.c +1 -1
index 38dae74..e0fec0d 100644
@@ -8,7 +8,7 @@
 #include <ctype.h>
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <util/util.h>
 #include "../util/parse-options.h"
 #include "../util/header.h"
 #include "bench.h"
tools/perf/bench/sched-messaging.c +1 -1
index d1d1b30..fac36b5 100644
@@ -10,7 +10,7 @@
  */
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <util/util.h>
 #include "../util/parse-options.h"
 #include "../builtin.h"
 #include "bench.h"
tools/perf/bench/sched-pipe.c +1 -1
index d9ab3ce..e7bb3d9 100644
@@ -11,7 +11,7 @@
  */
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <util/util.h>
 #include "../util/parse-options.h"
 #include "../builtin.h"
 #include "bench.h"
tools/perf/builtin-bench.c +1 -1
index fcb9626..a083106 100644
@@ -17,7 +17,7 @@
  */
 
 #include "perf.h"
-#include "util/util.h"
+#include <util/util.h>
 #include "util/parse-options.h"
 #include "builtin.h"
 #include "bench/bench.h"
tools/perf/builtin.h +2 -2
index 921245b..0b65de4 100644
@@ -1,8 +1,8 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
-#include "util/util.h"
-#include "util/strbuf.h"
+#include <util/util.h>
+#include <util/strbuf.h>
 
 extern const char perf_version_string[];
 extern const char perf_usage_string[];
tools/perf/perf.c +2 -13
index 6e48711..ee5c28d 100644
@@ -9,11 +9,11 @@
 #include "builtin.h"
 
 #include "util/exec_cmd.h"
-#include "util/cache.h"
+#include <util/cache.h>
 #include "util/quote.h"
 #include "util/run-command.h"
 #include "util/parse-events.h"
-#include "util/debugfs.h"
+#include <util/debugfs.h>
 
 const char perf_usage_string[] =
 	"perf [--version] [--help] COMMAND [ARGS]";
@@ -29,8 +29,6 @@ struct pager_config {
 	int val;
 };
 
-static char debugfs_mntpt[MAXPATHLEN];
-
 static int pager_command_config(const char *var, const char *value, void *data)
 {
 	struct pager_config *c = data;
@@ -81,15 +79,6 @@ static void commit_pager_choice(void)
 	}
 }
 
-static void set_debugfs_path(void)
-{
-	char *path;
-
-	path = getenv(PERF_DEBUGFS_ENVIRONMENT);
-	snprintf(debugfs_path, MAXPATHLEN, "%s/%s", path ?: debugfs_mntpt,
-		 "tracing/events");
-}
-
 static int handle_options(const char ***argv, int *argc, int *envchanged)
 {
 	int handled = 0;
tools/perf/perf.h +2 -0
index ef7aa0a..e235f6a 100644
@@ -1,6 +1,8 @@
 #ifndef _PERF_PERF_H
 #define _PERF_PERF_H
 
+#include <linux/compiler.h>
+
 struct winsize;
 
 void get_term_dimensions(struct winsize *ws);
tools/perf/util/abspath.c +1 -1
index 0e76aff..659125d 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 
 static const char *get_pwd_cwd(void)
 {
tools/perf/util/alias.c +2 -1
index b8144e8..1d13065 100644
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include <linux/compiler.h>
+#include <util/cache.h>
 
 static const char *alias_key;
 static char *alias_val;
tools/perf/util/build-id.c +1 -1
index 70c5cf8..d25de52 100644
@@ -6,7 +6,7 @@
  * Copyright (C) 2009, 2010 Red Hat Inc.
  * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <[email protected]>
  */
-#include "util.h"
+#include <util/util.h>
 #include <stdio.h>
 #include "build-id.h"
 #include "event.h"
tools/perf/util/cache.h deleted +0 -86

86 lines not on this page · raw message

tools/perf/util/callchain.c +1 -1
index 62b69ad..73f8cf0 100644
@@ -15,7 +15,7 @@
 #include <errno.h>
 #include <math.h>
 
-#include "util.h"
+#include <util/util.h>
 #include "callchain.h"
 
 bool ip_callchain__valid(struct ip_callchain *chain, event_t *event)
tools/perf/util/color.c +1 -1
index e191eb9..0e8edc4 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "color.h"
 
 int perf_use_color_default = -1;
tools/perf/util/color.h +2 -0
index dea082b..9ffab44 100644
@@ -1,6 +1,8 @@
 #ifndef __PERF_COLOR_H
 #define __PERF_COLOR_H
 
+#include <stddef.h>
+
 /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
 #define COLOR_MAXLEN 24
 
tools/perf/util/config.c +3 -2
index dabe892..d199791 100644
@@ -5,8 +5,9 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
-#include "util.h"
-#include "cache.h"
+#include <util/util.h>
+#include <util/cache.h>
+#include <linux/compiler.h>
 #include "exec_cmd.h"
 
 #define MAXNAME (256)
tools/perf/util/cpumap.c +1 -1
index 4e01490..47335ce 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <util/util.h>
 #include "../perf.h"
 #include "cpumap.h"
 #include <assert.h>
tools/perf/util/ctype.c +1 -1
index 3507362..ec47e62 100644
@@ -3,7 +3,7 @@
  *
  * No surprises, and works with signed and unsigned chars.
  */
-#include "cache.h"
+#include <util/cache.h>
 
 enum {
 	S = GIT_SPACE,
tools/perf/util/debug.c +2 -2
index dd824cf..b53e41c 100644
@@ -6,11 +6,11 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "cache.h"
+#include <util/cache.h>
 #include "color.h"
 #include "event.h"
 #include "debug.h"
-#include "util.h"
+#include <util/util.h>
 
 int verbose = 0;
 bool dump_trace = false;
tools/perf/util/debugfs.c deleted +0 -240

240 lines not on this page · raw message

tools/perf/util/debugfs.h deleted +0 -25
deleted file mode 100644
index 83a0287..0000000
@@ -1,25 +0,0 @@
-#ifndef __DEBUGFS_H__
-#define __DEBUGFS_H__
-
-#include <sys/mount.h>
-
-#ifndef MAX_PATH
-# define MAX_PATH 256
-#endif
-
-#ifndef STR
-# define _STR(x) #x
-# define STR(x) _STR(x)
-#endif
-
-extern const char *debugfs_find_mountpoint(void);
-extern int debugfs_valid_mountpoint(const char *debugfs);
-extern int debugfs_valid_entry(const char *path);
-extern char *debugfs_mount(const char *mountpoint);
-extern int debugfs_umount(void);
-extern int debugfs_write(const char *entry, const char *value);
-extern int debugfs_read(const char *entry, char *buffer, size_t size);
-extern void debugfs_force_cleanup(void);
-extern int debugfs_make_path(const char *element, char *buffer, int size);
-
-#endif /* __DEBUGFS_H__ */
tools/perf/util/environment.c +1 -1
index 275b0ee..3acdc7b 100644
@@ -3,7 +3,7 @@
  * file, so that programs can link against the config parser
  * without having to link against all the rest of perf.
  */
-#include "cache.h"
+#include <util/cache.h>
 
 const char *pager_program;
 int pager_use_color = 1;
tools/perf/util/exec_cmd.c +1 -1
index 67eeff5..10f062c 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "exec_cmd.h"
 #include "quote.h"
 
tools/perf/util/header.c +1 -1
index 1f62435..cd4a00f 100644
@@ -8,7 +8,7 @@
 #include <linux/list.h>
 #include <linux/kernel.h>
 
-#include "util.h"
+#include <util/util.h>
 #include "header.h"
 #include "../perf.h"
 #include "trace-event.h"
tools/perf/util/header.h +1 -1
index 402ac24..60325e2 100644
@@ -4,7 +4,7 @@
 #include "../../../include/linux/perf_event.h"
 #include <sys/types.h>
 #include <stdbool.h>
-#include "types.h"
+#include <util/types.h>
 #include "event.h"
 
 #include <linux/bitmap.h>
tools/perf/util/help.c +3 -1
index 6f2975a..cbe1c1c 100644
@@ -1,8 +1,10 @@
-#include "cache.h"
+#include <util/cache.h>
+#include <linux/compiler.h>
 #include "../builtin.h"
 #include "exec_cmd.h"
 #include "levenshtein.h"
 #include "help.h"
+#include "../perf.h"
 
 void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
 {
tools/perf/util/hist.c +1 -1
index cbf7eae..4352f43 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <util/util.h>
 #include "build-id.h"
 #include "hist.h"
 #include "session.h"
tools/perf/util/levenshtein.c +1 -1
index e521d15..68383fb 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "levenshtein.h"
 
 /*
tools/perf/util/map.h +1 -1
index f391345..3082109 100644
@@ -6,7 +6,7 @@
 #include <linux/rbtree.h>
 #include <stdio.h>
 #include <stdbool.h>
-#include "types.h"
+#include <util/types.h>
 
 enum map_type {
 	MAP__FUNCTION = 0,
tools/perf/util/newt.c +1 -1
index d54c540..e3cbe3b 100644
@@ -15,7 +15,7 @@
 #include <newt.h>
 #include <sys/ttydefaults.h>
 
-#include "cache.h"
+#include <util/cache.h>
 #include "hist.h"
 #include "pstack.h"
 #include "session.h"
tools/perf/util/pager.c +1 -1
index 1915de2..2eab6a4 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "run-command.h"
 #include "sigchain.h"
 
tools/perf/util/parse-events.c +4 -4
index 9bf0f40..3a22fa5 100644
@@ -1,14 +1,14 @@
 #include "../../../include/linux/hw_breakpoint.h"
-#include "util.h"
+#include <util/util.h>
 #include "../perf.h"
 #include "parse-options.h"
 #include "parse-events.h"
 #include "exec_cmd.h"
 #include "string.h"
 #include "symbol.h"
-#include "cache.h"
+#include <util/cache.h>
 #include "header.h"
-#include "debugfs.h"
+#include <util/debugfs.h>
 
 int				nr_counters;
 
@@ -28,7 +28,7 @@ enum event_result {
 	EVT_HANDLED_ALL
 };
 
-char debugfs_path[MAXPATHLEN];
+//char debugfs_path[MAXPATHLEN];
 
 #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
 #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
tools/perf/util/parse-events.h +3 -1
index fc4ab3f..473c475 100644
@@ -1,5 +1,8 @@
 #ifndef __PERF_PARSE_EVENTS_H
 #define __PERF_PARSE_EVENTS_H
+
+#include "header.h"
+
 /*
  * Parse symbolic events/counts passed in as options:
  */
@@ -30,7 +33,6 @@ extern int parse_filter(const struct option *opt, const char *str, int unset);
 
 extern void print_events(void);
 
-extern char debugfs_path[];
 extern int valid_debugfs_mount(const char *debugfs);
 
 
tools/perf/util/parse-options.c +3 -2
index 99d02aa..66e6af0 100644
@@ -1,6 +1,7 @@
-#include "util.h"
+#include <util/util.h>
+#include <util/cache.h>
+#include <linux/compiler.h>
 #include "parse-options.h"
-#include "cache.h"
 
 #define OPT_SHORT 1
 #define OPT_UNSET 2
tools/perf/util/path.c +1 -1
index 58a470d..e452676 100644
@@ -10,7 +10,7 @@
  *
  * which is what it's designed for.
  */
-#include "cache.h"
+#include <util/cache.h>
 
 static char bad_path[] = "/bad-path/";
 /*
tools/perf/util/probe-event.c +3 -3
index 914c670..9618d2a 100644
@@ -33,16 +33,16 @@
 #include <limits.h>
 
 #undef _GNU_SOURCE
-#include "util.h"
+#include <util/util.h>
 #include "event.h"
 #include "string.h"
 #include "strlist.h"
 #include "debug.h"
-#include "cache.h"
+#include <util/cache.h>
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include "debugfs.h"
+#include <util/debugfs.h>
 #include "trace-event.h"	/* For __unused */
 #include "probe-event.h"
 #include "probe-finder.h"
tools/perf/util/probe-finder.c +1 -1
index d964cb1..6b1e981 100644
@@ -36,7 +36,7 @@
 #include "string.h"
 #include "event.h"
 #include "debug.h"
-#include "util.h"
+#include <util/util.h>
 #include "probe-finder.h"
 
 /* Kprobe tracer basic type is up to u64 */
tools/perf/util/probe-finder.h +1 -1
index e1f61dc..df19a72 100644
@@ -2,7 +2,7 @@
 #define _PROBE_FINDER_H
 
 #include <stdbool.h>
-#include "util.h"
+#include <util/util.h>
 #include "probe-event.h"
 
 #define MAX_PATH_LEN		 256
tools/perf/util/pstack.c +1 -1
index 13d36fa..b735ebf 100644
@@ -4,7 +4,7 @@
  * (c) 2010 Arnaldo Carvalho de Melo <[email protected]>
  */
 
-#include "util.h"
+#include <util/util.h>
 #include "pstack.h"
 #include <linux/kernel.h>
 #include <stdlib.h>
tools/perf/util/quote.c +1 -1
index 01f0324..51df6c3 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "quote.h"
 
 /* Help to copy the thing properly quoted for the shell safety.
tools/perf/util/run-command.c +1 -1
index da8e9b2..a139174 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include <util/cache.h>
 #include "run-command.h"
 #include "exec_cmd.h"
 
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
index b059dc5..d91b9e4 100644
@@ -26,7 +26,7 @@
 #include <errno.h>
 
 #include "../../perf.h"
-#include "../util.h"
+#include <util/util.h>
 #include "../trace-event.h"
 
 #include <EXTERN.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index 81f39ca..78b2749 100644
@@ -28,7 +28,7 @@
 #include <errno.h>
 
 #include "../../perf.h"
-#include "../util.h"
+#include <util/util.h>
 #include "../trace-event.h"
 
 PyMODINIT_FUNC initperf_trace_context(void);
tools/perf/util/session.c +1 -1
index 8f83a18..e21f759 100644
@@ -9,7 +9,7 @@
 
 #include "session.h"
 #include "sort.h"
-#include "util.h"
+#include <util/util.h>
 
 static int perf_session__open(struct perf_session *self, bool force)
 {
tools/perf/util/sigchain.c +1 -1
index ba785e9..10ca4fb 100644
@@ -1,5 +1,5 @@
 #include "sigchain.h"
-#include "cache.h"
+#include <util/cache.h>
 
 #define SIGCHAIN_MAX_SIGNALS 32
 
tools/perf/util/sort.h +2 -2
index 0d61c40..41b2fc3 100644
@@ -2,11 +2,11 @@
 #define __PERF_SORT_H
 #include "../builtin.h"
 
-#include "util.h"
+#include <util/util.h>
 
 #include "color.h"
 #include <linux/list.h>
-#include "cache.h"
+#include <util/cache.h>
 #include <linux/rbtree.h>
 #include "symbol.h"
 #include "string.h"
tools/perf/util/strbuf.c deleted +0 -133

133 lines not on this page · raw message

tools/perf/util/strbuf.h deleted +0 -92

92 lines not on this page · raw message

tools/perf/util/string.c +1 -1
index 0409fc7..b5edba7 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <util/util.h>
 #include "string.h"
 
 #define K 1024LL
tools/perf/util/svghelper.h +1 -1
index e078198..278a72d 100644
@@ -1,7 +1,7 @@
 #ifndef __PERF_SVGHELPER_H
 #define __PERF_SVGHELPER_H
 
-#include "types.h"
+#include <util/types.h>
 
 extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
 extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
tools/perf/util/thread.c +1 -1
index 1f7ecd4..ce885bc 100644
@@ -4,7 +4,7 @@
 #include <string.h>
 #include "session.h"
 #include "thread.h"
-#include "util.h"
+#include <util/util.h>
 #include "debug.h"
 
 int find_all_tid(int pid, pid_t ** all_tid)
tools/perf/util/trace-event-info.c +1 -1
index b157260..6bdf4a1 100644
@@ -38,7 +38,7 @@
 
 #include "../perf.h"
 #include "trace-event.h"
-#include "debugfs.h"
+#include <util/debugfs.h>
 
 #define VERSION "0.5"
 
tools/perf/util/trace-event-parse.c +1 -1
index 73a0222..dcecf73 100644
@@ -30,7 +30,7 @@
 
 #undef _GNU_SOURCE
 #include "../perf.h"
-#include "util.h"
+#include <util/util.h>
 #include "trace-event.h"
 
 int header_page_ts_offset;
tools/perf/util/trace-event-read.c +1 -1
index f55cc3a..c5c62b1 100644
@@ -37,7 +37,7 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
+#include <util/util.h>
 #include "trace-event.h"
 
 static int input_fd;
tools/perf/util/trace-event-scripting.c +1 -1
index 7ea983a..d5eaffa 100644
@@ -26,7 +26,7 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
+#include <util/util.h>
 #include "trace-event.h"
 
 struct scripting_context *scripting_context;
tools/perf/util/types.h deleted +0 -17
deleted file mode 100644
index 7d6b833..0000000
@@ -1,17 +0,0 @@
-#ifndef __PERF_TYPES_H
-#define __PERF_TYPES_H
-
-/*
- * We define u64 as unsigned long long for every architecture
- * so that we can print it with %Lx without getting warnings.
- */
-typedef unsigned long long u64;
-typedef signed long long   s64;
-typedef unsigned int	   u32;
-typedef signed int	   s32;
-typedef unsigned short	   u16;
-typedef signed short	   s16;
-typedef unsigned char	   u8;
-typedef signed char	   s8;
-
-#endif /* __PERF_TYPES_H */
tools/perf/util/usage.c +1 -1
index e16bf9a..7085b6f 100644
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#include "util.h"
+#include <util/util.h>
 
 static void report(const char *prefix, const char *err, va_list params)
 {
tools/perf/util/util.c +1 -1
index 2142656..8714309 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <util/util.h>
 #include <sys/mman.h>
 
 int mkdir_p(char *path, mode_t mode)
tools/perf/util/util.h deleted +0 -282

282 lines not on this page · raw message

tools/perf/util/values.c +1 -1
index cfa55d6..e25c4b4 100644
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 
-#include "util.h"
+#include <util/util.h>
 #include "values.h"
 
 void perf_read_values_init(struct perf_read_values *values)
tools/perf/util/values.h +1 -1
index 2fa967e..012bc12 100644
@@ -1,7 +1,7 @@
 #ifndef __PERF_VALUES_H
 #define __PERF_VALUES_H
 
-#include "types.h"
+#include <util/types.h>
 
 struct perf_read_values {
 	int threads;
tools/perf/util/wrapper.c +2 -1
index 73e900e..3addc76 100644
@@ -1,7 +1,8 @@
 /*
  * Various trivial helper wrappers around standard functions
  */
-#include "cache.h"
+#include <linux/compiler.h>
+#include <util/cache.h>
 
 /*
  * There's no pack memory to release - but stay close to the Git
Signature · 9 lines
1.6.4.4


-- 
Regards/Gruss,
Boris.

Operating Systems Research Center
Advanced Micro Devices, Inc.
#18 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Em Mon, Jun 14, 2010 at 09:25:14PM +0200, Borislav Petkov escreveu:

Quoted 20 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, Jun 03, 2010 at 02:32:42PM -0300

Quoted 10 lines

Right, that has to be done, I have sample code I want to put in samples/ to show how to use the symbol libraries in tools/perf/util/, will take a stab at moving things for tools/lib/.

We'll need a top level Makefile, I guess, so that when asking to build tools/perf, it notices that it has to build tools/lib/, etc.

Probably we'll need tools/lib/symbols/, tools/lib/trace/parser/ things like that, I'll start with the symbols part, using a samples/ file I already wrote.

Right, so I started playing with this, added a global Makefile to tools/ and from there we descend into lib/ and perf/ in that order to prepare all the modules for the perflib. I've played with the include paths so that you can have #include <util/util.h> for all that generic library stuff.

Quoted 4 lines

The patch below carves out the debugfs helpers along with some generic headers, please take a look and let me know if this is an agreeable direction I'm going. Yeah, it is big, I think vger won't be able to swallow it but this is only moving files around so...

One thing I thought was that perhaps reusing Kbuild would be a good idea, something like:

cd tools/
make menuconfig

And use all the Kbuild machinery to select needed features, etc.

What do you think?

It can be a follow up to what you're doing, that is needed anyway, some questions below:

Quoted 8 lines

Thanks.

--

Quoted 1 line

From 0f391f0acf39d3b2e85145dce389cbf425cb7cdd Mon Sep 17 00:00:00 2001

From: Borislav Petkov <[email protected]>
Date: Mon, 14 Jun 2010 21:14:15 +0200
Subject: [PATCH] perf: rewire generic library stuff

Quoted 10 lines
---
 tools/Makefile                                     |   74 +++++
 tools/lib/Makefile                                 |   41 +++
 tools/lib/util/cache.h                             |   86 ++++++
 tools/lib/util/debugfs.c                           |  252 +++++++++++++++++
 tools/lib/util/debugfs.h                           |   31 +++
 tools/lib/util/strbuf.c                            |  133 +++++++++
 tools/lib/util/strbuf.h                            |   92 +++++++
 tools/lib/util/types.h                             |   17 ++
 tools/lib/util/util.h                              |  282 ++++++++++++++++++++

Will we continue using "util" here? What other name could we pick? Nah, probably for the ones you moved we can continue using it, the symbols part I plan to move to tools/lib/symbol/.

Review

Quoted 10 lines
 tools/perf/Makefile                                |   64 +----
 tools/perf/bench/bench.h                           |    2 +
 tools/perf/bench/mem-memcpy.c                      |    2 +-
 tools/perf/bench/sched-messaging.c                 |    2 +-
 tools/perf/bench/sched-pipe.c                      |    2 +-
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
(quoted diff) +1 -1
-#include "types.h"
+#include <util/types.h>

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

So I'll do some testing here and merge this for .36 unless somebody has other issues with this, Ingo? Frédéric?

- Arnaldo

author maintainer
#19 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 06:01:16PM -0300

Quoted 14 lines
Quoted 10 lines

Right, so I started playing with this, added a global Makefile to tools/ and from there we descend into lib/ and perf/ in that order to prepare all the modules for the perflib. I've played with the include paths so that you can have #include <util/util.h> for all that generic library stuff.

The patch below carves out the debugfs helpers along with some generic headers, please take a look and let me know if this is an agreeable direction I'm going. Yeah, it is big, I think vger won't be able to swallow it but this is only moving files around so...

One thing I thought was that perhaps reusing Kbuild would be a good idea, something like:

Quoted 6 lines

cd tools/
make menuconfig

And use all the Kbuild machinery to select needed features, etc.

What do you think?

Why not, however, do we need it at this point? I mean, you simply do

make -j; make install

in tools/perf/ and all is good. It even tells you if some libraries are missing. I simply don't see such a large amount of options to justify a configurator but maybe there are usecases where Kconfig would make sense, hmmm?

Quoted 22 lines

It can be a follow up to what you're doing, that is needed anyway, some questions below:

Quoted 8 lines

Thanks.

--

Quoted 1 line

From 0f391f0acf39d3b2e85145dce389cbf425cb7cdd Mon Sep 17 00:00:00 2001

From: Borislav Petkov <[email protected]>
Date: Mon, 14 Jun 2010 21:14:15 +0200
Subject: [PATCH] perf: rewire generic library stuff

Quoted 10 lines
---
 tools/Makefile                                     |   74 +++++
 tools/lib/Makefile                                 |   41 +++
 tools/lib/util/cache.h                             |   86 ++++++
 tools/lib/util/debugfs.c                           |  252 +++++++++++++++++
 tools/lib/util/debugfs.h                           |   31 +++
 tools/lib/util/strbuf.c                            |  133 +++++++++
 tools/lib/util/strbuf.h                            |   92 +++++++
 tools/lib/util/types.h                             |   17 ++
 tools/lib/util/util.h                              |  282 ++++++++++++++++++++
Quoted 3 lines

Will we continue using "util" here? What other name could we pick? Nah, probably for the ones you moved we can continue using it, the symbols part I plan to move to tools/lib/symbol/.

Yeah, names are kinda arbitrary. Keeping "util" meant as little changes as possible but it would make more sense to simply have all different library modules under "tools/lib/<module>.(c|h)" Will do so in the next version.

Quoted 8 lines
Quoted 7 lines
 tools/perf/Makefile                                |   64 +----
 tools/perf/bench/bench.h                           |    2 +
 tools/perf/bench/mem-memcpy.c                      |    2 +-
 tools/perf/bench/sched-messaging.c                 |    2 +-
 tools/perf/bench/sched-pipe.c                      |    2 +-
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-#include "types.h"
+#include <util/types.h>

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

Yeah, I have the -I$(CURDIR)/lib for this in the top level Makefile so all library includes would be like:

#include <util.h>

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Quoted 2 lines

So I'll do some testing here and merge this for .36 unless somebody has other issues with this, Ingo? Frédéric?

Can you please wait a bit with the merging, I'd like to write the whole rasd daemon stuff before we merge that and have the generic lib carve-out in one patchset?

Thanks.

Signature · 2 lines
Regards/Gruss,
    Boris.
#20 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Em Mon, Jun 14, 2010 at 11:24:26PM +0200, Borislav Petkov escreveu:

Quoted 11 lines

From: Arnaldo Carvalho de Melo <[email protected]>

Quoted 9 lines

One thing I thought was that perhaps reusing Kbuild would be a good idea, something like:

cd tools/
make menuconfig

And use all the Kbuild machinery to select needed features, etc.

What do you think?

Quoted 8 lines

Why not, however, do we need it at this point? I mean, you simply do

make -j; make install

in tools/perf/ and all is good. It even tells you if some libraries are missing. I simply don't see such a large amount of options to justify a configurator but maybe there are usecases where Kconfig would make sense, hmmm?

Yeah, I mean longer term, as we get libraries separated, more benchmarks, tools, etc.

Quoted 5 lines
Quoted 5 lines

It can be a follow up to what you're doing, that is needed anyway, some questions below:

Quoted 1 line
 tools/lib/util/util.h                              |  282 ++++++++++++++++++++
Quoted 7 lines
Quoted 3 lines

Will we continue using "util" here? What other name could we pick? Nah, probably for the ones you moved we can continue using it, the symbols part I plan to move to tools/lib/symbol/.

Yeah, names are kinda arbitrary. Keeping "util" meant as little changes as possible but it would make more sense to simply have all different library modules under "tools/lib/<module>.(c|h)" Will do so in the next version.

Ok

Quoted 12 lines
Quoted 8 lines

Review

Quoted 5 lines
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
(quoted diff) +1 -1
-#include "types.h"
+#include <util/types.h>

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

Yeah, I have the -I$(CURDIR)/lib for this in the top level Makefile so all library includes would be like:

Quoted 6 lines

#include <util.h>

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Agreed, but the last name this thing will have will be 'perf'something :-)

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

Quoted 6 lines
Quoted 2 lines

So I'll do some testing here and merge this for .36 unless somebody has other issues with this, Ingo? Frédéric?

Can you please wait a bit with the merging, I'd like to write the whole rasd daemon stuff before we merge that and have the generic lib carve-out in one patchset?

Ok with me, I'll see if I manage to do the symbols part tho, as it is kinda self contained and I already toyed with writing a test program that uses the subset of tools/perf/util/ that deals with symbols.

Part of that experiment is in tools/perf/builtin-test.c, parts are exemplified by this Makefile:

[acme@doppio linux-2.6-tip]$ cat tools/perf/util/examples/symbol/Makefile ppio linux-2.6-tip]$ l tools/perf/util/examples/symbol/Makefile -rw-rw-r-- 1 acme acme 693 2010-03-27 11:14 tools/perf/util/examples/symbol/Makefile CFLAGS = -Wall -I../../include -I../.. -std=gnu99 -DNO_DEMANGLE -g LDFLAGS = -lelf

ifeq ("$(origin O)", "command line")

	OUTPUT := $(O)/

endif

LIBSYM_OBJS = $(OUTPUT)map.o $(OUTPUT)rbtree.o $(OUTPUT)symbol.o $(OUTPUT)strlist.o $(OUTPUT)eprintf.o

all: $(OUTPUT)dsym $(OUTPUT)ksym

$(OUTPUT)dsym: $(OUTPUT)dsym.o $(LIBSYM_OBJS)

	gcc -o $@ $(LDFLAGS) [email protected] $(LIBSYM_OBJS)

$(OUTPUT)ksym: $(OUTPUT)ksym.o $(LIBSYM_OBJS)

	gcc -o $@ $(LDFLAGS) [email protected] $(LIBSYM_OBJS)

$(OUTPUT)rbtree.o: ../../../../../lib/rbtree.c

	gcc -o $@ -c $(CFLAGS) $<

$(OUTPUT)%.o: ../../%.c

	gcc -o $@ -c $(CFLAGS) $<

$(OUTPUT)%.o: %.c

	gcc -o $@ -c $(CFLAGS) $<

clean:

	rm -f $(LIBSYM_OBJS) $(OUTPUT)?sym.o $(OUTPUT)?sym

[acme@doppio linux-2.6-tip]$
[acme@doppio linux-2.6-tip]$ cd tools/perf/util/examples/symbol/ [acme@doppio symbol]$ l build/
total 104
drwxrwxr-x 2 acme acme 4096 2010-06-14 21:55 ./ drwxrwxr-x 3 acme acme 4096 2010-03-28 13:52 ../ -rwxrwxr-x 1 acme acme 47040 2010-06-14 21:55 dsym* -rwxrwxr-x 1 acme acme 47200 2010-06-14 21:55 ksym* [acme@doppio symbol]$ ldd build/dsym

	linux-vdso.so.1 =>  (0x00007fffe6cf2000)
	libelf.so.1 => /usr/lib64/libelf.so.1 (0x0000003404c00000)
	libc.so.6 => /lib64/libc.so.6 (0x0000003715a00000)
	/lib64/ld-linux-x86-64.so.2 (0x0000003715600000)

[acme@doppio symbol]$
[acme@doppio symbol]$ build/dsym
usage: dso DSO_NAME SYMBOL_NAME|0xADDR
[acme@doppio symbol]$ build/dsym /lib/libc-2.10.2.so malloc
malloc: 0x749c0-0x74bee
[acme@doppio symbol]$ build/dsym /lib/libc-2.10.2.so 0x749ee __GI___libc_malloc: 0x749c0-0x74bee
[acme@doppio symbol]$ build/dsym /lib/libc-2.10.2.so __GI___libc_malloc __GI___libc_malloc: 0x749c0-0x74bee

:-)

- Arnaldo

#21 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 09:02:01PM -0400

Quoted 16 lines

Em Mon, Jun 14, 2010 at 11:24:26PM +0200, Borislav Petkov escreveu:

Quoted 15 lines

From: Arnaldo Carvalho de Melo <[email protected]>

Quoted 9 lines

One thing I thought was that perhaps reusing Kbuild would be a good idea, something like:

cd tools/
make menuconfig

And use all the Kbuild machinery to select needed features, etc.

What do you think?

Why not, however, do we need it at this point? I mean, you simply do

make -j; make install

Quoted 7 lines
Quoted 4 lines

in tools/perf/ and all is good. It even tells you if some libraries are missing. I simply don't see such a large amount of options to justify a configurator but maybe there are usecases where Kconfig would make sense, hmmm?

Yeah, I mean longer term, as we get libraries separated, more benchmarks, tools, etc.

Sure, this is generally a good idea.

Quoted 35 lines
Quoted 6 lines
Quoted 6 lines

It can be a follow up to what you're doing, that is needed anyway, some questions below:

Quoted 1 line
 tools/lib/util/util.h                              |  282 ++++++++++++++++++++
Quoted 7 lines
Quoted 3 lines

Will we continue using "util" here? What other name could we pick? Nah, probably for the ones you moved we can continue using it, the symbols part I plan to move to tools/lib/symbol/.

Yeah, names are kinda arbitrary. Keeping "util" meant as little changes as possible but it would make more sense to simply have all different library modules under "tools/lib/<module>.(c|h)" Will do so in the next version.

Ok

Quoted 12 lines
Quoted 8 lines

Review

Quoted 5 lines
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
(quoted diff) +1 -1
-#include "types.h"
+#include <util/types.h>

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

Yeah, I have the -I$(CURDIR)/lib for this in the top level Makefile so all library includes would be like:

Quoted 6 lines

#include <util.h>

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Quoted 5 lines

Agreed, but the last name this thing will have will be 'perf'something :-)

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

Ok, since I'm a big fan of unambiguous short names, let's call it "lk" for "linux kernel" and have this namespace for all generic headers. So when you include those, you have something like

#include <lk/util.h>

How does that sound?

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

So I'll do some testing here and merge this for .36 unless somebody has other issues with this, Ingo? Frédéric?

Can you please wait a bit with the merging, I'd like to write the whole rasd daemon stuff before we merge that and have the generic lib carve-out in one patchset?

Ok with me, I'll see if I manage to do the symbols part tho, as it is kinda self contained and I already toyed with writing a test program that uses the subset of tools/perf/util/ that deals with symbols.

Neat, let's sync when I got my stuff ready so that we merge it together and fixup any paths fallout that might happen.

Thanks.

Signature · 5 lines
Regards/Gruss,
Boris.

Operating Systems Research Center
Advanced Micro Devices, Inc.
#22 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Em Tue, Jun 15, 2010 at 12:22:59PM +0200, Borislav Petkov escreveu:

Quoted 41 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 09:02:01PM -0400

Quoted 32 lines

Em Mon, Jun 14, 2010 at 11:24:26PM +0200, Borislav Petkov escreveu:

Quoted 9 lines

From: Arnaldo Carvalho de Melo <[email protected]>

Quoted 4 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Will we continue using "util" here? What other name could we pick? Nah, probably for the ones you moved we can continue using it, the symbols part I plan to move to tools/lib/symbol/.

Em Mon, Jun 14, 2010 at 11:24:26PM +0200, Borislav Petkov escreveu:
Yeah, names are kinda arbitrary. Keeping "util" meant as little changes as possible but it would make more sense to simply have all different library modules under "tools/lib/<module>.(c|h)" Will do so in the next version.

Ok

Quoted 12 lines
Quoted 8 lines

Review

Quoted 5 lines
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin.h                               |    4 +-
(quoted diff) +1 -1
-#include "types.h"
+#include <util/types.h>

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

Yeah, I have the -I$(CURDIR)/lib for this in the top level Makefile so all library includes would be like:

Quoted 6 lines

#include <util.h>

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Quoted 5 lines

Agreed, but the last name this thing will have will be 'perf'something :-)

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

Quoted 7 lines

Ok, since I'm a big fan of unambiguous short names, let's call it "lk" for "linux kernel" and have this namespace for all generic headers. So when you include those, you have something like

#include <lk/util.h>

How does that sound?

As this code originated on the Linux kernel, should be OK and probably unused.

Peter, ideas?

- Arnaldo

#23 lore raw

Re: [PATCH 1/2] perf: Add persistent events

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 10:02:01PM -0300

Quoted 13 lines
Quoted 6 lines
Quoted 2 lines

I thought about suggesting using -I to reduce patch size, but then it is using "" :-\

Yeah, I have the -I$(CURDIR)/lib for this in the top level Makefile so all library includes would be like:

Quoted 6 lines

#include <util.h>

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Quoted 5 lines

Agreed, but the last name this thing will have will be 'perf'something :-)

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

I'm still splitting perf/util into a more or less generic lib. Now, I want to reuse as much code as possible and am parsing the "mce:mce_record" tracepoint using parse_events(). However, this means that I have to push the not-so-generic perf bits like util/parse-events.c into the lib. Which, in turn, pulls in util/trace-event* etc.

What is your preference, do we want to export all perf/util stuff for other tools to use or rather link other tools together with compilation modules from perf/util in case those other tools need them?

I'm leaning towards the first one and am thinking "maximize code reuse" but I'm not completely sure, there might be reasons against it...

Hmm...?

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht Muenchen, HRB Nr. 43632
#24 lore raw

Re: [PATCH 1/2] perf: Add persistent events

Em Thu, Jun 17, 2010 at 03:43:57PM +0200, Borislav Petkov escreveu:

Quoted 12 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 10:02:01PM -0300

Quoted 9 lines
Quoted 4 lines

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Agreed, but the last name this thing will have will be 'perf'something :-) One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

Quoted 6 lines

I'm still splitting perf/util into a more or less generic lib. Now, I want to reuse as much code as possible and am parsing the "mce:mce_record" tracepoint using parse_events(). However, this means that I have to push the not-so-generic perf bits like util/parse-events.c into the lib. Which, in turn, pulls in util/trace-event* etc.

I'm not that familiar with the trace bits in perf, but I'd say pick what is needed for your tool and stash it into files in a tools/lib/trace/ directory, in a way that can be used by both perf and your tools.

I.e. no need to move files as-is, you can reorganize things to make it useful for both perf and your tool.

Quoted 4 lines

What is your preference, do we want to export all perf/util stuff for other tools to use or rather link other tools together with compilation modules from perf/util in case those other tools need them?

If we do it on a as-needed basis, as I suggested, we go eroding the current perf hodgepodge of potentially generic stuff.

Quoted 2 lines

I'm leaning towards the first one and am thinking "maximize code reuse" but I'm not completely sure, there might be reasons against it...

- Arnaldo

#25 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, Jun 17, 2010 at 11:25:46AM -0300

Quoted 20 lines

Em Thu, Jun 17, 2010 at 03:43:57PM +0200, Borislav Petkov escreveu:

Quoted 12 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Mon, Jun 14, 2010 at 10:02:01PM -0300

Quoted 9 lines
Quoted 4 lines

however, this does not differentiate perflib (let's call it that for how :) from libc headers. Do we want a "perf" or "kernel" or "perflib" or whatever prefix here - it might make sense later when this thing grows to differentiate between the namespaces...?

Agreed, but the last name this thing will have will be 'perf'something :-) One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

Quoted 6 lines

I'm still splitting perf/util into a more or less generic lib. Now, I want to reuse as much code as possible and am parsing the "mce:mce_record" tracepoint using parse_events(). However, this means that I have to push the not-so-generic perf bits like util/parse-events.c into the lib. Which, in turn, pulls in util/trace-event* etc.

Quoted 6 lines

I'm not that familiar with the trace bits in perf, but I'd say pick what is needed for your tool and stash it into files in a tools/lib/trace/ directory, in a way that can be used by both perf and your tools.

I.e. no need to move files as-is, you can reorganize things to make it useful for both perf and your tool.

Right, this is the idea. However, all those header includes pull in other stuff. For example, if I want to use parse_events(), it pulls in parse-options.* which pulls in header.h, symbol.h etc.

What I ended up doing is have

tools/lib/perf/

	 /trace/
	 /include/
	 /lk/

for all the different types of facilities. So lk contains the generic perf/util/ stuff, include contains all the linux and asm headers like bitops.h, hash.h, kernel.h etc, perf contains parse-events.* because it deals with perf stuff and so on.

How's that?

Quoted 7 lines
Quoted 4 lines

What is your preference, do we want to export all perf/util stuff for other tools to use or rather link other tools together with compilation modules from perf/util in case those other tools need them?

If we do it on a as-needed basis, as I suggested, we go eroding the current perf hodgepodge of potentially generic stuff.

I think splitting it in kinda "subsystems" helps keep the modularity.

Opinions, comments?

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht Muenchen, HRB Nr. 43632
maintainer
#26 lore raw

Re: [PATCH 1/2] perf: Add persistent events

In reply to Borislav Petkov
Quoted 10 lines · Borislav Petkov
Quoted 3 lines

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

I'm still splitting perf/util into a more or less generic lib. Now, I want to reuse as much code as possible and am parsing the "mce:mce_record" tracepoint using parse_events(). However, this means that I have to push the not-so-generic perf bits like util/parse-events.c into the lib. Which, in turn, pulls in util/trace-event* etc.

Note, I have a separate generic library in trace-cmd that has the parsing of trace events as its own library now.

This is the code that started trace-event-parse.c.

It has evolved quite a bit since then. You can get the code from:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

The files are parse-events.c and parse-events.h. As well as some filtering code: parse-filter.c.

It creates a libparsevent library.

I've been meaning to update the perf stuff with it, but just have not had the time. Seems that what you are doing might be a good fit for it.

-- Steve

#27 lore raw

Re: [PATCH 1/2] perf: Add persistent events

From: Steven Rostedt <[email protected]>
Date: Thu, Jun 17, 2010 at 12:19:57PM -0400

Quoted 22 lines · Borislav Petkov
Quoted 11 lines
Quoted 4 lines

One of the goals at least I have with pursuing this path is to separate out everything that is not strictly 'perf' into things that can be reused by other tools, like yours.

I'm still splitting perf/util into a more or less generic lib. Now, I want to reuse as much code as possible and am parsing the "mce:mce_record" tracepoint using parse_events(). However, this means that I have to push the not-so-generic perf bits like util/parse-events.c into the lib. Which, in turn, pulls in util/trace-event* etc.

Note, I have a separate generic library in trace-cmd that has the parsing of trace events as its own library now.

This is the code that started trace-event-parse.c.

It has evolved quite a bit since then. You can get the code from:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

Quoted 7 lines

The files are parse-events.c and parse-events.h. As well as some filtering code: parse-filter.c.

It creates a libparsevent library.

I've been meaning to update the perf stuff with it, but just have not had the time. Seems that what you are doing might be a good fit for it.

I see, well, I could take it and merge it into tools/trace-cmd or something and then we all could gradually weed out common code. But I'm open to other suggestions as well.

I mean, it is only natural if we merry perf and ftrace in kernel space to do the same in userspace, right :)

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht Muenchen, HRB Nr. 43632
maintainer
#28 lore raw
In reply to Borislav Petkov
Quoted 1 line · Borislav Petkov

* btw, perf and ftrace really need to get married :)

We all agree to that. It's the wedding plans the in-laws are fighting over.

-- Steve