RAS daemon v3
Subsystems (4)
cover RAS daemon v3
From: Borislav Petkov <[email protected]>
Hi all,
I finally had some time to work on this thing again. This time it can parse the MCE tracepoint and should be conceptually almost done. What needs to be done now is fleshing out a bunch of details here and there. I'm sending it early so that I can collect some more feedback.
So the patchset is ontop of 2.6.36 + Steven's trace_cmd restructuring set from
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git tip/perf/parse-events
I'm adding his patches too here, for completeness (although they need some more work).
I've also cherry-picked the bunch of EDAC's MCE injection stuff for testing.
So, in the end of the day, if you do
echo 0x9c00410000010016 > /sys/devices/system/edac/mce/status
(0x9c.. is the MCE signature of a data cache L2 TLB multimatch, for example)
echo 0 > /sys/devices/system/edac/mce/bank
(0 means bank 0, i.e. data cache errors)
after having loaded the mce_amd_inj injection testing module, the RAS daemon get's the status signature in userspace:
...
DBG main: Read some mmapped data
DBG main: MCE status: 0x9c00410000010016
All of the remaining fields can be postprocessed in arbitrary manner after that. The MCE decoding in the kernel can then be simplified by sharing it with the daemon, if needed. But that's another story.
To the patches, individually:
#1. Start splitting perf_event.c as we talked last time. The remaining units could be carved out from there based on functionality.
#2. persistent events registration
#3. ... and their first user.
#4,5: Steven's stuff. Btw, Steven, feel free to pick up any of the later patches if it makes your life easier, like #6 for example.
#6: could go with the above
#7-#19: Export all the shared stuff to the different libraries. I've splitted them to as small units as possible for easier review.
#20: Adds the daemon. Still full of debugging code since work-in-progress.
Also, in order to make this work, I needed the following hunk:
drivers/edac/mce_amd.c +3 -0
@@ -1,4 +1,5 @@#include <linux/module.h> +#include <trace/events/mce.h> #include "mce_amd.h" static bool report_gart_errors;
@@ -376,6 +377,8 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)amd_decode_err_code (m->status &0xffff ); +trace_mce_record (m); +return NOTIFY_STOP ;
This is needed just for testing the code by easily injecting MCEs as described above.
kernel/events/core.c +3 -1
@@ -2682,7 +2682,9 @@ static void perf_mmap_close(struct vm_area_struct *vma)struct user_struct *user = event->mmap_user;struct perf_buffer *buffer = event->buffer; -atomic_long_sub ((size >>PAGE_SHIFT ) +1 , &user->locked_vm); +if (user) +atomic_long_sub ((size >>PAGE_SHIFT ) +1 , &user->locked_vm); +
event->mmap_user doesn't get initialized in perf_mmap() since we have preallocated buffers and exit early. Which means that perf has to know about persistent events somehow or PeterZ has a better idea...
@@ -2719,8 +2721,10 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
if (event->cpu == -1 && event->attr.inherit)
return -EINVAL;
+#if 0
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
+#endif
Obviously, when mmaping the persistent buffers over debugfs, our vma is not shared. Uncommented for now until a figure out a sensible solution.
tools/lib/perf/mmap.c +4 -1
@@ -13,6 +13,7 @@ unsigned long mmap_read_head(struct mmap_data *md)return head; } +#if 0 static void mmap_write_tail (struct mmap_data *md,unsigned long tail) {struct perf_event_mmap_page *pc = md->base;
@@ -23,6 +24,7 @@ static void mmap_write_tail(struct mmap_data *md, unsigned long tail)/* mb(); */ pc->data_tail = tail; } +#endif static unsigned long mmap_read (struct mmap_data *md,void (*write_output)(void *,size_t ))
@@ -70,12 +72,13 @@ static unsigned long mmap_read(struct mmap_data *md, buf = &data[old & md->mask]; size = head - old; + old += size;write_output (buf, size); md->prev = old; -mmap_write_tail (md, old); +/* mmap_write_tail(md, old); */ return samples; }
This has to do with the previous change because mmap_write_tail() tries to write to RO mapping and there we segfault.
So anyway, here it is, it is still work in progress. Please take a look and let me know.
Thanks.
PATCH 1/20 perf: Start the massive restructuring
From: Borislav Petkov <[email protected]>
mv kernel/perf_event.c -> kernel/events/core.c. From there, all other sensible splitting can happen.
--- kernel/Makefile | 5 +- kernel/events/Makefile | 5 + kernel/events/core.c | 5895 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/perf_event.c | 5895 ------------------------------------------------ 4 files changed, 5904 insertions(+), 5896 deletions(-) create mode 100644 kernel/events/Makefile create mode 100644 kernel/events/core.c delete mode 100644 kernel/perf_event.c
kernel/Makefile +4 -1
@@ -100,7 +100,10 @@ obj-$(CONFIG_TRACING) += trace/ obj-$(CONFIG_X86_DS) += trace/ obj-$(CONFIG_RING_BUFFER) += trace/ obj-$(CONFIG_SMP) += sched_cpupri.o -obj-$(CONFIG_PERF_EVENTS) += perf_event.o + +# obj-$(CONFIG_PERF_EVENTS) += perf_event.o +obj-$(CONFIG_PERF_EVENTS) += events/ + obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o obj-$(CONFIG_PADATA) += padata.o
kernel/events/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +ifdef CONFIG_FUNCTION_TRACER +CFLAGS_REMOVE_perf_event.o = -pg +endif + +obj-y += core.o
kernel/events/core.c new file +5895 -0
2,984 lines not on this page · raw message
kernel/perf_event.c deleted +0 -5895
5,895 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 2/20 perf: Add persistent event facilities
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add barebones implementation for registering persistent events with perf.
--- include/linux/perf_event.h | 20 +++++++++++++++ kernel/events/Makefile | 2 +- kernel/events/core.c | 19 +++++++++++--- kernel/events/persistent.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 kernel/events/persistent.c
include/linux/perf_event.h +20 -0
@@ -1019,6 +1019,15 @@ extern int perf_swevent_get_recursion_context(void);extern void perf_swevent_put_recursion_context (int rctx);extern void perf_event_enable (struct perf_event *event);extern void perf_event_disable (struct perf_event *event); +extern struct perf_buffer * +perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags); +extern void perf_buffer_put (struct perf_buffer *buffer); +extern int perf_enable_persistent_event (struct perf_event **event, +struct perf_event_attr *attr, +int cpu,unsigned bufsz); +extern void perf_disable_persistent_event (struct perf_event *event,int cpu); +extern int perf_persistent_open (struct inode *inode,struct file *file); +extern const struct file_operations perf_pers_fops;#else static inline void perf_event_task_sched_in (struct task_struct *task) { }
@@ -1056,6 +1065,17 @@ static inline int perf_swevent_get_recursion_context(void) { return -1; }static inline void perf_swevent_put_recursion_context (int rctx) { }static inline void perf_event_enable (struct perf_event *event) { }static inline void perf_event_disable (struct perf_event *event) { } +static inline struct perf_buffer * +perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {return NULL ; } +static inline void perf_buffer_put (struct perf_buffer *buffer) {} +static inline int +perf_enable_persistent_event (struct perf_event **event, +struct perf_event_attr *attr,int cpu, +unsigned bufsz) {return -EINVAL ; } +static inline void +perf_disable_persistent_event (struct perf_event *event,int cpu) {} +static inline int +perf_persistent_open (struct inode *inode,struct file *file) {return -1 ; }#endif #define perf_output_put (handle, x) \
kernel/events/Makefile +1 -1
@@ -2,4 +2,4 @@ ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_perf_event.o = -pg endif -obj-y += core.o +obj-y += core.o persistent.o
kernel/events/core.c +15 -4
@@ -1899,7 +1899,7 @@ static void free_event_rcu(struct rcu_head *head) }static void perf_pending_sync (struct perf_event *event); -static void perf_buffer_put (struct perf_buffer *buffer); +void perf_buffer_put (struct perf_buffer *buffer);static void free_event (struct perf_event *event) {
@@ -2440,7 +2440,7 @@ static void *perf_mmap_alloc_page(int cpu)return page_address (page); } -static struct perf_buffer * +struct perf_buffer *perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {struct perf_buffer *buffer;
@@ -2557,7 +2557,7 @@ static void perf_buffer_free(struct perf_buffer *buffer)schedule_work (&buffer->work); } -static struct perf_buffer * +struct perf_buffer *perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {struct perf_buffer *buffer;
@@ -2658,7 +2658,7 @@ static struct perf_buffer *perf_buffer_get(struct perf_event *event)return buffer; } -static void perf_buffer_put (struct perf_buffer *buffer) +void perf_buffer_put (struct perf_buffer *buffer) {if (!atomic_dec_and_test (&buffer->refcount))return ;
@@ -2828,6 +2828,17 @@ static const struct file_operations perf_fops = { .fasync = perf_fasync, }; +const struct file_operations perf_pers_fops = { + .llseek = no_llseek, + .open = perf_persistent_open, + .poll = perf_poll, + .unlocked_ioctl = perf_ioctl, + .compat_ioctl = perf_ioctl, + .mmap = perf_mmap, + .fasync = perf_fasync, + .release = perf_release, +}; +/* * Perf event wakeup *
kernel/events/persistent.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.3.1
PATCH 3/20 x86, mce: Add persistent MCE event
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add the necessary glue to enable the mce_record tracepoint on boot turning it into a persistent event. This exports the MCE buffer read-only to a userspace daemon which will hook into it through debugfs when booting is finished.
--- arch/x86/include/asm/mce.h | 8 ++++ arch/x86/kernel/cpu/mcheck/mce.c | 84 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 0 deletions(-)
arch/x86/include/asm/mce.h +8 -0
@@ -91,6 +91,14 @@ struct mce_log {struct mce entry[MCE_LOG_LEN ]; }; +/* +* a per-cpu descriptor of the persistent MCE tracepoint +*/ +struct mce_tp_desc { +struct perf_event *event; +struct dentry *debugfs_entry; +}; +#define MCE_OVERFLOW 0/* bit 0 in flags means overflow */ #define MCE_LOG_SIGNATURE "MACHINECHECK"
arch/x86/kernel/cpu/mcheck/mce.c +84 -0
104 lines not on this page · raw message
Signature · 1 line
1.7.3.1
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 7 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add the necessary glue to enable the
mce_recordtracepoint on boot turning it into a persistent event. This exports the MCE buffer read-only to a userspace daemon which will hook into it through debugfs when booting is finished.
While MCE technically is a diagnostics service, do we want to start adding dependencies on debugfs in long-running, common-place daemons? I was under the impression we were to avoid using debugfs for anything other than values for one-off debugging.
Cheers,
- Ben
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 8 lines · Ben Gamari
Quoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add the necessary glue to enable the
mce_recordtracepoint on boot turning it into a persistent event. This exports the MCE buffer read-only to a userspace daemon which will hook into it through debugfs when booting is finished.
Quoted 4 lines
While MCE technically is a diagnostics service, do we want to start adding dependencies on debugfs in long-running, common-place daemons? I was under the impression we were to avoid using debugfs for anything other than values for one-off debugging.
See this current discussion thread on lkml:
[RFC][PATCH] perf: sysfs type id
Events are being added to sysfs as we want to avoid the debugfs dependency.
Thanks,
Ingo
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 16 lines · Ingo Molnar
Quoted 8 lines · Ben Gamari
Quoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add the necessary glue to enable the
mce_recordtracepoint on boot turning it into a persistent event. This exports the MCE buffer read-only to a userspace daemon which will hook into it through debugfs when booting is finished.Quoted 4 lines
While MCE technically is a diagnostics service, do we want to start adding dependencies on debugfs in long-running, common-place daemons? I was under the impression we were to avoid using debugfs for anything other than values for one-off debugging.
Quoted 5 lines
See this current discussion thread on lkml:
[RFC][PATCH] perf: sysfs type id
Events are being added to sysfs as we want to avoid the debugfs dependency.
Yep, event enumeration will land in /sysfs eventually but in this case debugfs is used to export the buffers with the events recorded so far to the daemon which mmaps them. And I remember also being mentioned that debugfs will thus be always compiled in because of that.
In any case, we need some kind of a facility with which to export those buffers for userspace to mmap. sysfs is clearly not that and debugfs is what we currently use. I'm open for better suggestions though.
Thanks.
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 Muenchen Registergericht Muenchen, HRB Nr. 43632
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 19 lines · Borislav Petkov
Quoted 18 lines · Ingo Molnar
Quoted 8 lines · Ben Gamari
Quoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add the necessary glue to enable the
mce_recordtracepoint on boot turning it into a persistent event. This exports the MCE buffer read-only to a userspace daemon which will hook into it through debugfs when booting is finished.Quoted 4 lines
While MCE technically is a diagnostics service, do we want to start adding dependencies on debugfs in long-running, common-place daemons? I was under the impression we were to avoid using debugfs for anything other than values for one-off debugging.
See this current discussion thread on lkml:
Quoted 8 lines
Quoted 3 lines
[RFC][PATCH] perf: sysfs type id
Events are being added to sysfs as we want to avoid the debugfs dependency.
Yep, event enumeration will land in /sysfs eventually but in this case debugfs is used to export the buffers with the events recorded so far to the daemon which mmaps them. And I remember also being mentioned that debugfs will thus be always compiled in because of that.
The event ring-buffer can be mmap()-ed off the fd that sys_perf_event_open() gives. This is what all of tools/perf/ does - it uses debugfs only for even enumeration (which will move to sysfs).
Thanks,
Ingo
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 6 lines · Ingo Molnar
Quoted 4 lines
Yep, event enumeration will land in /sysfs eventually but in this case debugfs is used to export the buffers with the events recorded so far to the daemon which mmaps them. And I remember also being mentioned that debugfs will thus be always compiled in because of that.
The event ring-buffer can be mmap()-ed off the fd that
sys_perf_event_open()gives.
This is what I did in the first version of the patchset...
Quoted 2 lines
This is what all of
tools/perf/does - it uses debugfs only for even enumeration (which will move to sysfs).
but then PeterZ suggested I should use debugfs to export the buffers and not teach sys_perf_event_open of persistent events. Which is also the right thing to do (maybe not through debugfs) since we want to have a single per-cpu buffer with all MCEs in there which even multiple userspace tools can access. So the question is, how do I mmap() those properly?
So we either
1) use the perf syscall and teach it about persistent events and it always returns the same fd whenever a persistent event is requested over its attr argument;
2) use debugfs (current approach);
3) enable the persistent event and stash its fd in some /sysfs member which the RAS daemon reads out and mmaps. This last one actually sounds pretty neat.
4) another idea which I'm missing.
So what do you guys think?
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 Muenchen Registergericht Muenchen, HRB Nr. 43632
Peter Zijlstra
maintainerRe: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 3 lines · Borislav Petkov
3) enable the persistent event and stash its fd in some /sysfs member which the RAS daemon reads out and mmaps. This last one actually sounds pretty neat.
Right, stashing the thing in sysfs, which you can open()+mmap() seems the best way. Not sure you want to make it a RAS specific place, maybe a generic persistent buffer place.
You'll get multiple files anyway, one per cpu, so maybe something like:
/sysfs/persistent_buffer/ras[0..n]
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Borislav Petkov
3) enable the persistent event and stash its fd in some /sysfs member which the RAS daemon reads out and mmaps. This last one actually sounds pretty neat.
Quoted 7 lines
Right, stashing the thing in sysfs, which you can open()+mmap() seems the best way. Not sure you want to make it a RAS specific place, maybe a generic persistent buffer place.
You'll get multiple files anyway, one per cpu, so maybe something like:
/sysfs/persistent_buffer/ras[0..n]
Yeah, or even integrate it even further into the events hierarchy like this:
/sys/.../cpu/events/mce -> this is the trace_mce_record tracepoint/sys/.../cpu/events/mce_pers -> persistent buffer fd
or an additional level further down
/sys/.../cpu/events/mce/persistent/...
or whatever.
Generally I don't care too much where we put it at the end.
Thanks.
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 Muenchen Registergericht Muenchen, HRB Nr. 43632
Re: [PATCH 03/20] x86, mce: Add persistent MCE event
Quoted 20 lines · Borislav Petkov
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Borislav Petkov
3) enable the persistent event and stash its fd in some /sysfs member which the RAS daemon reads out and mmaps. This last one actually sounds pretty neat.
Quoted 7 lines
Right, stashing the thing in sysfs, which you can open()+mmap() seems the best way. Not sure you want to make it a RAS specific place, maybe a generic persistent buffer place.
You'll get multiple files anyway, one per cpu, so maybe something like:
/sysfs/persistent_buffer/ras[0..n]
Yeah, or even integrate it even further into the events hierarchy like this:
/sys/.../cpu/events/mce-> this is thetrace_mce_recordtracepoint/sys/.../cpu/events/mce_pers-> persistent buffer fd
Quoted 7 lines
or an additional level further down
/sys/.../cpu/events/mce/persistent/...or whatever.
Generally I don't care too much where we put it at the end.
It should be in a nice logical place though :-)
Thanks,
Ingo
PATCH 4/20 perf: Move trace-event-parse out of perf/util directory
In reply to Borislav PetkovFrom: Steven Rostedt <[email protected]>
Move the parse-events.c code that originally came from trace-cmd into tools/lib/ and use it to make a libparsevent.a library.
This patch moves the file with minimal changes to the code.
--- tools/lib/Makefile | 43 + tools/lib/parse-events.c | 3231 ++++++++++++++++++++++++++++++++++ tools/lib/parse-events.h | 295 ++++ tools/perf/Makefile | 11 +- tools/perf/util/trace-event-parse.c | 3233 ----------------------------------- tools/perf/util/trace-event.h | 297 +---- 6 files changed, 3582 insertions(+), 3528 deletions(-) create mode 100644 tools/lib/Makefile create mode 100644 tools/lib/parse-events.c create mode 100644 tools/lib/parse-events.h delete mode 100644 tools/perf/util/trace-event-parse.c
tools/lib/Makefile new file +43 -0
@@ -0,0 +1,43 @@ + +# Make the path relative to DESTDIR, not to prefix +ifndef DESTDIR +prefix = $(HOME) +endif +bindir_relative = bin +bindir = $(prefix)/$(bindir_relative) +mandir = share/man +infodir = share/info +sharedir = $(prefix)/share +ifeq ($(prefix),/usr) +sysconfdir = /etc +else +sysconfdir = $(prefix)/etc +endif + +export prefix bindir sharedir sysconfdir + +CC = $(CROSS_COMPILE)gcc +AR = $(CROSS_COMPILE)ar +RM = rm -f +TAR = tar +FIND = find +INSTALL = install +RPMBUILD = rpmbuild +PTHREAD_LIBS = -lpthread + +ifeq ("$(origin V)", "command line") + VERBOSE = $(V) +endif +ifndef VERBOSE + VERBOSE = 0 +endif + +all: libparsevent.a + +PEVENT_LIB_OBJS = parse-events.o + +$(OUTPUT)%.o: %.c + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< + +libparsevent.a: $(PEVENT_LIB_OBJS) + $(RM) $@; $(AR) rcs $@ $^
tools/lib/parse-events.c new file +3231 -0
2,957 lines not on this page · raw message
tools/lib/parse-events.h new file +295 -0
295 lines not on this page · raw message
tools/perf/util/trace-event-parse.c deleted +0 -3233
3,233 lines not on this page · raw message
tools/perf/util/trace-event.h +4 -293
297 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 5/20 perf: Update the lib parse-events to the latest code
In reply to Borislav PetkovFrom: Steven Rostedt <[email protected]>
TBD
--- tools/lib/Makefile | 10 +- tools/lib/parse-events.c | 3248 ++++++++++++++------ tools/lib/parse-events.h | 604 ++++- tools/lib/parse-filter.c | 2085 +++++++++++++ tools/lib/parse-utils.c | 110 + tools/lib/trace-seq.c | 153 + tools/lib/util.h | 64 + tools/perf/Makefile | 8 +- tools/perf/builtin-kmem.c | 6 +- tools/perf/builtin-lock.c | 26 +- tools/perf/builtin-sched.c | 42 +- .../util/scripting-engines/trace-event-python.c | 12 +- tools/perf/util/trace-event-info.c | 2 + tools/perf/util/trace-event-parse.c | 234 ++ tools/perf/util/trace-event-read.c | 24 +- tools/perf/util/trace-event.h | 79 + 16 files changed, 5648 insertions(+), 1059 deletions(-) create mode 100644 tools/lib/parse-filter.c create mode 100644 tools/lib/parse-utils.c create mode 100644 tools/lib/trace-seq.c create mode 100644 tools/lib/util.h create mode 100644 tools/perf/util/trace-event-parse.c
tools/lib/Makefile +8 -2
@@ -34,10 +34,16 @@ endif all: libparsevent.a -PEVENT_LIB_OBJS = parse-events.o +PEVENT_LIB_OBJS += parse-events.o +PEVENT_LIB_OBJS += parse-filter.o +PEVENT_LIB_OBJS += parse-utils.o +PEVENT_LIB_OBJS += trace-seq.o $(OUTPUT)%.o: %.c - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< + $(QUIET_CC)$(CC) -g -o $@ -c $(ALL_CFLAGS) $< libparsevent.a: $(PEVENT_LIB_OBJS) $(RM) $@; $(AR) rcs $@ $^ + +clean: + $(RM) *.a *.o *~ *.so
tools/lib/parse-events.c +2336 -912
2,981 lines not on this page · raw message
tools/lib/parse-events.h +514 -90
604 lines not on this page · raw message
tools/lib/parse-filter.c new file +2085 -0
2,085 lines not on this page · raw message
tools/lib/parse-utils.c new file +110 -0
110 lines not on this page · raw message
tools/lib/trace-seq.c new file +153 -0
153 lines not on this page · raw message
tools/lib/util.h new file +64 -0
64 lines not on this page · raw message
tools/perf/builtin-sched.c +21 -21
42 lines not on this page · raw message
tools/perf/util/scripting-engines/trace-event-python.c +6 -6
Lines of this file are not shown. View the raw message.
tools/perf/util/trace-event-parse.c new file +234 -0
234 lines not on this page · raw message
tools/perf/util/trace-event.h +79 -0
79 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 6/20 perf: Move trace stuff into tools/lib/trace
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Move tracing stuff into tools/lib/trace and rewire it back into perf. Add a top-level Makefile which selects between targets depending on the tool we want to build.
Also, add a Makefile.lib for common facilities used by all the Makefiles. While at it, make sure objects output directory using O= exists.
Finally, rename trace/util.h to trace/trace-util.h so as not to conflict with perf's util.h.
--- tools/Makefile | 47 + tools/lib/Makefile | 49 - tools/lib/parse-events.c | 4655 ---------------------------------------- tools/lib/parse-events.h | 719 ------- tools/lib/parse-filter.c | 2085 ------------------ tools/lib/parse-utils.c | 110 - tools/lib/trace-seq.c | 153 -- tools/lib/trace/Makefile | 54 + tools/lib/trace/parse-events.c | 4655 ++++++++++++++++++++++++++++++++++++++++ tools/lib/trace/parse-events.h | 719 +++++++ tools/lib/trace/parse-filter.c | 2085 ++++++++++++++++++ tools/lib/trace/parse-utils.c | 110 + tools/lib/trace/trace-seq.c | 153 ++ tools/lib/trace/trace-util.h | 64 + tools/lib/util.h | 64 - tools/perf/Makefile | 41 +- tools/perf/util/trace-event.h | 2 +- tools/scripts/Makefile.lib | 33 + 18 files changed, 7923 insertions(+), 7875 deletions(-) create mode 100644 tools/Makefile delete mode 100644 tools/lib/Makefile delete mode 100644 tools/lib/parse-events.c delete mode 100644 tools/lib/parse-events.h delete mode 100644 tools/lib/parse-filter.c delete mode 100644 tools/lib/parse-utils.c delete mode 100644 tools/lib/trace-seq.c create mode 100644 tools/lib/trace/Makefile create mode 100644 tools/lib/trace/parse-events.c create mode 100644 tools/lib/trace/parse-events.h create mode 100644 tools/lib/trace/parse-filter.c create mode 100644 tools/lib/trace/parse-utils.c create mode 100644 tools/lib/trace/trace-seq.c create mode 100644 tools/lib/trace/trace-util.h delete mode 100644 tools/lib/util.h create mode 100644 tools/scripts/Makefile.lib
tools/Makefile new file +47 -0
@@ -0,0 +1,47 @@ +include scripts/Makefile.lib + +# 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 + +# lib includes for submake +BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include +export BASIC_CFLAGS + +PERF_TOP_DIR := $(CURDIR) +export PERF_TOP_DIR + +perf: libparsevent .FORCE + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) + +libparsevent: .FORCE + $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) + +clean: + $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean + +.PHONY: clean .FORCE
tools/lib/Makefile deleted +0 -49
50 lines not on this page · raw message
tools/lib/parse-events.c deleted +0 -4655
2,903 lines not on this page · raw message
tools/lib/parse-events.h deleted +0 -719
719 lines not on this page · raw message
tools/lib/parse-filter.c deleted +0 -2085
2,085 lines not on this page · raw message
tools/lib/parse-utils.c deleted +0 -110
110 lines not on this page · raw message
tools/lib/trace-seq.c deleted +0 -153
153 lines not on this page · raw message
tools/lib/trace/Makefile new file +54 -0
54 lines not on this page · raw message
tools/lib/trace/parse-events.c new file +4655 -0
4,655 lines not on this page · raw message
tools/lib/trace/parse-events.h new file +719 -0
719 lines not on this page · raw message
tools/lib/trace/parse-filter.c new file +2085 -0
2,085 lines not on this page · raw message
tools/lib/trace/parse-utils.c new file +110 -0
110 lines not on this page · raw message
tools/lib/trace/trace-seq.c new file +153 -0
153 lines not on this page · raw message
tools/lib/trace/trace-util.h new file +64 -0
64 lines not on this page · raw message
tools/lib/util.h deleted +0 -64
64 lines not on this page · raw message
tools/perf/Makefile +2 -39
41 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 7/20 perf: Export debugfs utilities
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export /proc/mounts parser and other debugfs-related helpers for general use. Also, exit if a valid debugfs mountpoint cannot be found.
--- tools/Makefile | 8 +- tools/lib/lk/Makefile | 38 +++ tools/lib/lk/debugfs.c | 256 ++++++++++++++++++ tools/lib/lk/debugfs.h | 31 +++ tools/lib/lk/types.h | 17 ++ tools/lib/lk/usage.c | 80 ++++++ tools/lib/lk/util.h | 285 ++++++++++++++++++++ tools/perf/Makefile | 11 +- 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-annotate.c | 2 +- tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-probe.c | 5 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 2 +- tools/perf/builtin.h | 2 +- tools/perf/perf.c | 23 +-- tools/perf/perf.h | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/cache.h | 4 +- tools/perf/util/callchain.c | 2 +- tools/perf/util/config.c | 2 +- tools/perf/util/cpumap.c | 2 +- tools/perf/util/debug.c | 2 +- tools/perf/util/debugfs.c | 240 ---------------- tools/perf/util/debugfs.h | 25 -- tools/perf/util/header.c | 2 +- tools/perf/util/header.h | 2 +- tools/perf/util/hist.c | 2 +- tools/perf/util/include/linux/ctype.h | 2 +- tools/perf/util/map.h | 2 +- tools/perf/util/parse-events.c | 5 +- tools/perf/util/parse-options.c | 2 +- tools/perf/util/probe-event.c | 5 +- tools/perf/util/probe-finder.c | 2 +- tools/perf/util/probe-finder.h | 2 +- tools/perf/util/pstack.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/sort.h | 2 +- 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 | 3 +- 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 | 80 ------ tools/perf/util/util.c | 2 +- tools/perf/util/util.h | 285 -------------------- tools/perf/util/values.c | 2 +- tools/perf/util/values.h | 2 +- 65 files changed, 782 insertions(+), 728 deletions(-) create mode 100644 tools/lib/lk/Makefile create mode 100644 tools/lib/lk/debugfs.c create mode 100644 tools/lib/lk/debugfs.h create mode 100644 tools/lib/lk/types.h create mode 100644 tools/lib/lk/usage.c create mode 100644 tools/lib/lk/util.h delete mode 100644 tools/perf/util/debugfs.c delete mode 100644 tools/perf/util/debugfs.h delete mode 100644 tools/perf/util/types.h delete mode 100644 tools/perf/util/usage.c delete mode 100644 tools/perf/util/util.h
tools/Makefile +6 -2
@@ -28,20 +28,24 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement export EXTRA_WARNINGS # lib includes for submake -BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include +BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/lib -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include export BASIC_CFLAGS PERF_TOP_DIR := $(CURDIR) export PERF_TOP_DIR -perf: libparsevent .FORCE +perf: libparsevent lklib .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) libparsevent: .FORCE $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) +lklib: .FORCE + $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) + clean: $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean .PHONY: clean .FORCE
tools/lib/lk/Makefile new file +38 -0
@@ -0,0 +1,38 @@ +include ../../scripts/Makefile.lib + +# guard against environment variables +LIB_H= +LIB_OBJS= + +LIB_H += debugfs.h +LIB_H += util.h +LIB_H += types.h + +LIB_OBJS += debugfs.o +LIB_OBJS += usage.o + +LIBFILE = $(LIB_OUTPUT)lklib.a + +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) +EXTLIBS = -lpthread -lrt -lelf -lm +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS = $(LDFLAGS) + +RM = rm -f + +$(LIBFILE): $(LIB_OBJS) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) + +$(LIB_OBJS): $(LIB_H) + +%.o: %.c + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +%.s: %.c + $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $< +%.o: %.S + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< + +clean: + $(RM) $(LIB_OBJS) $(LIBFILE) + +.PHONY: clean
tools/lib/lk/debugfs.c new file +256 -0
256 lines not on this page · raw message
tools/lib/lk/debugfs.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef __DEBUGFS_H__ +#define __DEBUGFS_H__ + +#include <sys/mount.h> +#include <sys/types.h> + +#ifndef MAX_PATH +# define MAX_PATH 256 +#endif + +#ifndef STR +# define _STR (x) #x +# define STR (x) _STR(x) +#endif + +#define LK_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" + +extern char debugfs_mntpt[]; + +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 int get_debugfs_mntpt (void ); + +#endif /* __DEBUGFS_H__ */
tools/lib/lk/types.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __LK_TYPES_H +#define __LK_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 /* __LK_TYPES_H */
tools/lib/lk/usage.c new file +80 -0
80 lines not on this page · raw message
tools/lib/lk/util.h new file +285 -0
285 lines not on this page · raw message
tools/perf/Makefile +3 -8
@@ -270,7 +270,7 @@ endif # Those must not be GNU-specific; they are shared with perl/ which may # be built by a different compiler. (Note that this is an artifact now # but it still might be nice to keep that distinction.) -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include +BASIC_CFLAGS += -Iarch/$(ARCH)/include BASIC_LDFLAGS = # Guard against environment variables
@@ -328,7 +328,7 @@ export PERL_PATH LIB_FILE=$(OUTPUT)libperf.a -EXTRA_LIB_FILE=$(LIB_OUTPUT)libparsevent.a +EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/rbtree.h
@@ -360,16 +360,13 @@ LIB_H += util/cache.h LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h -LIB_H += util/debugfs.h LIB_H += util/event.h LIB_H += util/exec_cmd.h -LIB_H += util/types.h LIB_H += util/levenshtein.h LIB_H += util/map.h LIB_H += util/parse-options.h LIB_H += util/parse-events.h LIB_H += util/quote.h -LIB_H += util/util.h LIB_H += util/header.h LIB_H += util/help.h LIB_H += util/session.h
@@ -395,7 +392,6 @@ LIB_OBJS += $(OUTPUT)util/alias.o LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o -LIB_OBJS += $(OUTPUT)util/debugfs.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o
@@ -412,7 +408,6 @@ LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o LIB_OBJS += $(OUTPUT)util/string.o LIB_OBJS += $(OUTPUT)util/strlist.o -LIB_OBJS += $(OUTPUT)util/usage.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/symbol.o
@@ -465,7 +460,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o BUILTIN_OBJS += $(OUTPUT)builtin-test.o BUILTIN_OBJS += $(OUTPUT)builtin-inject.o -PERFLIBS = $(LIB_FILE) $(EXTRA_LIB_FILE) +PERFLIBS = $(LIB_FILE) $(EXTRA_LIB_FILES) # # Platform specific tweaks
tools/perf/bench/bench.h +2 -0
@@ -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
@@ -8,7 +8,7 @@#include <ctype.h> #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../util/header.h" #include "bench.h"
tools/perf/bench/sched-messaging.c +1 -1
@@ -10,7 +10,7 @@*/ #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../builtin.h" #include "bench.h"
tools/perf/bench/sched-pipe.c +1 -1
@@ -11,7 +11,7 @@*/ #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../builtin.h" #include "bench.h"
tools/perf/builtin-annotate.c +1 -1
@@ -7,7 +7,7 @@*/ #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/color.h" #include <linux/list.h>
tools/perf/builtin-bench.c +1 -1
@@ -17,7 +17,7 @@*/ #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "builtin.h" #include "bench/bench.h"
tools/perf/builtin-diff.c +1 -1
@@ -12,7 +12,7 @@#include "util/session.h" #include "util/sort.h" #include "util/symbol.h" -#include "util/util.h" +#include <lk/util.h> #include <stdlib.h>
tools/perf/builtin-kmem.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-kvm.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-lock.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-probe.c +3 -2
@@ -32,13 +32,14 @@#include <string.h> #undef _GNU_SOURCE +#include <lk/util.h> +#include <lk/debugfs.h> +#include "perf.h" #include "builtin.h" -#include "util/util.h" #include "util/strlist.h" #include "util/symbol.h" #include "util/debug.h" -#include "util/debugfs.h" #include "util/parse-options.h" #include "util/probe-finder.h" #include "util/probe-event.h"
tools/perf/builtin-record.c +1 -1
@@ -12,7 +12,7 @@#include "perf.h" #include "util/build-id.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "util/parse-events.h"
tools/perf/builtin-report.c +1 -1
@@ -7,7 +7,7 @@*/ #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/color.h" #include <linux/list.h>
tools/perf/builtin-sched.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-stat.c +1 -1
@@ -39,7 +39,7 @@#include "perf.h" #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "util/parse-events.h" #include "util/event.h"
tools/perf/builtin-timechart.c +1 -1
@@ -14,7 +14,7 @@#include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/color.h" #include <linux/list.h>
tools/perf/builtin-top.c +1 -1
@@ -24,7 +24,7 @@#include "util/session.h" #include "util/symbol.h" #include "util/thread.h" -#include "util/util.h" +#include <lk/util.h> #include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h"
tools/perf/builtin-trace.c +1 -1
@@ -10,7 +10,7 @@#include "util/symbol.h" #include "util/thread.h" #include "util/trace-event.h" -#include "util/util.h" +#include <lk/util.h> static char const *script_name;static char const *generate_script_lang;
tools/perf/builtin.h +1 -1
@@ -1,7 +1,7 @@#ifndef BUILTIN_H #define BUILTIN_H -#include "util/util.h" +#include <lk/util.h> #include "util/strbuf.h" extern const char perf_version_string[];
tools/perf/perf.c +6 -17
@@ -6,14 +6,14 @@* This is the main hub from which the sub-commands (perf stat, * perf top, perf record, perf report, etc.) are started. */ -#include "builtin.h" +#include <lk/debugfs.h> +#include "builtin.h" #include "util/exec_cmd.h" #include "util/cache.h" #include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.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;
@@ -85,7 +83,7 @@ static void set_debugfs_path(void) {char *path; - path =getenv (PERF_DEBUGFS_ENVIRONMENT ); + path =getenv (LK_DEBUGFS_ENVIRONMENT );snprintf (debugfs_path,MAXPATHLEN ,"%s/%s" , path ?: debugfs_mntpt,"tracing/events" ); }
@@ -415,17 +413,6 @@ static int run_argv(int *argcp, const char ***argv)return done_alias; } -/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ -static void get_debugfs_mntpt (void ) -{ -const char *path =debugfs_mount (NULL ); - -if (path) -strncpy (debugfs_mntpt, path,sizeof (debugfs_mntpt)); -else - debugfs_mntpt[0 ] ='\0' ; -} -int main (int argc,const char **argv) {const char *cmd;
@@ -434,7 +421,9 @@ int main(int argc, const char **argv)if (!cmd) cmd ="perf-help" ;/* get debugfs mount point from /proc/mounts */ -get_debugfs_mntpt (); +if (get_debugfs_mntpt ()) +die ("cannot find debugfs mountpoint" ); +/* * "perf-xxxx" is the same as "perf xxxx", but we obviously: *
tools/perf/perf.h +1 -1
@@ -91,7 +91,7 @@ void get_term_dimensions(struct winsize *ws);#include <sys/syscall.h> #include "../../include/linux/perf_event.h" -#include "util/types.h" +#include <lk/types.h> #include <stdbool.h> /*
tools/perf/util/build-id.c +1 -1
@@ -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 <lk/util.h> #include <stdio.h> #include "build-id.h" #include "event.h"
tools/perf/util/cache.h +2 -2
@@ -2,9 +2,10 @@#define __PERF_CACHE_H#include <stdbool.h> -#include "util.h" +#include <lk/util.h> #include "strbuf.h" #include "../perf.h" +#include <linux/compiler.h> #define CMD_EXEC_PATH "--exec-path"#define CMD_PERF_DIR "--perf-dir="
@@ -15,7 +16,6 @@#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" -#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"typedef int (*config_fn_t )(const char *,const char *,void *);extern int perf_default_config (const char *,const char *,void *);
tools/perf/util/callchain.c +1 -1
@@ -15,7 +15,7 @@#include <errno.h> #include <math.h> -#include "util.h" +#include <lk/util.h> #include "callchain.h" bool ip_callchain__valid (struct ip_callchain *chain,const event_t *event)
tools/perf/util/config.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) Johannes Schindelin, 2005 * */ -#include "util.h" +#include <lk/util.h> #include "cache.h" #include "exec_cmd.h"
tools/perf/util/cpumap.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "../perf.h" #include "cpumap.h" #include <assert.h>
tools/perf/util/debug.c +1 -1
@@ -10,7 +10,7 @@#include "color.h" #include "event.h" #include "debug.h" -#include "util.h" +#include <lk/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
@@ -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/header.c +1 -1
@@ -8,7 +8,7 @@#include <linux/list.h> #include <linux/kernel.h> -#include "util.h" +#include <lk/util.h> #include "header.h" #include "../perf.h" #include "trace-event.h"
tools/perf/util/header.h +1 -1
@@ -4,7 +4,7 @@#include "../../../include/linux/perf_event.h" #include <sys/types.h> #include <stdbool.h> -#include "types.h" +#include <lk/types.h> #include "event.h" #include <linux/bitmap.h>
tools/perf/util/hist.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "build-id.h" #include "hist.h" #include "session.h"
tools/perf/util/include/linux/ctype.h +1 -1
@@ -1 +1 @@ -#include "../util.h" +#include <lk/util.h>
tools/perf/util/map.h +1 -1
@@ -6,7 +6,7 @@#include <linux/rbtree.h> #include <stdio.h> #include <stdbool.h> -#include "types.h" +#include <lk/types.h> enum map_type {MAP__FUNCTION =0 ,
tools/perf/util/parse-events.c +3 -2
@@ -1,5 +1,7 @@ +#include <lk/util.h> +#include <lk/debugfs.h> +#include "../../../include/linux/hw_breakpoint.h" -#include "util.h" #include "../perf.h" #include "parse-options.h" #include "parse-events.h"
@@ -8,7 +10,6 @@#include "symbol.h" #include "cache.h" #include "header.h" -#include "debugfs.h" int nr_counters;
tools/perf/util/parse-options.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "parse-options.h" #include "cache.h"
tools/perf/util/probe-event.c +3 -2
@@ -33,7 +33,9 @@#include <limits.h> #undef _GNU_SOURCE -#include "util.h" +#include <lk/util.h> +#include <lk/debugfs.h> +#include "event.h" #include "string.h" #include "strlist.h"
@@ -42,7 +44,6 @@#include "color.h" #include "symbol.h" #include "thread.h" -#include "debugfs.h" #include "trace-event.h" /* For __unused */ #include "probe-event.h" #include "probe-finder.h"
tools/perf/util/probe-finder.c +1 -1
@@ -35,7 +35,7 @@#include "event.h" #include "debug.h" -#include "util.h" +#include <lk/util.h> #include "symbol.h" #include "probe-finder.h"
tools/perf/util/probe-finder.h +1 -1
@@ -2,7 +2,7 @@#define _PROBE_FINDER_H#include <stdbool.h> -#include "util.h" +#include <lk/util.h> #include "probe-event.h" #define MAX_PATH_LEN 256
tools/perf/util/pstack.c +1 -1
@@ -4,7 +4,7 @@* (c) 2010 Arnaldo Carvalho de Melo <[email protected]> */ -#include "util.h" +#include <lk/util.h> #include "pstack.h" #include <linux/kernel.h> #include <stdlib.h>
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -26,7 +26,7 @@#include <errno.h> #include "../../perf.h" -#include "../util.h" +#include <lk/util.h> #include "../trace-event.h" #include <EXTERN.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -28,7 +28,7 @@#include <errno.h> #include "../../perf.h" -#include "../util.h" +#include <lk/util.h> #include "../trace-event.h" PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/session.c +1 -1
@@ -9,7 +9,7 @@#include "session.h" #include "sort.h" -#include "util.h" +#include <lk/util.h> static int perf_session__open (struct perf_session *self,bool force) {
tools/perf/util/sort.h +1 -1
@@ -2,7 +2,7 @@#define __PERF_SORT_H#include "../builtin.h" -#include "util.h" +#include <lk/util.h> #include "color.h" #include <linux/list.h>
tools/perf/util/string.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "string.h" #define K 1024LL
tools/perf/util/svghelper.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_SVGHELPER_H#define __PERF_SVGHELPER_H -#include "types.h" +#include <lk/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
@@ -4,7 +4,7 @@#include <string.h> #include "session.h" #include "thread.h" -#include "util.h" +#include <lk/util.h> #include "debug.h" /* Skip "." and ".." directories */
tools/perf/util/trace-event-info.c +2 -1
@@ -36,9 +36,10 @@#include <stdbool.h> #include <linux/kernel.h> +#include <lk/debugfs.h> +#include "../perf.h" #include "trace-event.h" -#include "debugfs.h" #define VERSION "0.5"
tools/perf/util/trace-event-parse.c +1 -1
@@ -27,7 +27,7 @@#undef _GNU_SOURCE#include "../perf.h" -#include "util.h" +#include <lk/util.h> #include "trace-event.h" int header_page_size_size;
tools/perf/util/trace-event-read.c +1 -1
@@ -37,7 +37,7 @@#include <errno.h> #include "../perf.h" -#include "util.h" +#include <lk/util.h> #include "trace-event.h" static int input_fd;
tools/perf/util/trace-event-scripting.c +1 -1
@@ -26,7 +26,7 @@#include <errno.h> #include "../perf.h" -#include "util.h" +#include <lk/util.h> #include "trace-event.h" struct scripting_context *scripting_context;
tools/perf/util/types.h deleted +0 -17
@@ -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 deleted +0 -80
80 lines not on this page · raw message
tools/perf/util/util.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include <sys/mman.h> int mkdir_p (char *path,mode_t mode)
tools/perf/util/util.h deleted +0 -285
285 lines not on this page · raw message
tools/perf/util/values.c +1 -1
@@ -1,6 +1,6 @@#include <stdlib.h> -#include "util.h" +#include <lk/util.h> #include "values.h" void perf_read_values_init (struct perf_read_values *values)
tools/perf/util/values.h +1 -1
@@ -1,7 +1,7 @@ #ifndef __PERF_VALUES_H #define __PERF_VALUES_H -#include "types.h" +#include <lk/types.h> struct perf_read_values { int threads;
Signature · 1 line
1.7.3.1
PATCH 8/20 perf: Export cpumap
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export cpu counting and cpumap manipulating utils for general use. This pulls ctype.c along.
--- tools/lib/lk/Makefile | 3 + tools/lib/lk/cpumap.c | 114 +++++++++++++++++++++++++++++++++++++++++++ tools/lib/lk/cpumap.h | 7 +++ tools/lib/lk/ctype.c | 39 +++++++++++++++ tools/perf/Makefile | 3 - tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/cpumap.c | 114 ------------------------------------------- tools/perf/util/cpumap.h | 7 --- tools/perf/util/ctype.c | 39 --------------- 11 files changed, 166 insertions(+), 166 deletions(-) create mode 100644 tools/lib/lk/cpumap.c create mode 100644 tools/lib/lk/cpumap.h create mode 100644 tools/lib/lk/ctype.c delete mode 100644 tools/perf/util/cpumap.c delete mode 100644 tools/perf/util/cpumap.h delete mode 100644 tools/perf/util/ctype.c
tools/lib/lk/Makefile +3 -0
@@ -7,9 +7,12 @@ LIB_OBJS= LIB_H += debugfs.h LIB_H += util.h LIB_H += types.h +LIB_H += cpumap.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o +LIB_OBJS += cpumap.o +LIB_OBJS += ctype.o LIBFILE = $(LIB_OUTPUT)lklib.a
tools/lib/lk/cpumap.c new file +114 -0
114 lines not on this page · raw message
tools/lib/lk/cpumap.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __LK_CPUMAP_H +#define __LK_CPUMAP_H + +extern int read_cpu_map (const char *cpu_list); +extern int cpumap[]; + +#endif /* __LK_CPUMAP_H */
tools/lib/lk/ctype.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Sane locale-independent, ASCII ctype. +* +* No surprises, and works with signed and unsigned chars. +*/ +#include "util.h" + +enum { +S =GIT_SPACE , +A =GIT_ALPHA , +D =GIT_DIGIT , +G =GIT_GLOB_SPECIAL ,/* *, ?, [, \\ */ +R =GIT_REGEX_SPECIAL ,/* $, (, ), +, ., ^, {, | * */ +P =GIT_PRINT_EXTRA ,/* printable - alpha - digit - glob - regex */ + +PS =GIT_SPACE |GIT_PRINT_EXTRA , +}; + +unsigned char sane_ctype[256 ] = { +/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,S ,S ,0 ,0 ,S ,0 ,0 ,/* 0.. 15 */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 16.. 31 */ +PS ,P ,P ,P ,R ,P ,P ,P ,R ,R ,G ,R ,P ,P ,R ,P ,/* 32.. 47 */ +D ,D ,D ,D ,D ,D ,D ,D ,D ,D ,P ,P ,P ,P ,P ,G ,/* 48.. 63 */ +P ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,/* 64.. 79 */ +A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,G ,G ,P ,R ,P ,/* 80.. 95 */ +P ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,/* 96..111 */ +A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,R ,R ,P ,P ,0 ,/* 112..127 */ +/* Nothing in the 128.. range */ +}; + +const char *graph_line = +"_____________________________________________________________________" +"_____________________________________________________________________" ; +const char *graph_dotted_line = +"---------------------------------------------------------------------" +"---------------------------------------------------------------------" +"---------------------------------------------------------------------" ;
tools/perf/Makefile +0 -3
@@ -385,13 +385,11 @@ LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h LIB_H += util/pstack.h -LIB_H += util/cpumap.h LIB_OBJS += $(OUTPUT)util/abspath.o LIB_OBJS += $(OUTPUT)util/alias.o LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o -LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o
@@ -430,7 +428,6 @@ LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o LIB_OBJS += $(OUTPUT)util/util.o -LIB_OBJS += $(OUTPUT)util/cpumap.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
tools/perf/builtin-record.c +1 -1
@@ -21,7 +21,7 @@#include "util/debug.h" #include "util/session.h" #include "util/symbol.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include <unistd.h> #include <sched.h>
tools/perf/builtin-stat.c +1 -1
@@ -45,7 +45,7 @@#include "util/event.h" #include "util/debug.h" #include "util/header.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/thread.h" #include <sys/prctl.h>
tools/perf/builtin-top.c +1 -1
@@ -28,7 +28,7 @@#include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/debug.h"
tools/perf/util/cpumap.c deleted +0 -114
114 lines not on this page · raw message
tools/perf/util/cpumap.h deleted +0 -7
@@ -1,7 +0,0 @@ -#ifndef __PERF_CPUMAP_H -#define __PERF_CPUMAP_H - -extern int read_cpu_map (const char *cpu_list); -extern int cpumap[]; - -#endif /* __PERF_CPUMAP_H */
tools/perf/util/ctype.c deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Sane locale-independent, ASCII ctype. -* -* No surprises, and works with signed and unsigned chars. -*/ -#include "cache.h" - -enum { -S =GIT_SPACE , -A =GIT_ALPHA , -D =GIT_DIGIT , -G =GIT_GLOB_SPECIAL ,/* *, ?, [, \\ */ -R =GIT_REGEX_SPECIAL ,/* $, (, ), +, ., ^, {, | * */ -P =GIT_PRINT_EXTRA ,/* printable - alpha - digit - glob - regex */ - -PS =GIT_SPACE |GIT_PRINT_EXTRA , -}; - -unsigned char sane_ctype[256 ] = { -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ - -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,S ,S ,0 ,0 ,S ,0 ,0 ,/* 0.. 15 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 16.. 31 */ -PS ,P ,P ,P ,R ,P ,P ,P ,R ,R ,G ,R ,P ,P ,R ,P ,/* 32.. 47 */ -D ,D ,D ,D ,D ,D ,D ,D ,D ,D ,P ,P ,P ,P ,P ,G ,/* 48.. 63 */ -P ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,/* 64.. 79 */ -A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,G ,G ,P ,R ,P ,/* 80.. 95 */ -P ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,/* 96..111 */ -A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,A ,R ,R ,P ,P ,0 ,/* 112..127 */ -/* Nothing in the 128.. range */ -}; - -const char *graph_line = -"_____________________________________________________________________" -"_____________________________________________________________________" ; -const char *graph_dotted_line = -"---------------------------------------------------------------------" -"---------------------------------------------------------------------" -"---------------------------------------------------------------------" ;
Signature · 1 line
1.7.3.1
PATCH 9/20 perf: Carve out mmap helpers for general use
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export the mmap_read* helpers into tools/lib/perf/mmap.[ch]
--- tools/Makefile | 6 ++- tools/lib/perf/Makefile | 35 ++++++++++++++ tools/lib/perf/mmap.c | 95 ++++++++++++++++++++++++++++++++++++++ tools/lib/perf/mmap.h | 15 ++++++ tools/perf/Makefile | 2 +- tools/perf/builtin-record.c | 107 ++++--------------------------------------- tools/perf/builtin-top.c | 28 ++--------- 7 files changed, 166 insertions(+), 122 deletions(-) create mode 100644 tools/lib/perf/Makefile create mode 100644 tools/lib/perf/mmap.c create mode 100644 tools/lib/perf/mmap.h
tools/Makefile +5 -1
@@ -34,7 +34,7 @@ export BASIC_CFLAGS PERF_TOP_DIR := $(CURDIR) export PERF_TOP_DIR -perf: libparsevent lklib .FORCE +perf: libparsevent lklib lkperflib .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) libparsevent: .FORCE
@@ -43,9 +43,13 @@ libparsevent: .FORCE lklib: .FORCE $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) +lkperflib: .FORCE + $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) + clean: $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean .PHONY: clean .FORCE
tools/lib/perf/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +include ../../scripts/Makefile.lib + +# guard against environment variables +LIB_H= +LIB_OBJS= + +LIB_H += mmap.h + +LIB_OBJS += mmap.o + +LIBFILE = $(LIB_OUTPUT)lkperflib.a + +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) +EXTLIBS = -lpthread -lrt -lelf -lm +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS = $(LDFLAGS) + +RM = rm -f + +$(LIBFILE): $(LIB_OBJS) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) + +$(LIB_OBJS): $(LIB_H) + +%.o: %.c + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +%.s: %.c + $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $< +%.o: %.S + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< + +clean: + $(RM) $(LIB_OBJS) $(LIBFILE) + +.PHONY: clean
tools/lib/perf/mmap.c new file +95 -0
95 lines not on this page · raw message
tools/lib/perf/mmap.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef __PERF_MMAP_H +#define __PERF_MMAP_H + +struct mmap_data { +int counter; +void *base; +unsigned int mask; +unsigned int prev; +}; + +unsigned long mmap_read_head (struct mmap_data *md); +unsigned long mmap_read_all (struct mmap_data *,int , +void (*write_output)(void *,size_t )); + +#endif /* __PERF_MMAP_H */
tools/perf/Makefile +1 -1
@@ -328,7 +328,7 @@ export PERL_PATH LIB_FILE=$(OUTPUT)libperf.a -EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a +EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a $(LIB_OUTPUT)lkperflib.a LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/rbtree.h
tools/perf/builtin-record.c +9 -98
159 lines not on this page · raw message
tools/perf/builtin-top.c +6 -22
@@ -24,11 +24,8 @@#include "util/session.h" #include "util/symbol.h" #include "util/thread.h" -#include <lk/util.h> -#include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h" -#include <lk/cpumap.h> #include "util/debug.h"
@@ -52,6 +49,11 @@#include <sys/uio.h> #include <sys/mman.h> +#include <lk/util.h> +#include <lk/cpumap.h> +#include <perf/mmap.h> + +#include <linux/rbtree.h> #include <linux/unistd.h> #include <linux/types.h>
@@ -1082,24 +1084,6 @@ static void event__process_sample(const event_t *self, } } -struct mmap_data { -int counter; -void *base; -int mask; -unsigned int prev; -}; - -static unsigned int mmap_read_head (struct mmap_data *md) -{ -struct perf_event_mmap_page *pc = md->base; -int head; - - head = pc->data_head; -rmb (); - -return head; -} -static void perf_session__mmap_read_counter (struct perf_session *self,struct mmap_data *md) {
@@ -1117,7 +1101,7 @@ static void perf_session__mmap_read_counter(struct perf_session *self,* In either case, truncate and restart at head. */ diff = head - old; -if (diff > md->mask /2 || diff <0 ) { +if ((unsigned )diff > md->mask /2 || diff <0 ) {fprintf (stderr,"WARNING: failed to keep up with mmap data.\n" );/*
Signature · 1 line
1.7.3.1
PATCH 10/20 perf: Export util.ch into library
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is needed for sharing common functionality.
--- tools/lib/lk/Makefile | 1 + tools/lib/lk/cpumap.c | 1 + tools/lib/lk/util.c | 116 ++++++++++++++++++++++++++++++++++++++++ tools/lib/perf/Makefile | 1 + tools/lib/perf/util.h | 8 +++ tools/perf/Makefile | 1 - tools/perf/perf.h | 3 - tools/perf/util/parse-events.h | 1 + tools/perf/util/util.c | 116 ---------------------------------------- 9 files changed, 128 insertions(+), 120 deletions(-) create mode 100644 tools/lib/lk/util.c create mode 100644 tools/lib/perf/util.h delete mode 100644 tools/perf/util/util.c
tools/lib/lk/Makefile +1 -0
@@ -11,6 +11,7 @@ LIB_H += cpumap.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o +LIB_OBJS += util.o LIB_OBJS += cpumap.o LIB_OBJS += ctype.o
tools/lib/lk/cpumap.c +1 -0
@@ -1,4 +1,5 @@#include <lk/util.h> +#include <perf/util.h> #include <perf.h> #include "cpumap.h" #include <assert.h>
tools/lib/lk/util.c new file +116 -0
116 lines not on this page · raw message
tools/lib/perf/Makefile +1 -0
@@ -5,6 +5,7 @@ LIB_H= LIB_OBJS= LIB_H += mmap.h +LIB_H += util.h LIB_OBJS += mmap.o
tools/lib/perf/util.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __PERF_UTIL_H +#define __PERF_UTIL_H + +#define MAX_COUNTERS 256 +#define MAX_NR_CPUS 256 + +#endif /* __PERF_UTIL_H */ +
tools/perf/Makefile +0 -1
@@ -427,7 +427,6 @@ LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o -LIB_OBJS += $(OUTPUT)util/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
tools/perf/perf.h +0 -3
@@ -136,9 +136,6 @@ sys_perf_event_open(struct perf_event_attr *attr, group_fd, flags); } -#define MAX_COUNTERS 256 -#define MAX_NR_CPUS 256 -struct ip_callchain {u64 nr;u64 ips[0 ];
tools/perf/util/parse-events.h +1 -0
@@ -3,6 +3,7 @@/* * Parse symbolic events/counts passed in as options: */ +#include <perf/util.h> struct option ;
tools/perf/util/util.c deleted +0 -116
116 lines not on this page · raw message
Signature · 1 line
1.7.3.1
PATCH 11/20 perf: Move rbtree to library
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is generic code anyway and will be needed by other utils so move it to a generic library.
--- tools/lib/lk/Makefile | 5 +++++ tools/lib/lk/rbtree.h | 1 + tools/perf/Makefile | 6 ------ tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/callchain.h | 2 +- tools/perf/util/include/linux/rbtree.h | 1 - tools/perf/util/map.h | 2 +- tools/perf/util/session.h | 2 +- tools/perf/util/sort.h | 2 +- tools/perf/util/strlist.h | 2 +- tools/perf/util/symbol.h | 2 +- tools/perf/util/thread.h | 2 +- tools/perf/util/ui/browser.c | 2 +- tools/perf/util/ui/browsers/hists.c | 2 +- 18 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 tools/lib/lk/rbtree.h delete mode 100644 tools/perf/util/include/linux/rbtree.h
tools/lib/lk/Makefile +5 -0
@@ -8,12 +8,15 @@ LIB_H += debugfs.h LIB_H += util.h LIB_H += types.h LIB_H += cpumap.h +LIB_H += ../../../include/linux/rbtree.h +LIB_H += rbtree.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o LIB_OBJS += util.o LIB_OBJS += cpumap.o LIB_OBJS += ctype.o +LIB_OBJS += rbtree.o LIBFILE = $(LIB_OUTPUT)lklib.a
@@ -29,6 +32,8 @@ $(LIBFILE): $(LIB_OBJS) $(LIB_OBJS): $(LIB_H) +rbtree.o: ../../../lib/rbtree.c + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -I../../../include $< %.o: %.c $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< %.s: %.c
tools/lib/lk/rbtree.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../../include/linux/rbtree.h"
tools/perf/Makefile +0 -6
@@ -331,7 +331,6 @@ LIB_FILE=$(OUTPUT)libperf.a EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a $(LIB_OUTPUT)lkperflib.a LIB_H += ../../include/linux/perf_event.h -LIB_H += ../../include/linux/rbtree.h LIB_H += ../../include/linux/list.h LIB_H += ../../include/linux/hash.h LIB_H += ../../include/linux/stringify.h
@@ -344,7 +343,6 @@ LIB_H += util/include/linux/list.h LIB_H += util/include/linux/module.h LIB_H += util/include/linux/poison.h LIB_H += util/include/linux/prefetch.h -LIB_H += util/include/linux/rbtree.h LIB_H += util/include/linux/string.h LIB_H += util/include/linux/types.h LIB_H += util/include/asm/asm-offsets.h
@@ -398,7 +396,6 @@ LIB_OBJS += $(OUTPUT)util/levenshtein.o LIB_OBJS += $(OUTPUT)util/parse-options.o LIB_OBJS += $(OUTPUT)util/parse-events.o LIB_OBJS += $(OUTPUT)util/path.o -LIB_OBJS += $(OUTPUT)util/rbtree.o LIB_OBJS += $(OUTPUT)util/bitmap.o LIB_OBJS += $(OUTPUT)util/hweight.o LIB_OBJS += $(OUTPUT)util/run-command.o
@@ -958,9 +955,6 @@ $(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< -$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
tools/perf/builtin-annotate.c +1 -1
@@ -12,7 +12,7 @@#include "util/color.h" #include <linux/list.h> #include "util/cache.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "util/symbol.h" #include "perf.h"
tools/perf/builtin-kmem.c +1 -1
@@ -13,7 +13,7 @@#include "util/debug.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> struct alloc_stat ;typedef int (*sort_fn_t )(struct alloc_stat *,struct alloc_stat *);
tools/perf/builtin-report.c +1 -1
@@ -12,7 +12,7 @@#include "util/color.h" #include <linux/list.h> #include "util/cache.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "util/symbol.h" #include "util/callchain.h" #include "util/strlist.h"
tools/perf/builtin-timechart.c +1 -1
@@ -19,7 +19,7 @@#include "util/color.h" #include <linux/list.h> #include "util/cache.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "util/symbol.h" #include "util/callchain.h" #include "util/strlist.h"
tools/perf/builtin-top.c +1 -1
@@ -53,7 +53,7 @@#include <lk/cpumap.h> #include <perf/mmap.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <linux/unistd.h> #include <linux/types.h>
tools/perf/util/callchain.h +1 -1
@@ -3,7 +3,7 @@#include "../perf.h" #include <linux/list.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "event.h" #include "symbol.h"
tools/perf/util/include/linux/rbtree.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../../../include/linux/rbtree.h"
tools/perf/util/map.h +1 -1
@@ -3,7 +3,7 @@#include <linux/compiler.h> #include <linux/list.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <stdio.h> #include <stdbool.h> #include <lk/types.h>
tools/perf/util/session.h +1 -1
@@ -6,7 +6,7 @@#include "header.h" #include "symbol.h" #include "thread.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "../../../include/linux/perf_event.h" struct sample_queue ;
tools/perf/util/sort.h +1 -1
@@ -7,7 +7,7 @@#include "color.h" #include <linux/list.h> #include "cache.h" -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "symbol.h" #include "string.h" #include "callchain.h"
tools/perf/util/strlist.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_STRLIST_H#define __PERF_STRLIST_H -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <stdbool.h> struct str_node {
tools/perf/util/symbol.h +1 -1
@@ -6,7 +6,7 @@#include <stdint.h> #include "map.h" #include <linux/list.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <stdio.h> #ifdef HAVE_CPLUS_DEMANGLE
tools/perf/util/thread.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_THREAD_H#define __PERF_THREAD_H -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <unistd.h> #include "symbol.h"
tools/perf/util/ui/browser.c +1 -1
@@ -12,7 +12,7 @@#endif #include <slang.h> #include <linux/list.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include <stdlib.h> #include <sys/ttydefaults.h> #include "browser.h"
tools/perf/util/ui/browsers/hists.c +1 -1
@@ -5,7 +5,7 @@#include <stdlib.h> #include <string.h> #include <newt.h> -#include <linux/rbtree.h> +#include <lk/rbtree.h> #include "../../hist.h" #include "../../pstack.h"
Signature · 1 line
1.7.3.1
PATCH 12/20 perf: Export generic kernel utils to library
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Move all bitops-related stuff together.
--- tools/lib/lk/Makefile | 5 ++ tools/lib/lk/bitmap.c | 21 ++++++ tools/lib/lk/bitmap.h | 35 ++++++++++ tools/lib/lk/bitops.h | 30 +++++++++ tools/lib/lk/hweight.c | 31 +++++++++ tools/lib/lk/kernel.h | 113 ++++++++++++++++++++++++++++++++ tools/perf/Makefile | 6 -- tools/perf/util/bitmap.c | 21 ------ tools/perf/util/build-id.c | 2 +- tools/perf/util/event.h | 1 + tools/perf/util/header.c | 2 +- tools/perf/util/header.h | 2 +- tools/perf/util/hweight.c | 31 --------- tools/perf/util/include/asm/hweight.h | 8 -- tools/perf/util/include/linux/bitmap.h | 35 ---------- tools/perf/util/include/linux/bitops.h | 27 -------- tools/perf/util/include/linux/kernel.h | 111 ------------------------------- tools/perf/util/map.h | 4 +- tools/perf/util/parse-options.h | 2 +- tools/perf/util/pstack.c | 2 +- tools/perf/util/session.c | 2 +- tools/perf/util/strlist.h | 1 + tools/perf/util/trace-event-info.c | 2 +- 23 files changed, 247 insertions(+), 247 deletions(-) create mode 100644 tools/lib/lk/bitmap.c create mode 100644 tools/lib/lk/bitmap.h create mode 100644 tools/lib/lk/bitops.h create mode 100644 tools/lib/lk/hweight.c create mode 100644 tools/lib/lk/kernel.h delete mode 100644 tools/perf/util/bitmap.c delete mode 100644 tools/perf/util/hweight.c delete mode 100644 tools/perf/util/include/asm/hweight.h delete mode 100644 tools/perf/util/include/linux/bitmap.h delete mode 100644 tools/perf/util/include/linux/bitops.h delete mode 100644 tools/perf/util/include/linux/kernel.h
tools/lib/lk/Makefile +5 -0
@@ -10,6 +10,9 @@ LIB_H += types.h LIB_H += cpumap.h LIB_H += ../../../include/linux/rbtree.h LIB_H += rbtree.h +LIB_H += bitops.h +LIB_H += bitmap.h +LIB_H += kernel.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o
@@ -17,6 +20,8 @@ LIB_OBJS += util.o LIB_OBJS += cpumap.o LIB_OBJS += ctype.o LIB_OBJS += rbtree.o +LIB_OBJS += hweight.o +LIB_OBJS += bitmap.o LIBFILE = $(LIB_OUTPUT)lklib.a
tools/lib/lk/bitmap.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* From lib/bitmap.c +* Helper functions for bitmap.h. +* +* This source code is licensed under the GNU General Public License, +* Version 2. See the file COPYING for more details. +*/ +#include "bitmap.h" + +int __bitmap_weight (const unsigned long *bitmap,int bits) +{ +int k, w =0 , lim = bits/BITS_PER_LONG ; + +for (k =0 ; k < lim; k++) + w +=hweight_long (bitmap[k]); + +if (bits %BITS_PER_LONG ) + w +=hweight_long (bitmap[k] &BITMAP_LAST_WORD_MASK (bits)); + +return w; +}
tools/lib/lk/bitmap.h new file +35 -0
@@ -0,0 +1,35 @@ +#ifndef __LK_BITMAP_H +#define __LK_BITMAP_H + +#include <string.h> +#include <lk/bitops.h> + +int __bitmap_weight (const unsigned long *bitmap,int bits); + +#define BITMAP_LAST_WORD_MASK (nbits) \ +( \ + ((nbits) % BITS_PER_LONG) ? \ + (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ +) + +#define small_const_nbits (nbits) \ + (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) + +static inline void bitmap_zero (unsigned long *dst,int nbits) +{ +if (small_const_nbits (nbits)) + *dst =0UL ; +else { +int len =BITS_TO_LONGS (nbits) *sizeof (unsigned long ); +memset (dst,0 , len); + } +} + +static inline int bitmap_weight (const unsigned long *src,int nbits) +{ +if (small_const_nbits (nbits)) +return hweight_long (*src &BITMAP_LAST_WORD_MASK (nbits)); +return __bitmap_weight (src, nbits); +} + +#endif /* __LK_BITMAP_H */
tools/lib/lk/bitops.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef __LK_BITOPS_H +#define __LK_BITOPS_H + +#include "kernel.h" +#include "types.h" + +#define BITS_PER_LONG __WORDSIZE +#define BITS_PER_BYTE 8 +#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + +extern unsigned int hweight32 (unsigned int w); +extern unsigned long hweight64 (u64 w); + +static inline void set_bit (int nr,unsigned long *addr) +{ + addr[nr /BITS_PER_LONG ] |=1UL << (nr %BITS_PER_LONG ); +} + +static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) +{ +return ((1UL << (nr %BITS_PER_LONG )) & + (((unsigned long *)addr)[nr /BITS_PER_LONG ])) !=0 ; +} + +static inline unsigned long hweight_long (unsigned long w) +{ +return sizeof (w) ==4 ?hweight32 (w) :hweight64 (w); +} + +#endif
tools/lib/lk/hweight.c new file +31 -0
@@ -0,0 +1,31 @@ +#include "bitops.h" + +/** +* hweightN - returns the hamming weight of a N-bit word +* @x: the word to weigh +* +* The Hamming Weight of a number is the total number of bits set in it. +*/ + +unsigned int hweight32 (unsigned int w) +{ +unsigned int res = w - ((w >>1 ) &0x55555555 ); + res = (res &0x33333333 ) + ((res >>2 ) &0x33333333 ); + res = (res + (res >>4 )) &0x0F0F0F0F ; + res = res + (res >>8 ); +return (res + (res >>16 )) &0x000000FF ; +} + +unsigned long hweight64 (u64 w) +{ +#if BITS_PER_LONG ==32 +return hweight32 ((unsigned int )(w >>32 )) +hweight32 ((unsigned int )w); +#elif BITS_PER_LONG ==64 +u64 res = w - ((w >>1 ) &0x5555555555555555ul ); + res = (res &0x3333333333333333ul ) + ((res >>2 ) &0x3333333333333333ul ); + res = (res + (res >>4 )) &0x0F0F0F0F0F0F0F0Ful ; + res = res + (res >>8 ); + res = res + (res >>16 ); +return (res + (res >>32 )) &0x00000000000000FFul ; +#endif +}
tools/lib/lk/kernel.h new file +113 -0
113 lines not on this page · raw message
tools/perf/Makefile +0 -6
@@ -334,11 +334,8 @@ LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/list.h LIB_H += ../../include/linux/hash.h LIB_H += ../../include/linux/stringify.h -LIB_H += util/include/linux/bitmap.h -LIB_H += util/include/linux/bitops.h LIB_H += util/include/linux/compiler.h LIB_H += util/include/linux/ctype.h -LIB_H += util/include/linux/kernel.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/module.h LIB_H += util/include/linux/poison.h
@@ -348,7 +345,6 @@ LIB_H += util/include/linux/types.h LIB_H += util/include/asm/asm-offsets.h LIB_H += util/include/asm/bug.h LIB_H += util/include/asm/byteorder.h -LIB_H += util/include/asm/hweight.h LIB_H += util/include/asm/swab.h LIB_H += util/include/asm/system.h LIB_H += util/include/asm/uaccess.h
@@ -396,8 +392,6 @@ LIB_OBJS += $(OUTPUT)util/levenshtein.o LIB_OBJS += $(OUTPUT)util/parse-options.o LIB_OBJS += $(OUTPUT)util/parse-events.o LIB_OBJS += $(OUTPUT)util/path.o -LIB_OBJS += $(OUTPUT)util/bitmap.o -LIB_OBJS += $(OUTPUT)util/hweight.o LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o
tools/perf/util/bitmap.c deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* From lib/bitmap.c -* Helper functions for bitmap.h. -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. -*/ -#include <linux/bitmap.h> - -int __bitmap_weight (const unsigned long *bitmap,int bits) -{ -int k, w =0 , lim = bits/BITS_PER_LONG ; - -for (k =0 ; k < lim; k++) - w +=hweight_long (bitmap[k]); - -if (bits %BITS_PER_LONG ) - w +=hweight_long (bitmap[k] &BITMAP_LAST_WORD_MASK (bits)); - -return w; -}
tools/perf/util/build-id.c +1 -1
@@ -11,7 +11,7 @@#include "build-id.h" #include "event.h" #include "symbol.h" -#include <linux/kernel.h> +#include <lk/kernel.h> #include "debug.h" static int build_id__mark_dso_hit (event_t *event,struct perf_session *session)
tools/perf/util/event.h +1 -0
@@ -2,6 +2,7 @@#define __PERF_RECORD_H#include <limits.h> +#include <lk/kernel.h> #include "../perf.h" #include "map.h"
tools/perf/util/header.c +1 -1
@@ -6,7 +6,7 @@#include <stdio.h> #include <stdlib.h> #include <linux/list.h> -#include <linux/kernel.h> +#include <lk/kernel.h> #include <lk/util.h> #include "header.h"
tools/perf/util/header.h +1 -1
@@ -7,7 +7,7 @@#include <lk/types.h> #include "event.h" -#include <linux/bitmap.h> +#include <lk/bitmap.h> struct perf_header_attr {struct perf_event_attr attr;
tools/perf/util/hweight.c deleted +0 -31
@@ -1,31 +0,0 @@ -#include <linux/bitops.h> - -/** -* hweightN - returns the hamming weight of a N-bit word -* @x: the word to weigh -* -* The Hamming Weight of a number is the total number of bits set in it. -*/ - -unsigned int hweight32 (unsigned int w) -{ -unsigned int res = w - ((w >>1 ) &0x55555555 ); - res = (res &0x33333333 ) + ((res >>2 ) &0x33333333 ); - res = (res + (res >>4 )) &0x0F0F0F0F ; - res = res + (res >>8 ); -return (res + (res >>16 )) &0x000000FF ; -} - -unsigned long hweight64 (__u64 w) -{ -#if BITS_PER_LONG ==32 -return hweight32 ((unsigned int )(w >>32 )) +hweight32 ((unsigned int )w); -#elif BITS_PER_LONG ==64 -__u64 res = w - ((w >>1 ) &0x5555555555555555ul ); - res = (res &0x3333333333333333ul ) + ((res >>2 ) &0x3333333333333333ul ); - res = (res + (res >>4 )) &0x0F0F0F0F0F0F0F0Ful ; - res = res + (res >>8 ); - res = res + (res >>16 ); -return (res + (res >>32 )) &0x00000000000000FFul ; -#endif -}
tools/perf/util/include/asm/hweight.h deleted +0 -8
@@ -1,8 +0,0 @@ -#ifndef PERF_HWEIGHT_H -#define PERF_HWEIGHT_H - -#include <linux/types.h> -unsigned int hweight32 (unsigned int w); -unsigned long hweight64 (__u64 w); - -#endif /* PERF_HWEIGHT_H */
tools/perf/util/include/linux/bitmap.h deleted +0 -35
@@ -1,35 +0,0 @@ -#ifndef _PERF_BITOPS_H -#define _PERF_BITOPS_H - -#include <string.h> -#include <linux/bitops.h> - -int __bitmap_weight (const unsigned long *bitmap,int bits); - -#define BITMAP_LAST_WORD_MASK (nbits) \ -( \ - ((nbits) % BITS_PER_LONG) ? \ - (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ -) - -#define small_const_nbits (nbits) \ - (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) - -static inline void bitmap_zero (unsigned long *dst,int nbits) -{ -if (small_const_nbits (nbits)) - *dst =0UL ; -else { -int len =BITS_TO_LONGS (nbits) *sizeof (unsigned long ); -memset (dst,0 , len); - } -} - -static inline int bitmap_weight (const unsigned long *src,int nbits) -{ -if (small_const_nbits (nbits)) -return hweight_long (*src &BITMAP_LAST_WORD_MASK (nbits)); -return __bitmap_weight (src, nbits); -} - -#endif /* _PERF_BITOPS_H */
tools/perf/util/include/linux/bitops.h deleted +0 -27
@@ -1,27 +0,0 @@ -#ifndef _PERF_LINUX_BITOPS_H_ -#define _PERF_LINUX_BITOPS_H_ - -#include <linux/kernel.h> -#include <asm/hweight.h> - -#define BITS_PER_LONG __WORDSIZE -#define BITS_PER_BYTE 8 -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) - -static inline void set_bit (int nr,unsigned long *addr) -{ - addr[nr /BITS_PER_LONG ] |=1UL << (nr %BITS_PER_LONG ); -} - -static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) -{ -return ((1UL << (nr %BITS_PER_LONG )) & - (((unsigned long *)addr)[nr /BITS_PER_LONG ])) !=0 ; -} - -static inline unsigned long hweight_long (unsigned long w) -{ -return sizeof (w) ==4 ?hweight32 (w) :hweight64 (w); -} - -#endif
tools/perf/util/include/linux/kernel.h deleted +0 -111
111 lines not on this page · raw message
tools/perf/util/map.h +3 -1
@@ -3,10 +3,12 @@#include <linux/compiler.h> #include <linux/list.h> -#include <lk/rbtree.h> #include <stdio.h> #include <stdbool.h> +#include <sys/types.h> #include <lk/types.h> +#include <lk/rbtree.h> +#include <lk/kernel.h> enum map_type {MAP__FUNCTION =0 ,
tools/perf/util/parse-options.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_PARSE_OPTIONS_H#define __PERF_PARSE_OPTIONS_H -#include <linux/kernel.h> +#include <lk/kernel.h> #include <stdbool.h> enum parse_opt_type {
tools/perf/util/pstack.c +1 -1
@@ -6,7 +6,7 @@#include <lk/util.h> #include "pstack.h" -#include <linux/kernel.h> +#include <lk/kernel.h> #include <stdlib.h> struct pstack {
tools/perf/util/session.c +1 -1
@@ -1,6 +1,6 @@#define _FILE_OFFSET_BITS 64 -#include <linux/kernel.h> +#include <lk/kernel.h> #include <byteswap.h> #include <unistd.h>
tools/perf/util/strlist.h +1 -0
@@ -1,6 +1,7 @@#ifndef __PERF_STRLIST_H#define __PERF_STRLIST_H +#include <lk/kernel.h> #include <lk/rbtree.h> #include <stdbool.h>
tools/perf/util/trace-event-info.c +1 -1
@@ -34,7 +34,7 @@#include <ctype.h> #include <errno.h> #include <stdbool.h> -#include <linux/kernel.h> +#include <lk/kernel.h> #include <lk/debugfs.h>
Signature · 1 line
1.7.3.1
PATCH 13/20 perf: Export compiler.h to the generic library
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Sucked in by other utils later.
--- tools/lib/lk/Makefile | 1 + tools/lib/lk/compiler.h | 12 ++++++++++++ tools/perf/Makefile | 1 - tools/perf/bench/bench.h | 2 +- tools/perf/util/cache.h | 2 +- tools/perf/util/include/linux/compiler.h | 12 ------------ tools/perf/util/map.h | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 tools/lib/lk/compiler.h delete mode 100644 tools/perf/util/include/linux/compiler.h
tools/lib/lk/Makefile +1 -0
@@ -13,6 +13,7 @@ LIB_H += rbtree.h LIB_H += bitops.h LIB_H += bitmap.h LIB_H += kernel.h +LIB_H += compiler.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o
tools/lib/lk/compiler.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __LK_COMPILER_H +#define __LK_COMPILER_H + +#ifndef __always_inline +#define __always_inline inline +#endif +#define __user +#define __attribute_const__ + +#define __used __attribute__((__unused__)) + +#endif /* __LK_COMPILER_H */
tools/perf/Makefile +0 -1
@@ -334,7 +334,6 @@ LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/list.h LIB_H += ../../include/linux/hash.h LIB_H += ../../include/linux/stringify.h -LIB_H += util/include/linux/compiler.h LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/module.h
tools/perf/bench/bench.h +1 -1
@@ -1,7 +1,7 @@#ifndef BENCH_H #define BENCH_H -#include <linux/compiler.h> +#include <lk/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);
tools/perf/util/cache.h +1 -1
@@ -5,7 +5,7 @@#include <lk/util.h> #include "strbuf.h" #include "../perf.h" -#include <linux/compiler.h> +#include <lk/compiler.h> #define CMD_EXEC_PATH "--exec-path"#define CMD_PERF_DIR "--perf-dir="
tools/perf/util/include/linux/compiler.h deleted +0 -12
@@ -1,12 +0,0 @@ -#ifndef _PERF_LINUX_COMPILER_H_ -#define _PERF_LINUX_COMPILER_H_ - -#ifndef __always_inline -#define __always_inline inline -#endif -#define __user -#define __attribute_const__ - -#define __used __attribute__((__unused__)) - -#endif
tools/perf/util/map.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_MAP_H#define __PERF_MAP_H -#include <linux/compiler.h> +#include <lk/compiler.h> #include <linux/list.h> #include <stdio.h> #include <stdbool.h>
Signature · 1 line
1.7.3.1
PATCH 14/20 perf: Export color.ch and config.ch
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Will be needed by stuff exported later, move perf-wide defines to perf/config.ch temporarily.
--- tools/lib/lk/compiler.h | 2 + tools/lib/perf/Makefile | 5 + tools/lib/perf/color.c | 324 ++++++++++++++++++++++++++ tools/lib/perf/color.h | 51 ++++ tools/lib/perf/config.c | 502 ++++++++++++++++++++++++++++++++++++++++ tools/lib/perf/config.h | 31 +++ tools/lib/perf/path.c | 156 +++++++++++++ tools/lib/trace/Makefile | 2 + tools/lib/trace/parse-events.c | 11 +- tools/lib/trace/parse-events.h | 8 +- tools/lib/trace/parse-utils.c | 3 +- tools/perf/Makefile | 8 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-help.c | 2 + tools/perf/builtin-report.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/perf.c | 1 + tools/perf/util/abspath.c | 1 + tools/perf/util/alias.c | 1 + tools/perf/util/cache.h | 19 -- tools/perf/util/color.c | 324 -------------------------- tools/perf/util/color.h | 46 ---- tools/perf/util/config.c | 492 --------------------------------------- tools/perf/util/debug.c | 2 +- tools/perf/util/environment.c | 1 - tools/perf/util/exec_cmd.c | 10 + tools/perf/util/help.c | 2 + tools/perf/util/pager.c | 15 +- tools/perf/util/path.c | 156 ------------- tools/perf/util/probe-event.c | 2 +- tools/perf/util/sort.h | 2 +- tools/perf/util/ui/browser.c | 2 +- 33 files changed, 1110 insertions(+), 1079 deletions(-) create mode 100644 tools/lib/perf/color.c create mode 100644 tools/lib/perf/color.h create mode 100644 tools/lib/perf/config.c create mode 100644 tools/lib/perf/config.h create mode 100644 tools/lib/perf/path.c delete mode 100644 tools/perf/util/color.c delete mode 100644 tools/perf/util/color.h delete mode 100644 tools/perf/util/config.c delete mode 100644 tools/perf/util/path.c
tools/lib/lk/compiler.h +2 -0
@@ -1,6 +1,8 @@#ifndef __LK_COMPILER_H#define __LK_COMPILER_H +#define __weak __attribute__((weak)) +#ifndef __always_inline#define __always_inline inline#endif
tools/lib/perf/Makefile +5 -0
@@ -6,8 +6,13 @@ LIB_OBJS= LIB_H += mmap.h LIB_H += util.h +LIB_H += color.h +LIB_H += config.h LIB_OBJS += mmap.o +LIB_OBJS += color.o +LIB_OBJS += config.o +LIB_OBJS += path.o LIBFILE = $(LIB_OUTPUT)lkperflib.a
tools/lib/perf/color.c new file +324 -0
324 lines not on this page · raw message
tools/lib/perf/color.h new file +51 -0
51 lines not on this page · raw message
tools/lib/perf/config.c new file +502 -0
502 lines not on this page · raw message
tools/lib/perf/config.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef __PERF_CONFIG_H +#define __PERF_CONFIG_H + +#include <string.h> +#include <sys/types.h> + +#include <lk/util.h> + +extern int spawned_pager; + +typedef int (*config_fn_t )(const char *,const char *,void *); +extern int perf_default_config (const char *,const char *,void *); +extern int perf_config (config_fn_t fn,void *); +extern int perf_config_int (const char *,const char *); +extern int perf_config_bool (const char *,const char *); +extern int config_error_nonbool (const char *); +extern const char *perf_config_dirname (const char *,const char *); + +extern int pager_in_use (void ); +extern int pager_use_color; + +extern char *mkpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); +extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); + +const char *perf_etc_perfconfig (void ); + +extern size_t strlcpy (char *dest,const char *src,size_t size); +extern char *strip_path_suffix (const char *path,const char *suffix); +extern char *perf_path (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); + +#endif /* __PERF_CONFIG_H */
tools/lib/perf/path.c new file +156 -0
156 lines not on this page · raw message
tools/lib/trace/Makefile +2 -0
@@ -42,6 +42,8 @@ PEVENT_LIB_OBJS += parse-filter.o PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += trace-seq.o +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + $(OUTPUT)%.o: %.c $(QUIET_CC)$(CC) -g -o $@ -c $(ALL_CFLAGS) $<
tools/lib/trace/parse-events.c +2 -9
@@ -24,7 +24,6 @@* Frederic Weisbecker gave his permission to relicense the code to * the Lesser General Public License. */ -#define _GNU_SOURCE#include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -95,13 +94,7 @@ void pevent_buffer_init(const char *buf, unsigned long long size)init_input_buf (buf, size); } -void breakpoint (void ) -{ -static int x; - x++; -} - -struct print_arg *alloc_arg (void ) +static struct print_arg *alloc_arg (void ) {struct print_arg *arg;
@@ -164,7 +157,7 @@ static int cmdline_init(struct pevent *pevent)return 0 ; } -static char *find_cmdline (struct pevent *pevent,int pid) +static const char *find_cmdline (struct pevent *pevent,int pid) {const struct cmdline *comm;struct cmdline key;
tools/lib/trace/parse-events.h +5 -3
@@ -24,6 +24,8 @@#include <stdarg.h> #include <regex.h> +#include <lk/compiler.h> +#ifndef __unused#define __unused __attribute__ ((unused))#endif
@@ -359,9 +361,9 @@ void __die(const char *fmt, ...);void __warning (const char *fmt, ...);void __pr_stat (const char *fmt, ...); -void __vdie (const char *fmt, ...); -void __vwarning (const char *fmt, ...); -void __vpr_stat (const char *fmt, ...); +void __vdie (const char *fmt,va_list ap); +void __vwarning (const char *fmt,va_list ap); +void __vpr_stat (const char *fmt,va_list ap);static inline unsigned short __data2host2 (struct pevent *pevent,unsigned short data)
tools/lib/trace/parse-utils.c +2 -1
@@ -3,8 +3,9 @@#include <string.h> #include <stdarg.h> #include <errno.h> +#include <lk/compiler.h> -#define __weak __attribute__((weak)) +#include "parse-events.h" void __vdie (const char *fmt,va_list ap) {
tools/perf/Makefile +1 -7
@@ -369,7 +369,6 @@ LIB_H += util/svghelper.h LIB_H += util/run-command.h LIB_H += util/sigchain.h LIB_H += util/symbol.h -LIB_H += util/color.h LIB_H += util/values.h LIB_H += util/sort.h LIB_H += util/hist.h
@@ -382,7 +381,6 @@ LIB_H += util/pstack.h LIB_OBJS += $(OUTPUT)util/abspath.o LIB_OBJS += $(OUTPUT)util/alias.o LIB_OBJS += $(OUTPUT)util/build-id.o -LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o
@@ -390,7 +388,6 @@ LIB_OBJS += $(OUTPUT)util/help.o LIB_OBJS += $(OUTPUT)util/levenshtein.o LIB_OBJS += $(OUTPUT)util/parse-options.o LIB_OBJS += $(OUTPUT)util/parse-events.o -LIB_OBJS += $(OUTPUT)util/path.o LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o
@@ -399,7 +396,6 @@ LIB_OBJS += $(OUTPUT)util/strlist.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/symbol.o -LIB_OBJS += $(OUTPUT)util/color.o LIB_OBJS += $(OUTPUT)util/pager.o LIB_OBJS += $(OUTPUT)util/header.o LIB_OBJS += $(OUTPUT)util/callchain.o
@@ -928,14 +924,12 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \ '-DBINDIR="$(bindir_relative_SQ)"' \ '-DPREFIX="$(prefix_SQ)"' \ + '-DETC_PERFCONFIG="$(ETC_PERFCONFIG_SQ)"' \ $< $(OUTPUT)builtin-init-db.o: builtin-init-db.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_PERF_TEMPLATE_DIR='"$(template_dir_SQ)"' $< -$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - $(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
tools/perf/builtin-annotate.c +1 -1
@@ -9,7 +9,7 @@#include <lk/util.h> -#include "util/color.h" +#include <perf/color.h> #include <linux/list.h> #include "util/cache.h" #include <lk/rbtree.h>
tools/perf/builtin-help.c +2 -0
@@ -3,6 +3,8 @@* * Builtin help command */ +#include <perf/config.h> +#include "perf.h" #include "util/cache.h" #include "builtin.h"
tools/perf/builtin-report.c +1 -1
@@ -9,7 +9,7 @@#include <lk/util.h> -#include "util/color.h" +#include <perf/color.h> #include <linux/list.h> #include "util/cache.h" #include <lk/rbtree.h>
tools/perf/builtin-timechart.c +1 -1
@@ -16,7 +16,7 @@#include <lk/util.h> -#include "util/color.h" +#include <perf/color.h> #include <linux/list.h> #include "util/cache.h" #include <lk/rbtree.h>
tools/perf/builtin-top.c +1 -1
@@ -20,7 +20,7 @@#include "perf.h" -#include "util/color.h" +#include <perf/color.h> #include "util/session.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/perf.c +1 -0
@@ -7,6 +7,7 @@* perf top, perf record, perf report, etc.) are started. */ #include <lk/debugfs.h> +#include <perf/config.h> #include "builtin.h" #include "util/exec_cmd.h"
tools/perf/util/abspath.c +1 -0
@@ -1,3 +1,4 @@ +#include <perf/config.h> #include "cache.h" static const char *get_pwd_cwd (void )
tools/perf/util/alias.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include <perf/config.h> static const char *alias_key;static char *alias_val;
tools/perf/util/cache.h +0 -19
@@ -17,19 +17,9 @@#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" -typedef int (*config_fn_t )(const char *,const char *,void *); -extern int perf_default_config (const char *,const char *,void *); -extern int perf_config (config_fn_t fn,void *); -extern int perf_config_int (const char *,const char *); -extern int perf_config_bool (const char *,const char *); -extern int config_error_nonbool (const char *); -extern const char *perf_config_dirname (const char *,const char *); -/* pager.c */ extern void setup_pager (void );extern const char *pager_program; -extern int pager_in_use (void ); -extern int pager_use_color;extern int use_browser;
@@ -74,14 +64,5 @@ static inline int is_absolute_path(const char *path) }const char *make_nonrelative_path (const char *path); -char *strip_path_suffix (const char *path,const char *suffix); - -extern char *mkpath (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -extern char *perf_path (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); - -extern char *perf_pathdup (const char *fmt, ...) - __attribute__((format (printf,1 ,2 ))); - -extern size_t strlcpy (char *dest,const char *src,size_t size);#endif /* __PERF_CACHE_H */
tools/perf/util/color.c deleted +0 -324
324 lines not on this page · raw message
tools/perf/util/color.h deleted +0 -46
46 lines not on this page · raw message
tools/perf/util/config.c deleted +0 -492
492 lines not on this page · raw message
tools/perf/util/debug.c +1 -1
@@ -7,7 +7,7 @@#include <stdio.h> #include "cache.h" -#include "color.h" +#include <perf/color.h> #include "event.h" #include "debug.h" #include <lk/util.h>
tools/perf/util/environment.c +0 -1
@@ -6,4 +6,3 @@#include "cache.h" const char *pager_program; -int pager_use_color =1 ;
tools/perf/util/exec_cmd.c +10 -0
@@ -2,6 +2,8 @@#include "exec_cmd.h" #include "quote.h" +#include <perf/config.h> +#include <string.h> #define MAX_ARGS 32
@@ -165,3 +167,11 @@ int execl_perf_cmd(const char *cmd,...) argv[argc] =NULL ;return execv_perf_cmd (argv); } + +const char *perf_etc_perfconfig (void ) +{ +static const char *system_wide; +if (!system_wide) + system_wide =system_path (ETC_PERFCONFIG ); +return system_wide; +}
tools/perf/util/help.c +2 -0
@@ -4,6 +4,8 @@#include "levenshtein.h" #include "help.h" +#include <perf/config.h> +void add_cmdname (struct cmdnames *cmds,const char *name,size_t len) {struct cmdname *ent =malloc (sizeof (*ent) + len +1 );
tools/perf/util/pager.c +2 -13
@@ -2,13 +2,13 @@#include "run-command.h" #include "sigchain.h" +#include <perf/config.h> +/* * This is split up from the rest of git so that we can do * something different on Windows. */ -static int spawned_pager; -static void pager_preexec (void ) {/*
@@ -83,14 +83,3 @@ void setup_pager(void)sigchain_push_common (wait_for_pager_signal);atexit (wait_for_pager); } - -int pager_in_use (void ) -{ -const char *env; - -if (spawned_pager) -return 1 ; - - env =getenv ("PERF_PAGER_IN_USE" ); -return env ?perf_config_bool ("PERF_PAGER_IN_USE" , env) :0 ; -}
tools/perf/util/path.c deleted +0 -156
156 lines not on this page · raw message
tools/perf/util/probe-event.c +1 -1
@@ -41,7 +41,7 @@#include "strlist.h" #include "debug.h" #include "cache.h" -#include "color.h" +#include <perf/color.h> #include "symbol.h" #include "thread.h" #include "trace-event.h" /* For __unused */
tools/perf/util/sort.h +1 -1
@@ -4,7 +4,7 @@#include <lk/util.h> -#include "color.h" +#include <perf/color.h> #include <linux/list.h> #include "cache.h" #include <lk/rbtree.h>
tools/perf/util/ui/browser.c +1 -1
@@ -17,7 +17,7 @@#include <sys/ttydefaults.h> #include "browser.h" #include "helpline.h" -#include "../color.h" +#include <perf/color.h> #include "../util.h" #if SLANG_VERSION <20104
Signature · 1 line
1.7.3.1
PATCH 15/20 perf: Export strlist.ch
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Needed by other perf utils like map.c and symbol.c
--- tools/lib/lk/Makefile | 2 + tools/lib/lk/strlist.c | 200 ++++++++++++++++++++++++++++++++++++ tools/lib/lk/strlist.h | 79 ++++++++++++++ tools/perf/Makefile | 2 - tools/perf/builtin-buildid-cache.c | 2 +- tools/perf/builtin-probe.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/util/event.c | 2 +- tools/perf/util/probe-event.c | 2 +- tools/perf/util/probe-event.h | 2 +- tools/perf/util/sort.h | 2 +- tools/perf/util/strlist.c | 200 ------------------------------------ tools/perf/util/strlist.h | 79 -------------- tools/perf/util/symbol.c | 2 +- 15 files changed, 290 insertions(+), 290 deletions(-) create mode 100644 tools/lib/lk/strlist.c create mode 100644 tools/lib/lk/strlist.h delete mode 100644 tools/perf/util/strlist.c delete mode 100644 tools/perf/util/strlist.h
tools/lib/lk/Makefile +2 -0
@@ -14,6 +14,7 @@ LIB_H += bitops.h LIB_H += bitmap.h LIB_H += kernel.h LIB_H += compiler.h +LIB_H += strlist.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o
@@ -23,6 +24,7 @@ LIB_OBJS += ctype.o LIB_OBJS += rbtree.o LIB_OBJS += hweight.o LIB_OBJS += bitmap.o +LIB_OBJS += strlist.o LIBFILE = $(LIB_OUTPUT)lklib.a
tools/lib/lk/strlist.c new file +200 -0
200 lines not on this page · raw message
tools/lib/lk/strlist.h new file +79 -0
79 lines not on this page · raw message
tools/perf/Makefile +0 -2
@@ -364,7 +364,6 @@ LIB_H += util/header.h LIB_H += util/help.h LIB_H += util/session.h LIB_H += util/strbuf.h -LIB_H += util/strlist.h LIB_H += util/svghelper.h LIB_H += util/run-command.h LIB_H += util/sigchain.h
@@ -392,7 +391,6 @@ LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o LIB_OBJS += $(OUTPUT)util/string.o -LIB_OBJS += $(OUTPUT)util/strlist.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/symbol.o
tools/perf/builtin-buildid-cache.c +1 -1
@@ -12,7 +12,7 @@#include "util/debug.h" #include "util/header.h" #include "util/parse-options.h" -#include "util/strlist.h" +#include <lk/strlist.h> #include "util/symbol.h" static char const *add_name_list_str, *remove_name_list_str;
tools/perf/builtin-probe.c +1 -1
@@ -37,7 +37,7 @@#include "perf.h" #include "builtin.h" -#include "util/strlist.h" +#include <lk/strlist.h> #include "util/symbol.h" #include "util/debug.h" #include "util/parse-options.h"
tools/perf/builtin-report.c +1 -1
@@ -15,7 +15,7 @@#include <lk/rbtree.h> #include "util/symbol.h" #include "util/callchain.h" -#include "util/strlist.h" +#include <lk/strlist.h> #include "util/values.h" #include "perf.h"
tools/perf/builtin-timechart.c +1 -1
@@ -22,7 +22,7 @@#include <lk/rbtree.h> #include "util/symbol.h" #include "util/callchain.h" -#include "util/strlist.h" +#include <lk/strlist.h> #include "perf.h" #include "util/header.h"
tools/perf/util/event.c +1 -1
@@ -4,7 +4,7 @@#include "session.h" #include "sort.h" #include "string.h" -#include "strlist.h" +#include <lk/strlist.h> #include "thread.h" const char *event__name[] = {
tools/perf/util/probe-event.c +1 -1
@@ -38,7 +38,7 @@#include "event.h" #include "string.h" -#include "strlist.h" +#include <lk/strlist.h> #include "debug.h" #include "cache.h" #include <perf/color.h>
tools/perf/util/probe-event.h +1 -1
@@ -2,7 +2,7 @@#define _PROBE_EVENT_H#include <stdbool.h> -#include "strlist.h" +#include <lk/strlist.h> extern bool probe_event_dry_run;
tools/perf/util/sort.h +1 -1
@@ -11,7 +11,7 @@#include "symbol.h" #include "string.h" #include "callchain.h" -#include "strlist.h" +#include <lk/strlist.h> #include "values.h" #include "../perf.h"
tools/perf/util/strlist.c deleted +0 -200
200 lines not on this page · raw message
tools/perf/util/strlist.h deleted +0 -79
79 lines not on this page · raw message
tools/perf/util/symbol.c +1 -1
@@ -14,7 +14,7 @@#include "build-id.h" #include "debug.h" #include "symbol.h" -#include "strlist.h" +#include <lk/strlist.h> #include <libelf.h> #include <gelf.h>
Signature · 1 line
1.7.3.1
PATCH 16/20 perf: Export map.ch and symbol.ch
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Those suck in a bunch of other stuff. Put objects shared between perf/util/ and lib/perf/ in lib/perf/config.ch for now, will go in lib/perf/shared.ch later.
--- tools/lib/lk/util.h | 2 + tools/lib/perf/Makefile | 4 + tools/lib/perf/config.c | 3 + tools/lib/perf/config.h | 1 + tools/lib/perf/map.c | 682 +++++++++ tools/lib/perf/map.h | 229 +++ tools/lib/perf/symbol.c | 2466 ++++++++++++++++++++++++++++++++ tools/lib/perf/symbol.h | 233 +++ tools/perf/Makefile | 4 - tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-buildid-cache.c | 3 +- tools/perf/builtin-buildid-list.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-probe.c | 3 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-test.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/build-id.h | 2 - tools/perf/util/callchain.h | 2 +- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 1 - tools/perf/util/event.h | 2 +- tools/perf/util/header.c | 2 +- tools/perf/util/hist.h | 1 + tools/perf/util/map.c | 682 --------- tools/perf/util/map.h | 229 --- tools/perf/util/parse-events.c | 2 +- tools/perf/util/probe-event.c | 2 +- tools/perf/util/probe-finder.c | 2 +- tools/perf/util/session.h | 2 +- tools/perf/util/sort.h | 2 +- tools/perf/util/symbol.c | 2459 ------------------------------- tools/perf/util/symbol.h | 231 --- tools/perf/util/thread.c | 1 + tools/perf/util/thread.h | 2 +- tools/perf/util/ui/browsers/annotate.c | 2 +- tools/perf/util/ui/browsers/hists.c | 2 +- tools/perf/util/ui/browsers/map.c | 4 +- 48 files changed, 3656 insertions(+), 3639 deletions(-) create mode 100644 tools/lib/perf/map.c create mode 100644 tools/lib/perf/map.h create mode 100644 tools/lib/perf/symbol.c create mode 100644 tools/lib/perf/symbol.h delete mode 100644 tools/perf/util/map.c delete mode 100644 tools/perf/util/map.h delete mode 100644 tools/perf/util/symbol.c delete mode 100644 tools/perf/util/symbol.h
tools/lib/lk/util.h +2 -0
@@ -40,7 +40,9 @@#define decimal_length (x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)#define _ALL_SOURCE 1 +#ifndef _GNU_SOURCE#define _GNU_SOURCE 1 +#endif #define _BSD_SOURCE 1#define HAS_BOOL
tools/lib/perf/Makefile +4 -0
@@ -8,11 +8,15 @@ LIB_H += mmap.h LIB_H += util.h LIB_H += color.h LIB_H += config.h +LIB_H += map.h +LIB_H += symbol.h LIB_OBJS += mmap.o LIB_OBJS += color.o LIB_OBJS += config.o LIB_OBJS += path.o +LIB_OBJS += map.o +LIB_OBJS += symbol.o LIBFILE = $(LIB_OUTPUT)lkperflib.a
tools/lib/perf/config.c +3 -0
@@ -18,6 +18,9 @@ int pager_use_color = 1;char buildid_dir[MAXPATHLEN ];/* root dir for buildid, binary cache */ +/* debug.c */ +int verbose =0 ; +static FILE *config_file;static const char *config_file_name;static int config_linenr;
tools/lib/perf/config.h +1 -0
@@ -7,6 +7,7 @@#include <lk/util.h> extern int spawned_pager; +extern int verbose;typedef int (*config_fn_t )(const char *,const char *,void *);extern int perf_default_config (const char *,const char *,void *);
tools/lib/perf/map.c new file +682 -0
682 lines not on this page · raw message
tools/lib/perf/map.h new file +229 -0
229 lines not on this page · raw message
tools/lib/perf/symbol.c new file +2466 -0
2,049 lines not on this page · raw message
tools/lib/perf/symbol.h new file +233 -0
233 lines not on this page · raw message
tools/perf/util/map.c deleted +0 -682
682 lines not on this page · raw message
tools/perf/util/map.h deleted +0 -229
229 lines not on this page · raw message
tools/perf/util/symbol.c deleted +0 -2459
2,459 lines not on this page · raw message
tools/perf/util/symbol.h deleted +0 -231
231 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 17/20 perf: Export trace parsing utils
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
.. and put them into lib/trace/ for a wider use. Also, move a couple of helpers from perf/util/parse-events.c -> lib/trace/trace-event-info.c. While at it, merge duplicated enum trace_flag_type.
--- tools/lib/lk/debugfs.c | 1 + tools/lib/lk/debugfs.h | 1 + tools/lib/trace/Makefile | 7 +- tools/lib/trace/parse-events.h | 12 +- tools/lib/trace/trace-event-info.c | 650 ++++++++++++++++++++ tools/lib/trace/trace-event-parse.c | 231 +++++++ tools/lib/trace/trace-event-read.c | 541 ++++++++++++++++ tools/lib/trace/trace-event.h | 115 ++++ tools/perf/Makefile | 4 - tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-timechart.c | 19 - tools/perf/builtin-trace.c | 2 +- tools/perf/scripts/perl/Perf-Trace-Util/Context.c | 2 +- tools/perf/scripts/perl/Perf-Trace-Util/Context.xs | 2 +- .../perf/scripts/python/Perf-Trace-Util/Context.c | 2 +- tools/perf/util/header.c | 7 +- tools/perf/util/parse-events.c | 103 +--- tools/perf/util/parse-events.h | 9 +- tools/perf/util/probe-event.c | 2 +- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- .../util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/trace-event-info.c | 566 ----------------- tools/perf/util/trace-event-parse.c | 234 ------- tools/perf/util/trace-event-read.c | 541 ---------------- tools/perf/util/trace-event-scripting.c | 2 +- tools/perf/util/trace-event.h | 90 --- 29 files changed, 1574 insertions(+), 1581 deletions(-) create mode 100644 tools/lib/trace/trace-event-info.c create mode 100644 tools/lib/trace/trace-event-parse.c create mode 100644 tools/lib/trace/trace-event-read.c create mode 100644 tools/lib/trace/trace-event.h delete mode 100644 tools/perf/util/trace-event-info.c delete mode 100644 tools/perf/util/trace-event-parse.c delete mode 100644 tools/perf/util/trace-event-read.c delete mode 100644 tools/perf/util/trace-event.h
tools/lib/lk/debugfs.c +1 -0
@@ -7,6 +7,7 @@static int debugfs_premounted;static char debugfs_mountpoint[MAX_PATH +1 ];char debugfs_mntpt[MAXPATHLEN ]; +char debugfs_path[MAXPATHLEN ];static const char *debugfs_known_mountpoints[] = {"/sys/kernel/debug/" ,
tools/lib/lk/debugfs.h +1 -0
@@ -16,6 +16,7 @@#define LK_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"extern char debugfs_mntpt[]; +extern char debugfs_path[];extern const char *debugfs_find_mountpoint (void );extern int debugfs_valid_mountpoint (const char *debugfs);
tools/lib/trace/Makefile +6 -1
@@ -37,17 +37,22 @@ TRACE_LIB = $(LIB_OUTPUT)libparsevent.a all: $(TRACE_LIB) +PEVENT_LIB_H += trace-event.h + PEVENT_LIB_OBJS += parse-events.o PEVENT_LIB_OBJS += parse-filter.o PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += trace-seq.o +PEVENT_LIB_OBJS += trace-event-parse.o +PEVENT_LIB_OBJS += trace-event-read.o +PEVENT_LIB_OBJS += trace-event-info.o ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(OUTPUT)%.o: %.c $(QUIET_CC)$(CC) -g -o $@ -c $(ALL_CFLAGS) $< -$(TRACE_LIB): $(PEVENT_LIB_OBJS) +$(TRACE_LIB): $(PEVENT_LIB_OBJS) $(PEVENT_LIB_H) $(RM) $@; $(AR) rcs $@ $^ clean:
tools/lib/trace/parse-events.h +11 -1
@@ -425,7 +425,17 @@ __data2host8(struct pevent *pevent, unsigned long long data)__data2host8 (pevent, __val); \ }) -/* taken from kernel/trace/trace.h */ +/* +* trace_flag_type is an enumeration that holds different +* states when a trace occurs. These are: +* IRQS_OFF - interrupts were disabled +* IRQS_NOSUPPORT - arch does not support irqs_disabled_flags +* NEED_RESCED - reschedule is requested +* HARDIRQ - inside an interrupt handler +* SOFTIRQ - inside a softirq handler +* +* taken from kernel/trace/trace.h +*/ enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 ,TRACE_FLAG_IRQS_NOSUPPORT =0x02 ,
tools/lib/trace/trace-event-info.c new file +650 -0
650 lines not on this page · raw message
tools/lib/trace/trace-event-parse.c new file +231 -0
231 lines not on this page · raw message
tools/lib/trace/trace-event-read.c new file +541 -0
541 lines not on this page · raw message
tools/lib/trace/trace-event.h new file +115 -0
115 lines not on this page · raw message
tools/perf/Makefile +0 -4
@@ -370,7 +370,6 @@ LIB_H += util/values.h LIB_H += util/sort.h LIB_H += util/hist.h LIB_H += util/thread.h -LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h LIB_H += util/pstack.h
@@ -399,9 +398,6 @@ LIB_OBJS += $(OUTPUT)util/debug.o LIB_OBJS += $(OUTPUT)util/pstack.o LIB_OBJS += $(OUTPUT)util/session.o LIB_OBJS += $(OUTPUT)util/thread.o -LIB_OBJS += $(OUTPUT)util/trace-event-parse.o -LIB_OBJS += $(OUTPUT)util/trace-event-read.o -LIB_OBJS += $(OUTPUT)util/trace-event-info.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o
tools/perf/builtin-kmem.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-kvm.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-lock.c +1 -1
@@ -8,7 +8,7 @@#include "util/header.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h" #include "util/session.h"
tools/perf/builtin-sched.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-timechart.c +0 -19
@@ -314,25 +314,6 @@ struct wakeup_entry {int success; }; -/* -* trace_flag_type is an enumeration that holds different -* states when a trace occurs. These are: -* IRQS_OFF - interrupts were disabled -* IRQS_NOSUPPORT - arch does not support irqs_disabled_flags -* NEED_RESCED - reschedule is requested -* HARDIRQ - inside an interrupt handler -* SOFTIRQ - inside a softirq handler -*/ -enum trace_flag_type { -TRACE_FLAG_IRQS_OFF =0x01 , -TRACE_FLAG_IRQS_NOSUPPORT =0x02 , -TRACE_FLAG_NEED_RESCHED =0x04 , -TRACE_FLAG_HARDIRQ =0x08 , -TRACE_FLAG_SOFTIRQ =0x10 , -}; - - -struct sched_switch {struct trace_entry te;char prev_comm[TASK_COMM_LEN ];
tools/perf/builtin-trace.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include <perf/config.h> #include "util/thread.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include <lk/util.h> static char const *script_name;
tools/perf/scripts/perl/Perf-Trace-Util/Context.c +1 -1
@@ -32,7 +32,7 @@#include "perl.h" #include "XSUB.h" #include "../../../perf.h" -#include "../../../util/trace-event.h" +#include <trace/trace-event.h> #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR (var) if (0) var = var
tools/perf/scripts/perl/Perf-Trace-Util/Context.xs +1 -1
@@ -23,7 +23,7 @@ #include "perl.h" #include "XSUB.h" #include "../../../perf.h" -#include "../../../util/trace-event.h" +#include <trace/trace-event.h> MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context PROTOTYPES: ENABLE
tools/perf/scripts/python/Perf-Trace-Util/Context.c +1 -1
@@ -21,7 +21,7 @@#include <Python.h> #include "../../../perf.h" -#include "../../../util/trace-event.h" +#include <trace/trace-event.h> PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/header.c +4 -3
@@ -6,15 +6,16 @@#include <stdio.h> #include <stdlib.h> #include <linux/list.h> +#include <lk/util.h> #include <lk/kernel.h> +#include <perf/symbol.h> +#include <trace/trace-event.h> -#include <lk/util.h> #include "header.h" #include "../perf.h" -#include "trace-event.h" #include "session.h" -#include <perf/symbol.h> #include "debug.h" +#include "parse-events.h" static bool no_buildid_cache = false;
tools/perf/util/parse-events.c +1 -102
121 lines not on this page · raw message
tools/perf/util/parse-events.h +1 -8
@@ -4,16 +4,10 @@* Parse symbolic events/counts passed in as options: */ #include <perf/util.h> +#include <trace/parse-events.h> struct option ; -struct tracepoint_path { -char *system; -char *name; -struct tracepoint_path *next; -}; - -extern struct tracepoint_path *tracepoint_id_to_path (u64 config);extern bool have_tracepoints (struct perf_event_attr *pattrs,int nb_events);extern int nr_counters;
@@ -31,7 +25,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/probe-event.c +1 -1
@@ -44,7 +44,7 @@#include <perf/color.h> #include <perf/symbol.h> #include "thread.h" -#include "trace-event.h" /* For __unused */ +#include <trace/trace-event.h> /* For __unused */ #include "probe-event.h" #include "probe-finder.h"
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -27,7 +27,7 @@#include "../../perf.h" #include <lk/util.h> -#include "../trace-event.h" +#include <trace/trace-event.h> #include <EXTERN.h> #include <perl.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -29,7 +29,7 @@#include "../../perf.h" #include <lk/util.h> -#include "../trace-event.h" +#include <trace/trace-event.h> PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/trace-event-info.c deleted +0 -566
566 lines not on this page · raw message
tools/perf/util/trace-event-parse.c deleted +0 -234
234 lines not on this page · raw message
tools/perf/util/trace-event-read.c deleted +0 -541
315 lines not on this page · raw message
tools/perf/util/trace-event-scripting.c +1 -1
Lines of this file are not shown. View the raw message.
tools/perf/util/trace-event.h deleted +0 -90
90 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.1
Part of the diff is not shown here. View the raw message.
PATCH 18/20 Move string.c to the library
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This one is generic enough so move it to lib/lk/string.c
--- tools/lib/lk/Makefile | 1 + tools/lib/lk/string.c | 296 +++++++++++++++++++++++++++++++++++++++++ tools/lib/lk/util.h | 2 +- tools/perf/Makefile | 1 - tools/perf/bench/mem-memcpy.c | 2 +- tools/perf/util/string.c | 296 ----------------------------------------- 6 files changed, 299 insertions(+), 299 deletions(-) create mode 100644 tools/lib/lk/string.c delete mode 100644 tools/perf/util/string.c
tools/lib/lk/Makefile +1 -0
@@ -25,6 +25,7 @@ LIB_OBJS += rbtree.o LIB_OBJS += hweight.o LIB_OBJS += bitmap.o LIB_OBJS += strlist.o +LIB_OBJS += string.o LIBFILE = $(LIB_OUTPUT)lklib.a
tools/lib/lk/string.c new file +296 -0
296 lines not on this page · raw message
tools/lib/lk/util.h +1 -1
@@ -261,7 +261,7 @@ static inline int sane_case(int x, int high)int mkdir_p (char *path,mode_t mode);int copyfile (const char *from,const char *to); -s64 perf_atoll (const char *str); +s64 lk_atoll (const char *str);char **argv_split (const char *str,int *argcp);void argv_free (char **argv);bool strglobmatch (const char *str,const char *pat);
tools/perf/Makefile +0 -1
@@ -387,7 +387,6 @@ LIB_OBJS += $(OUTPUT)util/parse-events.o LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o -LIB_OBJS += $(OUTPUT)util/string.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/pager.o
tools/perf/bench/mem-memcpy.c +1 -1
@@ -105,7 +105,7 @@ int bench_mem_memcpy(int argc, const char **argv, tv_diff.tv_sec =0 ; tv_diff.tv_usec =0 ; - length = (size_t )perf_atoll ((char *)length_str); + length = (size_t )lk_atoll ((char *)length_str);if ((s64 )length <=0 ) {fprintf (stderr,"Invalid length:%s\n" , length_str);
tools/perf/util/string.c deleted +0 -296
296 lines not on this page · raw message
Signature · 1 line
1.7.3.1
PATCH 19/20 perf, trace: Export event parsing helpers
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Those are needed for the RAS daemon.
--- tools/lib/trace/parse-events.c | 12 ++++++------ tools/lib/trace/parse-events.h | 5 +++++ tools/lib/trace/trace-event-info.c | 10 +++++----- tools/lib/trace/trace-event.h | 2 ++ 4 files changed, 18 insertions(+), 11 deletions(-)
tools/lib/trace/parse-events.c +6 -6
@@ -45,7 +45,7 @@ static int show_warning = 1; warning(fmt, ##__VA_ARGS__); \ }while (0 ) -static void init_input_buf(const char *buf, unsigned long long size) +void init_input_buf(const char *buf, unsigned long long size) { input_buf = buf; input_buf_siz = size;
@@ -585,7 +585,7 @@ void pevent_print_printk(struct pevent *pevent) } } -static struct event_format *alloc_event (void ) +struct event_format *alloc_event (void ) {struct event_format *event;
@@ -1079,7 +1079,7 @@ static int read_expected_item(enum event_type expect, const char *str)return __read_expected (expect, str,0 ); } -static char *event_read_name (void ) +char *event_read_name (void ) {char *token;
@@ -1099,7 +1099,7 @@ static char *event_read_name(void)return NULL ; } -static int event_read_id (void ) +int event_read_id (void ) {char *token;int id;
@@ -1394,7 +1394,7 @@ fail_expect:return -1 ; } -static int event_read_format (struct event_format *event) +int event_read_format (struct event_format *event) {char *token;int ret;
@@ -4287,7 +4287,7 @@ int pevent_parse_event(struct pevent *pevent,if (strcmp (event->name,"bprint" ) ==0 ) event->flags |=EVENT_FL_ISBPRINT ; } - + event->id =event_read_id ();if (event->id <0 )die ("failed to read event id" );
tools/lib/trace/parse-events.h +5 -0
@@ -728,4 +728,9 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *sourceint pevent_filter_compare (struct event_filter *filter1,struct event_filter *filter2); +extern struct event_format *alloc_event (void ); +extern void init_input_buf (const char *buf,unsigned long long size); +extern char *event_read_name (void ); +extern int event_read_id (void ); +extern int event_read_format (struct event_format *event);#endif /* _PARSE_EVENTS_H */
tools/lib/trace/trace-event-info.c +5 -5
@@ -136,7 +136,7 @@ static const char *find_tracing_dir(void)return tracing; } -static char *get_tracing_file (const char *name) +char *get_tracing_file (const char *name) {const char *tracing;char *file;
@@ -231,7 +231,7 @@ static unsigned long get_size_fd(int fd)return size; } -static unsigned long get_size (const char *file) +unsigned long get_filesize (const char *file) {unsigned long long size =0 ;int fd;
@@ -340,7 +340,7 @@ static void copy_event_system(const char *sys, struct tracepoint_path *tps)if (ret >=0 ) {/* unfortunately, you can not stat debugfs files for size */ - size =get_size (format); + size =get_filesize (format);write_or_die (&size,8 ); check_size =copy_file (format);if (size != check_size)
@@ -438,7 +438,7 @@ static void read_proc_kallsyms(void)write_or_die (&size,4 );return ; } - size =get_size (path); + size =get_filesize (path);write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size)
@@ -461,7 +461,7 @@ static void read_ftrace_printk(void)write_or_die (&size,4 ); goto out; } - size =get_size (path); + size =get_filesize (path);write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size)
tools/lib/trace/trace-event.h +2 -0
@@ -76,6 +76,8 @@ struct event_format *trace_find_event(int id);#endif struct event_format *trace_find_next_event (struct event_format *event);unsigned long long read_size (void *ptr,int size); +unsigned long get_filesize (const char *file); +char *get_tracing_file (const char *name);#if 0 unsigned long long raw_field_value (struct event_format *event,const char *name,void *data);
Signature · 1 line
1.7.3.1
PATCH 20/20 ras: Add RAS daemon
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
--- tools/Makefile | 4 + tools/ras/Makefile | 16 +++ tools/ras/rasd.c | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+), 0 deletions(-) create mode 100644 tools/ras/Makefile create mode 100644 tools/ras/rasd.c
tools/Makefile +4 -0
@@ -37,6 +37,9 @@ export PERF_TOP_DIR perf: libparsevent lklib lkperflib .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) +ras: libparsevent lklib lkperflib .FORCE + $(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1) + libparsevent: .FORCE $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
@@ -51,5 +54,6 @@ clean: $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1) clean .PHONY: clean .FORCE
tools/ras/Makefile new file +16 -0
@@ -0,0 +1,16 @@ +include ../scripts/Makefile.lib + +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 -DNO_NEWT_SUPPORT $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS = $(LDFLAGS) + +RASLIBS=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a $(LIB_OUTPUT)lkperflib.a + +rasd: rasd.o + $(QUIET_CC)$(CC) $(ALL_CFLAGS) -o $@ $^ $(RASLIBS) + +%.o: %.c + $(QUIET_CC)$(CC) $(ALL_CFLAGS) -c $< + +clean: + rm -rf *.o rasd
tools/ras/rasd.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
1.7.3.1
Hi Boris,
Em 04-11-2010 11:36, Borislav Petkov escreveu:
Quoted 9 lines
From: Borislav Petkov <[email protected]>
Hi all,
I finally had some time to work on this thing again. This time it can parse the MCE tracepoint and should be conceptually almost done. What needs to be done now is fleshing out a bunch of details here and there. I'm sending it early so that I can collect some more feedback.
Quoted 7 lines
So the patchset is ontop of 2.6.36 + Steven's
trace_cmdrestructuring set from
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.gittip/perf/parse-eventsI'm adding his patches too here, for completeness (although they need some more work).
I tried to apply your patches here, but they didn't apply. i suspect that Steven added some patches there at the meantime, as two patches on your series are already on his tree. IMO, the better would be if you could create a temporary tree or branch to allow us to better view it.
Quoted 9 lines
I've also cherry-picked the bunch of EDAC's MCE injection stuff for testing.
So, in the end of the day, if you do
echo
0x9c00410000010016>/sys/devices/system/edac/mce/status(
0x9c.. is the MCE signature of a data cache L2 TLB multimatch, for example)
This example looks quite ugly to me. I doubt anyone without a datasheet and after a very careful inspection would know what 0x9c00410000010016 magic number means. I suspect that writing a wrong magic number will also produce a completely undesired result. So, the better it to keep the MCE code internally to the driver.
Also, writing a magic number to a node named as "status" seems weird to me.
IMO, instead, it should be something like:
echo 1 >/sys/devices/system/edac/mce/error_inject
Quoted 16 lines
echo 0 >
/sys/devices/system/edac/mce/bank(0 means bank 0, i.e. data cache errors)
after having loaded the
mce_amd_injinjection testing module, the RAS daemon get's the status signature in userspace:...
DBG main: Read some mmapped data
DBG main: MCE status:0x9c00410000010016All of the remaining fields can be postprocessed in arbitrary manner after that. The MCE decoding in the kernel can then be simplified by sharing it with the daemon, if needed. But that's another story.
Quoted 5 lines · Mauro Carvalho Chehab
I tried to apply your patches here, but they didn't apply. i suspect that Steven added some patches there at the meantime, as two patches on your series are already on his tree. IMO, the better would be if you could create a temporary tree or branch to allow us to better view it.
Sure:
git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git ras-v3
Quoted 3 lines
This example looks quite ugly to me. I doubt anyone without a datasheet and after a very careful inspection would know what
0x9c00410000010016magic number means.
Right, this was only a hands-on example of what otherwise a script does. I wanted to show what happens in detail.
Quoted 2 lines
I suspect that writing a wrong magic number will also produce a completely undesired result.
That's not a problem since this is software-only injection. It actually makes sense to be able to inject crap so that you can test the decoding code:
[81953.494078] [Hardware Error]: MC5_STATUS: Uncorrected error, other errors lost: no, CPU context corrupt: yes, UECC Error [81953.505714] [Hardware Error]: Corrupted FR MCE info? [81953.505718] [Hardware Error]: Transaction: GEN (GEN), no timeout, Cache Level: L3/GEN, Participating Processor: GEN
Quoted 8 lines
So, the better it to keep the MCE code
internally to the driver.Also, writing a magic number to a node named as "status" seems weird to me.
IMO, instead, it should be something like:
echo 1 >/sys/devices/system/edac/mce/error_inject
Well, this way you inject a random error. But you want to control the error types which you inject and set not only one but a couple of the MCi_ bank MSRs. In that manner, you can inject the address at which a certain MCE happens and so on.
So, basically, the long term goal is to have a tool which could do all that. Maybe something like this:
perf inject --mce --functional-unit DC --uncorrectable --pcc-corrupt --virtual-address 0xdeadbeef ...
or
perf inject --mce --functional-unit IC --random --correctable --ecc
(I have long options so that it's clear what we do - we can make them shorter in the actual case.) But you get the idea. This way, you can inject all kinds of stuff and also in a human-readable form.
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 Muenchen Registergericht Muenchen, HRB Nr. 43632