Skip to content

Commit 1d229d5

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf symbols: Check '/tmp/perf-' symbol file ownership perf sched: Usage leftover from trace -> script rename perf sched: Do not delete session object prematurely perf tools: Check $HOME/.perfconfig ownership perf, x86: Add model 45 SandyBridge support perf tools: Add support to install perf python extension perf tools: do not look at ./config for configuration perf tools: Make clean leaves some files perf lock: Dropping unsupported ':r' modifier perf probe: Fix coredump introduced by probe module option jump label: Reduce the cycle count by changing the link order perf report: Use ui__warning in some more places perf python: Add PERF_RECORD_{LOST,READ,SAMPLE} routine tables perf evlist: Introduce 'disable' method trace events: Update version number reference to new 3.x scheme for EVENT_POWER_TRACING_DEPRECATED perf buildid-cache: Zero out buffer of filenames when adding/removing buildid
2 parents d16adea + 7676ebb commit 1d229d5

16 files changed

+239
-68
lines changed

arch/x86/kernel/cpu/perf_event_intel.c

+1
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ static __init int intel_pmu_init(void)
15901590
break;
15911591

15921592
case 42: /* SandyBridge */
1593+
case 45: /* SandyBridge, "Romely-EP" */
15931594
memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
15941595
sizeof(hw_cache_event_ids));
15951596

kernel/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
1010
kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
1111
hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
1212
notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \
13-
async.o range.o jump_label.o
13+
async.o range.o
1414
obj-y += groups.o
1515

1616
ifdef CONFIG_FUNCTION_TRACER
@@ -107,6 +107,7 @@ obj-$(CONFIG_PERF_EVENTS) += events/
107107
obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
108108
obj-$(CONFIG_PADATA) += padata.o
109109
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
110+
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
110111

111112
ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
112113
# According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is

kernel/trace/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ config EVENT_POWER_TRACING_DEPRECATED
8282
power:power_frequency
8383
This is for userspace compatibility
8484
and will vanish after 5 kernel iterations,
85-
namely 2.6.41.
85+
namely 3.1.
8686

8787
config CONTEXT_SWITCH_TRACER
8888
bool

tools/perf/Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ strip-libs = $(filter-out -l%,$(1))
181181

182182
$(OUTPUT)python/perf.so: $(PYRF_OBJS)
183183
$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
184-
--quiet build_ext \
185-
--build-lib='$(OUTPUT)python' \
186-
--build-temp='$(OUTPUT)python/temp'
184+
--quiet build_ext; \
185+
mkdir -p $(OUTPUT)python && \
186+
cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
187187
#
188188
# No Perl scripts right now:
189189
#
@@ -509,9 +509,13 @@ else
509509

510510
PYTHON_WORD := $(call shell-wordify,$(PYTHON))
511511

512-
python-clean := $(PYTHON_WORD) util/setup.py clean \
513-
--build-lib='$(OUTPUT)python' \
514-
--build-temp='$(OUTPUT)python/temp'
512+
# python extension build directories
513+
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
514+
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
515+
PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
516+
export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
517+
518+
python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
515519

