Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Aug 11, 2011
2 parents d16adea + 7676ebb commit 1d229d5
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 68 deletions.
1 change: 1 addition & 0 deletions arch/x86/kernel/cpu/perf_event_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ static __init int intel_pmu_init(void)
break;

case 42: /* SandyBridge */
case 45: /* SandyBridge, "Romely-EP" */
memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
sizeof(hw_cache_event_ids));

Expand Down
3 changes: 2 additions & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \
async.o range.o jump_label.o
async.o range.o
obj-y += groups.o

ifdef CONFIG_FUNCTION_TRACER
Expand Down Expand Up @@ -107,6 +107,7 @@ obj-$(CONFIG_PERF_EVENTS) += events/
obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
obj-$(CONFIG_PADATA) += padata.o
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o

ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ config EVENT_POWER_TRACING_DEPRECATED
power:power_frequency
This is for userspace compatibility
and will vanish after 5 kernel iterations,
namely 2.6.41.
namely 3.1.

config CONTEXT_SWITCH_TRACER
bool
Expand Down
21 changes: 14 additions & 7 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ strip-libs = $(filter-out -l%,$(1))

$(OUTPUT)python/perf.so: $(PYRF_OBJS)
$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
--quiet build_ext \
--build-lib='$(OUTPUT)python' \
--build-temp='$(OUTPUT)python/temp'
--quiet build_ext; \
mkdir -p $(OUTPUT)python && \
cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
#
# No Perl scripts right now:
#
Expand Down Expand Up @@ -509,9 +509,13 @@ else

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

python-clean := $(PYTHON_WORD) util/setup.py clean \
--build-lib='$(OUTPUT)python' \
--build-temp='$(OUTPUT)python/temp'
# python extension build directories
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP

python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so

