aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2010-01-13 03:58:37 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-13 04:08:50 -0500
commit61405fea92c42d072d9b8bd189689f1502a838af (patch)
tree013ea3e7ed71f4114004d5852d40b6e89e128f76 /tools
parent9c443dfdd31eddea6cbe6ee0ca469fbcc4e1dc3b (diff)
parent1703f2c321a8a531c393e137a82602e16c6061cb (diff)
Merge branch 'perf/urgent' into perf/core
Merge reason: queue up dependent patch, update to -rc4 Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile44
-rw-r--r--tools/perf/builtin-kmem.c4
-rw-r--r--tools/perf/design.txt8
3 files changed, 34 insertions, 22 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7c846424aebf..2c03a9411317 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -250,7 +250,19 @@ PTHREAD_LIBS = -lpthread
250# explicitly what architecture to check for. Fix this up for yours.. 250# explicitly what architecture to check for. Fix this up for yours..
251SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ 251SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
252 252
253ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null "$(QUIET_STDERR)" && echo y"), y) 253ifeq ($(V), 2)
254 QUIET_STDERR = ">/dev/null"
255else
256 QUIET_STDERR = ">/dev/null 2>&1"
257endif
258
259BITBUCKET = "/dev/null"
260
261ifneq ($(shell sh -c "(echo '\#include <stdio.h>'; echo 'int main(void) { return puts(\"hi\"); }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
262 BITBUCKET = .perf.dev.null
263endif
264
265ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
254 CFLAGS := $(CFLAGS) -fstack-protector-all 266 CFLAGS := $(CFLAGS) -fstack-protector-all
255endif 267endif
256 268
@@ -452,11 +464,6 @@ BUILTIN_OBJS += builtin-kmem.o
452 464
453PERFLIBS = $(LIB_FILE) 465PERFLIBS = $(LIB_FILE)
454 466
455ifeq ($(V), 2)
456 QUIET_STDERR = ">/dev/null"
457else
458 QUIET_STDERR = ">/dev/null 2>&1"
459endif
460# 467#
461# Platform specific tweaks 468# Platform specific tweaks
462# 469#
@@ -484,19 +491,19 @@ ifeq ($(uname_S),Darwin)
484 PTHREAD_LIBS = 491 PTHREAD_LIBS =
485endif 492endif
486 493
487ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 494ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
488ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 495ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
489 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); 496 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
490endif 497endif
491 498
492 ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 499 ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
493 BASIC_CFLAGS += -DLIBELF_NO_MMAP 500 BASIC_CFLAGS += -DLIBELF_NO_MMAP
494 endif 501 endif
495else 502else
496 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); 503 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
497endif 504endif
498 505
499ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 506ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
500 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); 507 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
501 BASIC_CFLAGS += -DNO_LIBDWARF 508 BASIC_CFLAGS += -DNO_LIBDWARF
502else 509else
@@ -510,7 +517,7 @@ PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
510PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` 517PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
511endif 518endif
512 519
513ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o /dev/null $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) 520ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o $(BITBUCKET) $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
514 BASIC_CFLAGS += -DNO_LIBPERL 521 BASIC_CFLAGS += -DNO_LIBPERL
515else 522else
516 ALL_LDFLAGS += $(PERL_EMBED_LDOPTS) 523 ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
@@ -520,20 +527,20 @@ endif
520ifdef NO_DEMANGLE 527ifdef NO_DEMANGLE
521 BASIC_CFLAGS += -DNO_DEMANGLE 528 BASIC_CFLAGS += -DNO_DEMANGLE
522else 529else
523 has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") 530 has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
524 531
525 ifeq ($(has_bfd),y) 532 ifeq ($(has_bfd),y)
526 EXTLIBS += -lbfd 533 EXTLIBS += -lbfd
527 else 534 else
528 has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") 535 has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
529 ifeq ($(has_bfd_iberty),y) 536 ifeq ($(has_bfd_iberty),y)
530 EXTLIBS += -lbfd -liberty 537 EXTLIBS += -lbfd -liberty
531 else 538 else
532 has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") 539 has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
533 ifeq ($(has_bfd_iberty_z),y) 540 ifeq ($(has_bfd_iberty_z),y)
534 EXTLIBS += -lbfd -liberty -lz 541 EXTLIBS += -lbfd -liberty -lz
535 else 542 else
536 has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") 543 has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
537 ifeq ($(has_cplus_demangle),y) 544 ifeq ($(has_cplus_demangle),y)
538 EXTLIBS += -liberty 545 EXTLIBS += -liberty
539 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE 546 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
@@ -781,7 +788,7 @@ export TAR INSTALL DESTDIR SHELL_PATH
781 788
782SHELL = $(SHELL_PATH) 789SHELL = $(SHELL_PATH)
783 790
784all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS 791all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
785ifneq (,$X) 792ifneq (,$X)
786 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) 793 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
787endif 794endif
@@ -1108,6 +1115,11 @@ clean:
1108.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS 1115.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
1109.PHONY: .FORCE-PERF-BUILD-OPTIONS 1116.PHONY: .FORCE-PERF-BUILD-OPTIONS
1110 1117
1118.perf.dev.null:
1119 touch .perf.dev.null
1120
1121.INTERMEDIATE: .perf.dev.null
1122
1111### Make sure built-ins do not have dups and listed in perf.c 1123### Make sure built-ins do not have dups and listed in perf.c
1112# 1124#
1113check-builtins:: 1125check-builtins::
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 05dc5a735039..88c570c18e3e 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -132,7 +132,7 @@ static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
132 if (data && data->ptr == ptr) { 132 if (data && data->ptr == ptr) {
133 data->hit++; 133 data->hit++;
134 data->bytes_req += bytes_req; 134 data->bytes_req += bytes_req;
135 data->bytes_alloc += bytes_req; 135 data->bytes_alloc += bytes_alloc;
136 } else { 136 } else {
137 data = malloc(sizeof(*data)); 137 data = malloc(sizeof(*data));
138 if (!data) 138 if (!data)
@@ -172,7 +172,7 @@ static void insert_caller_stat(unsigned long call_site,
172 if (data && data->call_site == call_site) { 172 if (data && data->call_site == call_site) {
173 data->hit++; 173 data->hit++;
174 data->bytes_req += bytes_req; 174 data->bytes_req += bytes_req;
175 data->bytes_alloc += bytes_req; 175 data->bytes_alloc += bytes_alloc;
176 } else { 176 } else {
177 data = malloc(sizeof(*data)); 177 data = malloc(sizeof(*data));
178 if (!data) 178 if (!data)
diff --git a/tools/perf/design.txt b/tools/perf/design.txt
index f000c30877ac..8d0de5130db3 100644
--- a/tools/perf/design.txt
+++ b/tools/perf/design.txt
@@ -21,7 +21,7 @@ There's one file descriptor per virtual counter used.
21The special file descriptor is opened via the perf_event_open() 21The special file descriptor is opened via the perf_event_open()
22system call: 22system call:
23 23
24 int sys_perf_event_open(struct perf_event_hw_event *hw_event_uptr, 24 int sys_perf_event_open(struct perf_event_attr *hw_event_uptr,
25 pid_t pid, int cpu, int group_fd, 25 pid_t pid, int cpu, int group_fd,
26 unsigned long flags); 26 unsigned long flags);
27 27
@@ -32,9 +32,9 @@ can be used to set the blocking mode, etc.
32Multiple counters can be kept open at a time, and the counters 32Multiple counters can be kept open at a time, and the counters
33can be poll()ed. 33can be poll()ed.
34 34
35When creating a new counter fd, 'perf_event_hw_event' is: 35When creating a new counter fd, 'perf_event_attr' is:
36 36
37struct perf_event_hw_event { 37struct perf_event_attr {
38 /* 38 /*
39 * The MSB of the config word signifies if the rest contains cpu 39 * The MSB of the config word signifies if the rest contains cpu
40 * specific (raw) counter configuration data, if unset, the next 40 * specific (raw) counter configuration data, if unset, the next
@@ -399,7 +399,7 @@ Notification of new events is possible through poll()/select()/epoll() and
399fcntl() managing signals. 399fcntl() managing signals.
400 400
401Normally a notification is generated for every page filled, however one can 401Normally a notification is generated for every page filled, however one can
402additionally set perf_event_hw_event.wakeup_events to generate one every 402additionally set perf_event_attr.wakeup_events to generate one every
403so many counter overflow events. 403so many counter overflow events.
404 404
405Future work will include a splice() interface to the ring-buffer. 405Future work will include a splice() interface to the ring-buffer.