Skip to content

Commit 8aedf8a

Browse files
committed
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (52 commits) perf record: Use per-task-per-cpu events for inherited events perf record: Properly synchronize child creation perf events: Allow per-task-per-cpu counters perf diff: Percent calcs should use double values perf diff: Change the default sort order to "dso,symbol" perf diff: Use perf_session__fprintf_hists just like 'perf record' perf report: Fix cut'n'paste error recently introduced perf session: Move perf report specific hits out of perf_session__fprintf_hists perf tools: Move hist entries printing routines from perf report perf report: Generalize perf_session__fprintf_hists() perf symbols: Move symbol filtering to event__preprocess_sample() perf symbols: Adopt the strlists for dso, comm perf symbols: Make symbol_conf global perf probe: Fix to show which probe point is not found perf probe: Check symbols in symtab/kallsyms perf probe: Check build-id of vmlinux perf probe: Reject second attempt of adding same-name event perf probe: Support event name for --add option perf probe: Add glob matching support on --del perf probe: Use strlist__for_each macros in probe-event.c ...
2 parents bac5e54 + 60ab271 commit 8aedf8a

53 files changed

Lines changed: 2293 additions & 1413 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/linux/perf_event.h‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,11 @@ struct perf_event_attr {
211211
__u32 wakeup_watermark; /* bytes before wakeup */
212212
};
213213

214-
struct { /* Hardware breakpoint info */
215-
__u64 bp_addr;
216-
__u32 bp_type;
217-
__u32 bp_len;
218-
__u64 __bp_reserved_1;
219-
__u64 __bp_reserved_2;
220-
};
221-
222214
__u32 __reserved_2;
223215

224-
__u64 __reserved_3;
216+
__u64 bp_addr;
217+
__u32 bp_type;
218+
__u32 bp_len;
225219
};
226220