516520
ifdef NO_LIBPYTHON
517521
$(call disable-python)
@@ -868,6 +872,9 @@ install: all
868872
$(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
869873
$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
870874

875+
install-python_ext:
876+
$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
877+
871878
install-doc:
872879
$(MAKE) -C Documentation install
873880

@@ -895,7 +902,7 @@ quick-install-html:
895902
### Cleaning rules
896903

897904
clean:
898-
$(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
905+
$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
899906
$(RM) $(ALL_PROGRAMS) perf
900907
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
901908
$(MAKE) -C Documentation/ clean

tools/perf/builtin-lock.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -942,10 +942,10 @@ static const char *record_args[] = {
942942
"-f",
943943
"-m", "1024",
944944
"-c", "1",
945-
"-e", "lock:lock_acquire:r",
946-
"-e", "lock:lock_acquired:r",
947-
"-e", "lock:lock_contended:r",
948-
"-e", "lock:lock_release:r",
945+
"-e", "lock:lock_acquire",
946+
"-e", "lock:lock_acquired",
947+
"-e", "lock:lock_contended",
948+
"-e", "lock:lock_release",
949949
};
950950

951951
static int __cmd_record(int argc, const char **argv)

tools/perf/builtin-record.c

+2-17
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#include <sched.h>
3131
#include <sys/mman.h>
3232

33-
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
34-
3533
enum write_mode_t {
3634
WRITE_FORCE,
3735
WRITE_APPEND
@@ -438,7 +436,6 @@ static void mmap_read_all(void)
438436

439437
static int __cmd_record(int argc, const char **argv)
440438
{
441-
int i;
442439
struct stat st;
443440
int flags;
444441
int err;
@@ -682,7 +679,6 @@ static int __cmd_record(int argc, const char **argv)
682679

683680
for (;;) {
684681
int hits = samples;
685-
int thread;
686682

687683
mmap_read_all();
688684

@@ -693,19 +689,8 @@ static int __cmd_record(int argc, const char **argv)
693689
waking++;
694690
}
695691

696-
if (done) {
697-
for (i = 0; i < evsel_list->cpus->nr; i++) {
698-
struct perf_evsel *pos;
699-
700-
list_for_each_entry(pos, &evsel_list->entries, node) {
701-
for (thread = 0;
702-
thread < evsel_list->threads->nr;
703-
thread++)
704-
ioctl(FD(pos, i, thread),
705-
PERF_EVENT_IOC_DISABLE);
706-
}
707-
}
708-
}
692+
if (done)
693+
perf_evlist__disable(evsel_list);
709694
}
710695

711696
if (quiet || signr == SIGUSR1)

tools/perf/builtin-report.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -162,23 +162,22 @@ static int perf_session__setup_sample_type(struct perf_session *self)
162162
{
163163
if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
164164
if (sort__has_parent) {
165-
fprintf(stderr, "selected --sort parent, but no"
166-
" callchain data. Did you call"
167-
" perf record without -g?\n");
165+
ui__warning("Selected --sort parent, but no "
166+
"callchain data. Did you call "
167+
"'perf record' without -g?\n");
168168
return -EINVAL;
169169
}
170170
if (symbol_conf.use_callchain) {
171-
fprintf(stderr, "selected -g but no callchain data."
172-
" Did you call perf record without"
173-
" -g?\n");
171+
ui__warning("Selected -g but no callchain data. Did "
172+
"you call 'perf record' without -g?\n");
174173
return -1;
175174
}
176175
} else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE &&
177176
!symbol_conf.use_callchain) {
178177
symbol_conf.use_callchain = true;
179178
if (callchain_register_param(&callchain_param) < 0) {
180-
fprintf(stderr, "Can't register callchain"
181-
" params\n");
179+
ui__warning("Can't register callchain "
180+
"params.\n");
182181
return -EINVAL;
183182
}
184183
}

tools/perf/builtin-sched.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = {
16371637
.ordered_samples = true,
16381638
};
16391639

1640-
static int read_events(void)
1640+
static void read_events(bool destroy, struct perf_session **psession)
16411641
{
16421642
int err = -EINVAL;
16431643
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
16441644
0, false, &event_ops);
16451645
if (session == NULL)
1646-
return -ENOMEM;
1646+
die("No Memory");
16471647

16481648
if (perf_session__has_traces(session, "record -R")) {
16491649
err = perf_session__process_events(session, &event_ops);
1650+
if (err)
1651+
die("Failed to process events, error %d", err);
1652+
16501653
nr_events = session->hists.stats.nr_events[0];
16511654
nr_lost_events = session->hists.stats.total_lost;
16521655
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
16531656
}
16541657

1655-
perf_session__delete(session);
1656-
return err;
1658+
if (destroy)
1659+
perf_session__delete(session);
1660+
1661+
if (psession)
1662+
*psession = session;
16571663
}
16581664

16591665
static void print_bad_events(void)
@@ -1689,9 +1695,10 @@ static void print_bad_events(void)
16891695
static void __cmd_lat(void)
16901696
{
16911697
struct rb_node *next;
1698+
struct perf_session *session;
16921699

16931700
setup_pager();
1694-
read_events();
1701+
read_events(false, &session);
16951702
sort_lat();
16961703

16971704
printf("\n ---------------------------------------------------------------------------------------------------------------\n");
@@ -1717,6 +1724,7 @@ static void __cmd_lat(void)
17171724
print_bad_events();
17181725
printf("\n");
17191726

1727+
perf_session__delete(session);
17201728
}
17211729

17221730
static struct trace_sched_handler map_ops = {
@@ -1731,7 +1739,7 @@ static void __cmd_map(void)
17311739
max_cpu = sysconf(_SC_NPROCESSORS_CONF);
17321740

17331741
setup_pager();
1734-
read_events();
1742+
read_events(true, NULL);
17351743
print_bad_events();
17361744
}
17371745

@@ -1744,7 +1752,7 @@ static void __cmd_replay(void)
17441752

17451753
test_calibrations();
17461754

1747-
read_events();
1755+
read_events(true, NULL);
17481756

17491757
printf("nr_run_events: %ld\n", nr_run_events);
17501758
printf("nr_sleep_events: %ld\n", nr_sleep_events);
@@ -1769,7 +1777,7 @@ static void __cmd_replay(void)
17691777

17701778

17711779
static const char * const sched_usage[] = {
1772-
"perf sched [<options>] {record|latency|map|replay|trace}",
1780+
"perf sched [<options>] {record|latency|map|replay|script}",
17731781
NULL
17741782
};
17751783

tools/perf/util/config.c

+22-10
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ static int perf_config_global(void)
399399
int perf_config(config_fn_t fn, void *data)
400400
{
401401
int ret = 0, found = 0;
402-
char *repo_config = NULL;
403402
const char *home = NULL;
404403

405404
/* Setting $PERF_CONFIG makes perf read _only_ the given config file. */
@@ -414,19 +413,32 @@ int perf_config(config_fn_t fn, void *data)
414413
home = getenv("HOME");
415414
if (perf_config_global() && home) {
416415
char *user_config = strdup(mkpath("%s/.perfconfig", home));
417-
if (!access(user_config, R_OK)) {
418-
ret += perf_config_from_file(fn, user_config, data);
419-
found += 1;
416+
struct stat st;
417+
418+
if (user_config == NULL) {
419+
warning("Not enough memory to process %s/.perfconfig, "
420+
"ignoring it.", home);
421+
goto out;
420422
}
421-
free(user_config);
422-
}
423423

424-
repo_config = perf_pathdup("config");
425-
if (!access(repo_config, R_OK)) {
426-
ret += perf_config_from_file(fn, repo_config, data);
424+
if (stat(user_config, &st) < 0)
425+
goto out_free;
426+
427+
if (st.st_uid && (st.st_uid != geteuid())) {
428+
warning("File %s not owned by current user or root, "
429+
"ignoring it.", user_config);
430+
goto out_free;
431+
}
432+
433+
if (!st.st_size)
434+
goto out_free;
435+
436+
ret += perf_config_from_file(fn, user_config, data);
427437
found += 1;
438+
out_free:
439+
free(user_config);
428440
}
429-
free(repo_config);
441+
out:
430442
if (found == 0)
431443
return -1;
432444
return ret;

tools/perf/util/evlist.c

+13
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
9191
return 0;
9292
}
9393

94+
void perf_evlist__disable(struct perf_evlist *evlist)
95+
{
96+
int cpu, thread;
97+
struct perf_evsel *pos;
98+
99+
for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
100+
list_for_each_entry(pos, &evlist->entries, node) {
101+
for (thread = 0; thread < evlist->threads->nr; thread++)
102+
ioctl(FD(pos, cpu, thread), PERF_EVENT_IOC_DISABLE);
103+
}
104+
}
105+
}
106+
94107
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
95108
{
96109
int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries;

tools/perf/util/evlist.h

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
5353
int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite);
5454
void perf_evlist__munmap(struct perf_evlist *evlist);
5555

56+
void perf_evlist__disable(struct perf_evlist *evlist);
57+
5658
static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
5759
struct cpu_map *cpus,
5860
struct thread_map *threads)

