Skip to content

Commit

Permalink
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/acme/linux-2.6 into perf/core
  • Loading branch information
Ingo Molnar committed Jun 8, 2010
2 parents 6113e45 + bafb674 commit becf6c9
Show file tree
Hide file tree
Showing 30 changed files with 328 additions and 96 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ endif
no-dot-config-targets := clean mrproper distclean \
cscope TAGS tags help %docs check% \
include/linux/version.h headers_% \
kernelrelease kernelversion
kernelrelease kernelversion %src-pkg

config-targets := 0
mixed-targets := 0
Expand Down Expand Up @@ -1215,6 +1215,8 @@ distclean: mrproper
# rpm target kept for backward compatibility
package-dir := $(srctree)/scripts/package

%src-pkg: FORCE
$(Q)$(MAKE) $(build)=$(package-dir) $@
%pkg: include/config/kernel.release FORCE
$(Q)$(MAKE) $(build)=$(package-dir) $@
rpm: include/config/kernel.release FORCE
Expand Down
37 changes: 31 additions & 6 deletions scripts/package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,38 @@ tar%pkg: FORCE
clean-dirs += $(objtree)/tar-install/


# perf-pkg - generate a source tarball with perf source
# ---------------------------------------------------------------------------

perf-tar=perf-$(KERNELVERSION)

quiet_cmd_perf_tar = TAR
cmd_perf_tar = \
git archive --prefix=$(perf-tar)/ HEAD^{tree} \
$$(cat $(srctree)/tools/perf/MANIFEST) -o $(perf-tar).tar; \
mkdir -p $(perf-tar); \
git rev-parse HEAD > $(perf-tar)/HEAD; \
tar rf $(perf-tar).tar $(perf-tar)/HEAD; \
rm -r $(perf-tar); \
$(if $(findstring tar-src,$@),, \
$(if $(findstring bz2,$@),bzip2, \
$(if $(findstring gz,$@),gzip, \
$(error unknown target $@))) \
-f -9 $(perf-tar).tar)

perf-%pkg: FORCE
$(call cmd,perf_tar)

# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
help: FORCE
@echo ' rpm-pkg - Build both source and binary RPM kernel packages'
@echo ' binrpm-pkg - Build only the binary kernel package'
@echo ' deb-pkg - Build the kernel as an deb package'
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
@echo ' rpm-pkg - Build both source and binary RPM kernel packages'
@echo ' binrpm-pkg - Build only the binary kernel package'
@echo ' deb-pkg - Build the kernel as an deb package'
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
@echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
@echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
@echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'

7 changes: 7 additions & 0 deletions tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ OPTIONS
--raw-samples::
Collect raw sample records from all opened counters (default for tracepoint counters).

-C::
--cpu::
Collect samples only on the list of cpus provided. Multiple CPUs can be provided as a
comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
In per-thread mode with inheritance mode on (default), samples are captured only when
the thread executes on the designated CPUs. Default is to monitor all CPUs.

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
7 changes: 7 additions & 0 deletions tools/perf/Documentation/perf-stat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ OPTIONS
-B::
print large numbers with thousands' separators according to locale

-C::
--cpu=::
Count only on the list of cpus provided. Multiple CPUs can be provided as a
comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
In per-thread mode, this option is ignored. The -a option is still necessary
to activate system-wide monitoring. Default is to count on all CPUs.

EXAMPLES
--------

Expand Down
8 changes: 5 additions & 3 deletions tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ OPTIONS
--count=<count>::
Event period to sample.

-C <cpu>::
--CPU=<cpu>::
CPU to profile.
-C <cpu-list>::
--cpu=<cpu>::
Monitor only on the list of cpus provided. Multiple CPUs can be provided as a
comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
Default is to monitor all CPUS.