ifdef NO_LIBPYTHON
$(call disable-python)
Expand Down Expand Up @@ -868,6 +872,9 @@ install: all
$(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'

install-python_ext:
$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'

install-doc:
$(MAKE) -C Documentation install

Expand Down Expand Up @@ -895,7 +902,7 @@ quick-install-html:
### Cleaning rules

clean:
$(RM) $(OUTPUT){*.o,*/*.o,*/*/*.o,*/*/*/*.o,$(LIB_FILE),perf-archive}
$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
$(RM) $(ALL_PROGRAMS) perf
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
$(MAKE) -C Documentation/ clean
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,10 @@ static const char *record_args[] = {
"-f",
"-m", "1024",
"-c", "1",
"-e", "lock:lock_acquire:r",
"-e", "lock:lock_acquired:r",
"-e", "lock:lock_contended:r",
"-e", "lock:lock_release:r",
"-e", "lock:lock_acquire",
"-e", "lock:lock_acquired",
"-e", "lock:lock_contended",
"-e", "lock:lock_release",
};

static int __cmd_record(int argc, const char **argv)
Expand Down
19 changes: 2 additions & 17 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <sched.h>
#include <sys/mman.h>

#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))

enum write_mode_t {
WRITE_FORCE,
WRITE_APPEND
Expand Down Expand Up @@ -438,7 +436,6 @@ static void mmap_read_all(void)

static int __cmd_record(int argc, const char **argv)
{
int i;
struct stat st;
int flags;
int err;
Expand Down Expand Up @@ -682,7 +679,6 @@ static int __cmd_record(int argc, const char **argv)

for (;;) {
int hits = samples;
int thread;

mmap_read_all();

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

if (done) {
for (i = 0; i < evsel_list->cpus->nr; i++) {
struct perf_evsel *pos;

list_for_each_entry(pos, &evsel_list->entries, node) {
for (thread = 0;
thread < evsel_list->threads->nr;
thread++)
ioctl(FD(pos, i, thread),
PERF_EVENT_IOC_DISABLE);
}
}
}
if (done)
perf_evlist__disable(evsel_list);
}

if (quiet || signr == SIGUSR1)
Expand Down
15 changes: 7 additions & 8 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,22 @@ static int perf_session__setup_sample_type(struct perf_session *self)
{
if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
fprintf(stderr, "selected --sort parent, but no"
" callchain data. Did you call"
" perf record without -g?\n");
ui__warning("Selected --sort parent, but no "
"callchain data. Did you call "
"'perf record' without -g?\n");
return -EINVAL;
}
if (symbol_conf.use_callchain) {
fprintf(stderr, "selected -g but no callchain data."
" Did you call perf record without"
" -g?\n");
ui__warning("Selected -g but no callchain data. Did "
"you call 'perf record' without -g?\n");
return -1;
}
} else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE &&
!symbol_conf.use_callchain) {
symbol_conf.use_callchain = true;
if (callchain_register_param(&callchain_param) < 0) {
fprintf(stderr, "Can't register callchain"
" params\n");
ui__warning("Can't register callchain "
"params.\n");
return -EINVAL;
}
}
Expand Down
24 changes: 16 additions & 8 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = {
.ordered_samples = true,
};

static int read_events(void)
static void read_events(bool destroy, struct perf_session **psession)
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops);
if (session == NULL)
return -ENOMEM;
die("No Memory");

if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops);
if (err)
die("Failed to process events, error %d", err);

nr_events = session->hists.stats.nr_events[0];
nr_lost_events = session->hists.stats.total_lost;
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
}

perf_session__delete(session);
return err;
if (destroy)
perf_session__delete(session);

if (psession)
*psession = session;
}

static void print_bad_events(void)
Expand Down Expand Up @@ -1689,9 +1695,10 @@ static void print_bad_events(void)
static void __cmd_lat(void)
{
struct rb_node *next;
struct perf_session *session;

setup_pager();
read_events();
read_events(false, &session);
sort_lat();

printf("\n ---------------------------------------------------------------------------------------------------------------\n");
Expand All @@ -1717,6 +1724,7 @@ static void __cmd_lat(void)
print_bad_events();
printf("\n");

perf_session__delete(session);
}

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

setup_pager();
read_events();
read_events(true, NULL);
print_bad_events();
}

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

test_calibrations();

read_events();
read_events(true, NULL);

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


static const char * const sched_usage[] = {
"perf sched [<options>] {record|latency|map|replay|trace}",
"perf sched [<options>] {record|latency|map|replay|script}",
NULL
};

Expand Down
32 changes: 22 additions & 10 deletions tools/perf/util/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ static int perf_config_global(void)
int perf_config(config_fn_t fn, void *data)
{
int ret = 0, found = 0;
char *repo_config = NULL;
const char *home = NULL;

/* Setting $PERF_CONFIG makes perf read _only_ the given config file. */
Expand All @@ -414,19 +413,32 @@ int perf_config(config_fn_t fn, void *data)
home = getenv("HOME");
if (perf_config_global() && home) {
char *user_config = strdup(mkpath("%s/.perfconfig", home));
if (!access(user_config, R_OK)) {
ret += perf_config_from_file(fn, user_config, data);
found += 1;
struct stat st;

if (user_config == NULL) {
warning("Not enough memory to process %s/.perfconfig, "
"ignoring it.", home);
goto out;
}
free(user_config);
}

repo_config = perf_pathdup("config");
if (!access(repo_config, R_OK)) {
ret += perf_config_from_file(fn, repo_config, data);
if (stat(user_config, &st) < 0)
goto out_free;

if (st.st_uid && (st.st_uid != geteuid())) {
warning("File %s not owned by current user or root, "
"ignoring it.", user_config);
goto out_free;
}

if (!st.st_size)
goto out_free;

ret += perf_config_from_file(fn, user_config, data);
found += 1;
out_free:
free(user_config);
}
free(repo_config);
out:
if (found == 0)
return -1;
return ret;
Expand Down
13 changes: 13 additions & 0 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
return 0;
}

void perf_evlist__disable(struct perf_evlist *evlist)
{
int cpu, thread;
struct perf_evsel *pos;

for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
list_for_each_entry(pos, &evlist->entries, node) {
for (thread = 0; thread < evlist->threads->nr; thread++)
ioctl(FD(pos, cpu, thread), PERF_EVENT_IOC_DISABLE);
}
}
}

int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
{
int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite);
void perf_evlist__munmap(struct perf_evlist *evlist);

void perf_evlist__disable(struct perf_evlist *evlist);

static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
struct cpu_map *cpus,
struct thread_map *threads)
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms)
{
const size_t size = PATH_MAX;
char *realname, *filename = malloc(size),
*linkname = malloc(size), *targetname;
char *realname, *filename = zalloc(size),
*linkname = zalloc(size), *targetname;
int len, err = -1;

if (is_kallsyms) {
Expand Down Expand Up @@ -254,8 +254,8 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
{
const size_t size = PATH_MAX;
char *filename = malloc(size),
*linkname = malloc(size);
char *filename = zalloc(size),
*linkname = zalloc(size);
int err = -1;

if (filename == NULL || linkname == NULL)
Expand Down
12 changes: 8 additions & 4 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,15 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
ret = -ENOMEM;
goto error;
}
tev->point.module = strdup(module);
if (tev->point.module == NULL) {
ret = -ENOMEM;
goto error;

if (module) {
tev->point.module = strdup(module);
if (tev->point.module == NULL) {
ret = -ENOMEM;
goto error;
}
}

tev->point.offset = pev->point.offset;
tev->point.retprobe = pev->point.retprobe;
tev->nargs = pev->nargs;
Expand Down
Loading

0 comments on commit 1d229d5

Please sign in to comment.