tools/perf/util/header.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
189189
const char *name, bool is_kallsyms)
190190
{
191191
const size_t size = PATH_MAX;
192-
char *realname, *filename = malloc(size),
193-
*linkname = malloc(size), *targetname;
192+
char *realname, *filename = zalloc(size),
193+
*linkname = zalloc(size), *targetname;
194194
int len, err = -1;
195195

196196
if (is_kallsyms) {
@@ -254,8 +254,8 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
254254
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
255255
{
256256
const size_t size = PATH_MAX;
257-
char *filename = malloc(size),
258-
*linkname = malloc(size);
257+
char *filename = zalloc(size),
258+
*linkname = zalloc(size);
259259
int err = -1;
260260

261261
if (filename == NULL || linkname == NULL)

tools/perf/util/probe-event.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1820,11 +1820,15 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
18201820
ret = -ENOMEM;
18211821
goto error;
18221822
}
1823-
tev->point.module = strdup(module);
1824-
if (tev->point.module == NULL) {
1825-
ret = -ENOMEM;
1826-
goto error;
1823+
1824+
if (module) {
1825+
tev->point.module = strdup(module);
1826+
if (tev->point.module == NULL) {
1827+
ret = -ENOMEM;
1828+
goto error;
1829+
}
18271830
}
1831+
18281832
tev->point.offset = pev->point.offset;
18291833
tev->point.retprobe = pev->point.retprobe;
18301834
tev->nargs = pev->nargs;

0 commit comments

Comments
 (0)