227221
/*

‎kernel/perf_event.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ static void __perf_install_in_context(void *info)
782782

783783
add_event_to_ctx(event, ctx);
784784

785+
if (event->cpu != -1 && event->cpu != smp_processor_id())
786+
goto unlock;
787+
785788
/*
786789
* Don't put the event on if it is disabled or if
787790
* it is in a group and the group isn't on.
@@ -925,6 +928,9 @@ static void __perf_event_enable(void *info)
925928
goto unlock;
926929
__perf_event_mark_enabled(event, ctx);
927930

931+
if (event->cpu != -1 && event->cpu != smp_processor_id())
932+
goto unlock;
933+
928934
/*
929935
* If the event is in a group and isn't the group leader,
930936
* then don't put it on unless the group is on.
@@ -1595,15 +1601,12 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
15951601
unsigned long flags;
15961602
int err;
15971603

1598-
/*
1599-
* If cpu is not a wildcard then this is a percpu event:
1600-
*/
1601-
if (cpu != -1) {
1604+
if (pid == -1 && cpu != -1) {
16021605
/* Must be root to operate on a CPU event: */
16031606
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
16041607
return ERR_PTR(-EACCES);
16051608

1606-
if (cpu < 0 || cpu > num_possible_cpus())
1609+
if (cpu < 0 || cpu >= nr_cpumask_bits)
16071610
return ERR_PTR(-EINVAL);
16081611

16091612
/*
@@ -4564,7 +4567,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
45644567
if (attr->type >= PERF_TYPE_MAX)
45654568
return -EINVAL;
45664569

4567-
if (attr->__reserved_1 || attr->__reserved_2 || attr->__reserved_3)
4570+
if (attr->__reserved_1 || attr->__reserved_2)
45684571
return -EINVAL;
45694572

45704573
if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
perf-diff(1)
2+
==============
3+
4+
NAME
5+
----
6+
perf-diff - Read two perf.data files and display the differential profile
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'perf diff' [oldfile] [newfile]
12+
13+
DESCRIPTION
14+
-----------
15+
This command displays the performance difference amongst two perf.data files
16+
captured via perf record.
17+
18+
If no parameters are passed it will assume perf.data.old and perf.data.
19+
20+
OPTIONS
21+
-------
22+
-d::
23+
--dsos=::
24+
Only consider symbols in these dsos. CSV that understands
25+
file://filename entries.
26+
27+
-C::
28+
--comms=::
29+
Only consider symbols in these comms. CSV that understands
30+
file://filename entries.
31+
32+
-S::
33+
--symbols=::
34+
Only consider these symbols. CSV that understands
35+
file://filename entries.
36+
37+
-s::
38+
--sort=::
39+
Sort by key(s): pid, comm, dso, symbol.
40+
41+
-t::
42+
--field-separator=::
43+
44+
Use a special separator character and don't pad with spaces, replacing
45+
all occurances of this separator in symbol names (and other output)
46+
with a '.' character, that thus it's the only non valid separator.
47+
48+
-v::
49+
--verbose::
50+
Be verbose, for instance, show the raw counts in addition to the
51+
diff.
52+
53+
SEE ALSO
54+
--------
55+
linkperf:perf-record[1]

‎tools/perf/Documentation/perf-probe.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ PROBE SYNTAX
4949
------------
5050
Probe points are defined by following syntax.
5151

52-
"FUNC[+OFFS|:RLN|%return][@SRC]|SRC:ALN [ARG ...]"
52+
"[EVENT=]FUNC[+OFFS|:RLN|%return][@SRC]|SRC:ALN [ARG ...]"
5353

54+
'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function. Currently, event group name is set as 'probe'.
5455
'FUNC' specifies a probed function name, and it may have one of the following options; '+OFFS' is the offset from function entry address in bytes, 'RLN' is the relative-line number from function entry line, and '%return' means that it probes function return. In addition, 'SRC' specifies a source file which has that function.
5556
It is also possible to specify a probe point by the source line number by using 'SRC:ALN' syntax, where 'SRC' is the source file path and 'ALN' is the line number.
5657
'ARG' specifies the arguments of this probe point. You can use the name of local variable, or kprobe-tracer argument format (e.g. $retval, %ax, etc).

‎tools/perf/Documentation/perf-report.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ OPTIONS
3939
Only consider these symbols. CSV that understands
4040
file://filename entries.
4141

42+
-s::
43+
--sort=::
44+
Sort by key(s): pid, comm, dso, symbol, parent.
45+
4246
-w::
4347
--field-width=::
4448
Force each column width to the provided list, for large terminal

‎tools/perf/Documentation/perf-trace.txt‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,43 @@ perf-trace - Read perf.data (created by perf record) and display trace output
88
SYNOPSIS
99
--------
1010
[verse]
11-
'perf trace' [-i <file> | --input=file] symbol_name
11+
'perf trace' {record <script> | report <script> [args] }
1212

1313
DESCRIPTION
1414
-----------
1515
This command reads the input file and displays the trace recorded.
1616

17+
There are several variants of perf trace:
18+
19+
'perf trace' to see a detailed trace of the workload that was
20+
recorded.
21+
22+
'perf trace record <script>' to record the events required for 'perf
23+
trace report'. <script> is the name displayed in the output of
24+
'perf trace --list' i.e. the actual script name minus any language
25+
extension.
26+
27+
'perf trace report <script>' to run and display the results of
28+
<script>. <script> is the name displayed in the output of 'perf
29+
trace --list' i.e. the actual script name minus any language
30+
extension. The perf.data output from a previous run of 'perf trace
31+
record <script>' is used and should be present for this command to
32+
succeed.
33+
1734
OPTIONS
1835
-------
1936
-D::
2037
--dump-raw-trace=::
2138
Display verbose dump of the trace data.
2239

40+
-L::
41+
--Latency=::
42+
Show latency attributes (irqs/preemption disabled, etc).
43+
44+
-l::
45+
--list=::
46+
Display a list of available trace scripts.
47+
2348
-s::
2449
--script=::
2550
Process trace data with the given script ([lang]:script[.ext]).

‎tools/perf/Makefile‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ LIB_H += util/values.h
370370
LIB_H += util/sort.h
371371
LIB_H += util/hist.h
372372
LIB_H += util/thread.h
373-
LIB_H += util/data_map.h
374373
LIB_H += util/probe-finder.h
375374
LIB_H += util/probe-event.h
376375

@@ -428,6 +427,7 @@ BUILTIN_OBJS += bench/sched-messaging.o
428427
BUILTIN_OBJS += bench/sched-pipe.o
429428
BUILTIN_OBJS += bench/mem-memcpy.o
430429

430+
BUILTIN_OBJS += builtin-diff.o
431431
BUILTIN_OBJS += builtin-help.o
432432
BUILTIN_OBJS += builtin-sched.o
433433
BUILTIN_OBJS += builtin-buildid-list.o
@@ -996,8 +996,6 @@ install: all
996996
$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
997997
$(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
998998
$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
999-
$(INSTALL) scripts/perl/Perf-Trace-Util/Makefile.PL -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util'
1000-
$(INSTALL) scripts/perl/Perf-Trace-Util/README -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util'
1001999
ifdef BUILT_INS
10021000
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
10031001
$(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'

‎tools/perf/builtin-annotate.c‎

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "util/sort.h"
2727
#include "util/hist.h"
2828
#include "util/session.h"
29-
#include "util/data_map.h"
3029

3130
static char const *input_name = "perf.data";
3231

@@ -52,11 +51,6 @@ struct sym_priv {
5251
struct sym_ext *ext;
5352
};
5453

55-
static struct symbol_conf symbol_conf = {
56-
.priv_size = sizeof(struct sym_priv),
57-
.try_vmlinux_path = true,
58-
};
59-
6054
static const char *sym_hist_filter;
6155

6256
static int symbol_filter(struct map *map __used, struct symbol *sym)
@@ -122,30 +116,32 @@ static void hist_hit(struct hist_entry *he, u64 ip)
122116
h->ip[offset]);
123117
}
124118

125-
static int hist_entry__add(struct addr_location *al, u64 count)
119+
static int perf_session__add_hist_entry(struct perf_session *self,
120+
struct addr_location *al, u64 count)
126121
{
127122
bool hit;
128-
struct hist_entry *he = __hist_entry__add(al, NULL, count, &hit);
123+
struct hist_entry *he = __perf_session__add_hist_entry(self, al, NULL,
124+
count, &hit);
129125
if (he == NULL)
130126
return -ENOMEM;
131127
hist_hit(he, al->addr);
132128
return 0;
133129
}
134130

135-
static int process_sample_event(event_t *event)
131+
static int process_sample_event(event_t *event, struct perf_session *session)
136132
{
137133
struct addr_location al;
138134

139135
dump_printf("(IP, %d): %d: %p\n", event->header.misc,
140136
event->ip.pid, (void *)(long)event->ip.ip);
141137

142-
if (event__preprocess_sample(event, &al, symbol_filter) < 0) {
138+
if (event__preprocess_sample(event, session, &al, symbol_filter) < 0) {
143139
fprintf(stderr, "problem processing %d event, skipping it.\n",
144140
event->header.type);
145141
return -1;
146142
}
147143

148-
if (hist_entry__add(&al, 1)) {
144+
if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
149145
fprintf(stderr, "problem incrementing symbol count, "
150146
"skipping event\n");
151147
return -1;
@@ -429,11 +425,11 @@ static void annotate_sym(struct hist_entry *he)
429425
free_source_line(he, len);
430426
}
431427

432-
static void find_annotations(void)
428+
static void perf_session__find_annotations(struct perf_session *self)
433429
{
434430
struct rb_node *nd;
435431

436-
for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
432+
for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) {
437433
struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
438434
struct sym_priv *priv;
439435

@@ -454,7 +450,7 @@ static void find_annotations(void)
454450
}
455451
}
456452

457-
static struct perf_file_handler file_handler = {
453+
static struct perf_event_ops event_ops = {
458454
.process_sample_event = process_sample_event,
459455
.process_mmap_event = event__process_mmap,
460456
.process_comm_event = event__process_comm,
@@ -463,17 +459,14 @@ static struct perf_file_handler file_handler = {
463459

464460
static int __cmd_annotate(void)
465461
{
466-
struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
467-
struct thread *idle;
468462
int ret;
463+
struct perf_session *session;
469464

465+
session = perf_session__new(input_name, O_RDONLY, force);
470466
if (session == NULL)
471467
return -ENOMEM;
472468

473-
idle = register_idle_thread();
474-
register_perf_file_handler(&file_handler);
475-
476-
ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
469+
ret = perf_session__process_events(session, &event_ops);
477470
if (ret)
478471
goto out_delete;
479472

@@ -483,15 +476,14 @@ static int __cmd_annotate(void)
483476
}
484477

485478
if (verbose > 3)
486-
threads__fprintf(stdout);
479+
perf_session__fprintf(session, stdout);
487480

488481
if (verbose > 2)
489482
dsos__fprintf(stdout);
490483

491-
collapse__resort();
492-
output__resort(event__total[0]);
493-
494-
find_annotations();
484+
perf_session__collapse_resort(session);
485+
perf_session__output_resort(session, session->event_total[0]);
486+
perf_session__find_annotations(session);
495487
out_delete:
496488
perf_session__delete(session);
497489

@@ -524,29 +516,17 @@ static const struct option options[] = {
524516
OPT_END()
525517
};
526518

527-
static void setup_sorting(void)
519+
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
528520
{
529-
char *tmp, *tok, *str = strdup(sort_order);
530-
531-
for (tok = strtok_r(str, ", ", &tmp);
532-
tok; tok = strtok_r(NULL, ", ", &tmp)) {
533-
if (sort_dimension__add(tok) < 0) {
534-
error("Unknown --sort key: `%s'", tok);
535-
usage_with_options(annotate_usage, options);
536-
}
537-
}
521+
argc = parse_options(argc, argv, options, annotate_usage, 0);
538522

539-
free(str);
540-
}
523+
symbol_conf.priv_size = sizeof(struct sym_priv);
524+
symbol_conf.try_vmlinux_path = true;
541525

542-
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
543-
{
544-
if (symbol__init(&symbol_conf) < 0)
526+
if (symbol__init() < 0)
545527
return -1;
546528

547-
argc = parse_options(argc, argv, options, annotate_usage, 0);
548-
549-
setup_sorting();
529+
setup_sorting(annotate_usage, options);
550530

551531
if (argc) {
552532
/*

‎tools/perf/builtin-buildid-list.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "builtin.h"
1010
#include "perf.h"
1111
#include "util/cache.h"
12-
#include "util/data_map.h"
1312
#include "util/debug.h"
1413
#include "util/parse-options.h"
1514
#include "util/session.h"
@@ -55,8 +54,9 @@ static int perf_file_section__process_buildids(struct perf_file_section *self,
5554
static int __cmd_buildid_list(void)
5655
{
5756
int err = -1;
58-
struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
57+
struct perf_session *session;
5958

59+
session = perf_session__new(input_name, O_RDONLY, force);
6060
if (session == NULL)
6161
return -1;
6262

0 commit comments

Comments
 (0)