-d <seconds>::
--delay=<seconds>::
Expand Down
12 changes: 12 additions & 0 deletions tools/perf/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tools/perf
include/linux/perf_event.h
include/linux/rbtree.h
include/linux/list.h
include/linux/hash.h
include/linux/stringify.h
lib/rbtree.c
include/linux/swab.h
arch/*/include/asm/unistd*.h
include/linux/poison.h
include/linux/magic.h
include/linux/hw_breakpoint.h
6 changes: 2 additions & 4 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
static int process_sample_event(event_t *event, struct perf_session *session)
{
struct addr_location al;
struct sample_data data;

dump_printf("(IP, %d): %d: %#Lx\n", event->header.misc,
event->ip.pid, event->ip.ip);

if (event__preprocess_sample(event, session, &al, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/builtin-buildid-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ static int __cmd_buildid_cache(void)
struct str_node *pos;
char debugdir[PATH_MAX];

snprintf(debugdir, sizeof(debugdir), "%s/%s", getenv("HOME"),
DEBUG_CACHE_DIR);
snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir);

if (add_name_list_str) {
list = strlist__new(true, add_name_list_str);
Expand Down
7 changes: 1 addition & 6 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
struct addr_location al;
struct sample_data data = { .period = 1, };

dump_printf("(IP, %d): %d: %#Lx\n", event->header.misc,
event->ip.pid, event->ip.ip);

if (event__preprocess_sample(event, session, &al, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand All @@ -47,8 +44,6 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
if (al.filtered || al.sym == NULL)
return 0;

event__parse_sample(event, session->sample_type, &data);

if (hists__add_entry(&session->hists, &al, data.period)) {
pr_warning("problem incrementing symbol period, skipping event\n");
return -1;
Expand Down
26 changes: 17 additions & 9 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static int group = 0;
static int realtime_prio = 0;
static bool raw_samples = false;
static bool system_wide = false;
static int profile_cpu = -1;
static pid_t target_pid = -1;
static pid_t target_tid = -1;
static pid_t *all_tids = NULL;
Expand All @@ -74,6 +73,7 @@ static int file_new = 1;
static off_t post_processing_offset;

static struct perf_session *session;
static const char *cpu_list;

struct mmap_data {
int counter;
Expand Down Expand Up @@ -274,6 +274,9 @@ static void create_counter(int counter, int cpu)
if (call_graph)
attr->sample_type |= PERF_SAMPLE_CALLCHAIN;

if (system_wide)
attr->sample_type |= PERF_SAMPLE_CPU;

if (raw_samples) {
attr->sample_type |= PERF_SAMPLE_TIME;
attr->sample_type |= PERF_SAMPLE_RAW;
Expand All @@ -300,7 +303,7 @@ static void create_counter(int counter, int cpu)
die("Permission error - are you root?\n"
"\t Consider tweaking"
" /proc/sys/kernel/perf_event_paranoid.\n");
else if (err == ENODEV && profile_cpu != -1) {
else if (err == ENODEV && cpu_list) {
die("No such device - did you specify"
" an out-of-range profile CPU?\n");
}
Expand Down Expand Up @@ -622,10 +625,15 @@ static int __cmd_record(int argc, const char **argv)
close(child_ready_pipe[0]);
}

if ((!system_wide && no_inherit) || profile_cpu != -1) {
open_counters(profile_cpu);
nr_cpus = read_cpu_map(cpu_list);
if (nr_cpus < 1) {
perror("failed to collect number of CPUs\n");
return -1;
}

if (!system_wide && no_inherit && !cpu_list) {
open_counters(-1);
} else {
nr_cpus = read_cpu_map();
for (i = 0; i < nr_cpus; i++)
open_counters(cpumap[i]);
}
Expand Down Expand Up @@ -704,7 +712,7 @@ static int __cmd_record(int argc, const char **argv)
if (perf_guest)
perf_session__process_machines(session, event__synthesize_guest_os);

if (!system_wide && profile_cpu == -1)
if (!system_wide && cpu_list)
event__synthesize_thread(target_tid, process_synthesized_event,
session);
else
Expand Down Expand Up @@ -794,8 +802,8 @@ static const struct option options[] = {
"system-wide collection from all CPUs"),
OPT_BOOLEAN('A', "append", &append_file,
"append to the output file to do incremental profiling"),
OPT_INTEGER('C', "profile_cpu", &profile_cpu,
"CPU to profile on"),
OPT_STRING('C', "cpu", &cpu_list, "cpu",
"list of cpus to monitor"),
OPT_BOOLEAN('f', "force", &force,
"overwrite existing data file (deprecated)"),
OPT_U64('c', "count", &user_interval, "event period to sample"),
Expand Down Expand Up @@ -825,7 +833,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
argc = parse_options(argc, argv, options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target_pid == -1 && target_tid == -1 &&
!system_wide && profile_cpu == -1)
!system_wide && !cpu_list)
usage_with_options(record_usage, options);

if (force && append_file) {
Expand Down
25 changes: 1 addition & 24 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
struct addr_location al;
struct perf_event_attr *attr;

event__parse_sample(event, session->sample_type, &data);

dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
data.pid, data.tid, data.ip, data.period);

if (session->sample_type & PERF_SAMPLE_CALLCHAIN) {
unsigned int i;

dump_printf("... chain: nr:%Lu\n", data.callchain->nr);

if (!ip_callchain__valid(data.callchain, event)) {
pr_debug("call-chain problem with event, "
"skipping it.\n");
return 0;
}

if (dump_trace) {
for (i = 0; i < data.callchain->nr; i++)
dump_printf("..... %2d: %016Lx\n",
i, data.callchain->ips[i]);
}
}

if (event__preprocess_sample(event, session, &al, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand Down
14 changes: 10 additions & 4 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static struct perf_event_attr default_attrs[] = {
};

static bool system_wide = false;
static unsigned int nr_cpus = 0;
static int nr_cpus = 0;
static int run_idx = 0;

static int run_count = 1;
Expand All @@ -82,6 +82,7 @@ static int thread_num = 0;
static pid_t child_pid = -1;
static bool null_run = false;
static bool big_num = false;
static const char *cpu_list;


static int *fd[MAX_NR_CPUS][MAX_COUNTERS];
Expand Down Expand Up @@ -158,7 +159,7 @@ static int create_perf_stat_counter(int counter)
PERF_FORMAT_TOTAL_TIME_RUNNING;

if (system_wide) {
unsigned int cpu;
int cpu;

for (cpu = 0; cpu < nr_cpus; cpu++) {
fd[cpu][counter][0] = sys_perf_event_open(attr,
Expand Down Expand Up @@ -208,7 +209,7 @@ static inline int nsec_counter(int counter)
static void read_counter(int counter)
{
u64 count[3], single_count[3];
unsigned int cpu;
int cpu;
size_t res, nv;
int scaled;
int i, thread;
Expand Down Expand Up @@ -542,6 +543,8 @@ static const struct option options[] = {
"null run - dont start any counters"),
OPT_BOOLEAN('B', "big-num", &big_num,
"print large numbers with thousands\' separators"),
OPT_STRING('C', "cpu", &cpu_list, "cpu",
"list of cpus to monitor in system-wide"),
OPT_END()
};

Expand All @@ -566,10 +569,13 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
}

if (system_wide)
nr_cpus = read_cpu_map();
nr_cpus = read_cpu_map(cpu_list);
else
nr_cpus = 1;

if (nr_cpus < 1)
usage_with_options(stat_usage, options);

if (target_pid != -1) {
target_tid = target_pid;
thread_num = find_all_tid(target_pid, &all_tids);
Expand Down
Loading

0 comments on commit becf6c9

Please sign in to comment.