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/tip

Pull perf updates from Ingo Molnar.

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
  perf ui browser: Stop using 'self'
  perf annotate browser: Read perf config file for settings
  perf config: Allow '_' in config file variable names
  perf annotate browser: Make feature toggles global
  perf annotate browser: The idx_asm field should be used in asm only view
  perf tools: Convert critical messages to ui__error()
  perf ui: Make --stdio default when TUI is not supported
  tools lib traceevent: Silence compiler warning on 32bit build
  perf record: Fix branch_stack type in perf_record_opts
  perf tools: Reconstruct event with modifiers from perf_event_attr
  perf top: Fix counter name fixup when fallbacking to cpu-clock
  perf tools: fix thread_map__new_by_pid_str() memory leak in error path
  perf tools: Do not use _FORTIFY_SOURCE when DEBUG=1 is specified
  tools lib traceevent: Fix signature of create_arg_item()
  tools lib traceevent: Use proper function parameter type
  tools lib traceevent: Fix freeing arg on process_dynamic_array()
  tools lib traceevent: Fix a possibly wrong memory dereference
  tools lib traceevent: Fix a possible memory leak
  tools lib traceevent: Allow expressions in __print_symbolic() fields
  perf evlist: Explicititely initialize input_name
  ...
  • Loading branch information
torvalds committed May 30, 2012
2 parents 42fe55c + 59cd358 commit 65a50c9
Show file tree
Hide file tree
Showing 21 changed files with 615 additions and 416 deletions.
5 changes: 5 additions & 0 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
if (!buffer)
return size;

/* Make sure the requested buffer exists */
if (cpu_id != RING_BUFFER_ALL_CPUS &&
!cpumask_test_cpu(cpu_id, buffer->cpumask))
return size;

size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
size *= BUF_PAGE_SIZE;

Expand Down
22 changes: 18 additions & 4 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,11 @@ static int event_read_fields(struct event_format *event, struct format_field **f
fail:
free_token(token);
fail_expect:
if (field)
if (field) {
free(field->type);
free(field->name);
free(field);
}
return -1;
}

Expand Down Expand Up @@ -1712,6 +1715,8 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)

if (set_op_prio(arg) == -1) {
event->flags |= EVENT_FL_FAILED;
/* arg->op.op (= token) will be freed at out_free */
arg->op.op = NULL;
goto out_free;
}

Expand Down Expand Up @@ -2124,6 +2129,13 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **

free_token(token);
type = process_arg(event, arg, &token);

if (type == EVENT_OP)
type = process_op(event, arg, &token);

if (type == EVENT_ERROR)
goto out_free;

if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;

Expand Down Expand Up @@ -2288,17 +2300,18 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char **
arg = alloc_arg();
type = process_arg(event, arg, &token);
if (type == EVENT_ERROR)
goto out_free;
goto out_free_arg;

if (!test_type_token(type, token, EVENT_OP, "]"))
goto out_free;
goto out_free_arg;

free_token(token);
type = read_token_item(tok);
return type;

out_free_arg:
free_arg(arg);
out_free:
free(arg);
free_token(token);
*tok = NULL;
return EVENT_ERROR;
Expand Down Expand Up @@ -3362,6 +3375,7 @@ process_defined_func(struct trace_seq *s, void *data, int size,
break;
}
farg = farg->next;
param = param->next;
}

ret = (*func_handle->func)(s, args);
Expand Down
7 changes: 3 additions & 4 deletions tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ static void free_events(struct event_list *events)
}

static struct filter_arg *
create_arg_item(struct event_format *event,
const char *token, enum filter_arg_type type,
char **error_str)
create_arg_item(struct event_format *event, const char *token,
enum event_type type, char **error_str)
{
struct format_field *field;
struct filter_arg *arg;
Expand Down Expand Up @@ -1585,7 +1584,7 @@ get_value(struct event_format *event,
const char *name;

name = get_comm(event, record);
return (unsigned long long)name;
return (unsigned long)name;
}

pevent_read_number_field(field, record->data, &val);
Expand Down
8 changes: 8 additions & 0 deletions tools/perf/Documentation/perfconfig.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@

# Default, disable using /dev/null
dir = /root/.debug

[annotate]

# Defaults
hide_src_code = false
use_offset = true
jump_arrows = true
show_nr_jumps = false
4 changes: 2 additions & 2 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ifeq ("$(origin DEBUG)", "command line")
PERF_DEBUG = $(DEBUG)
endif
ifndef PERF_DEBUG
CFLAGS_OPTIMIZE = -O6
CFLAGS_OPTIMIZE = -O6 -D_FORTIFY_SOURCE=2
endif

ifdef PARSER_DEBUG
Expand All @@ -89,7 +89,7 @@ ifdef PARSER_DEBUG
PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
endif

CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
EXTLIBS = -lpthread -lrt -lelf -lm
ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
ALL_LDFLAGS = $(LDFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
}

if (total_nr_samples == 0) {
ui__warning("The %s file has no samples!\n", session->filename);
ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}
out_delete:
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static const char * const evlist_usage[] = {
int cmd_evlist(int argc, const char **argv, const char *prefix __used)
{
struct perf_attr_details details = { .verbose = false, };
const char *input_name;
const char *input_name = NULL;
const struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"Input file name"),
Expand Down
14 changes: 7 additions & 7 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static void perf_record__open(struct perf_record *rec)
}

if (err == ENOENT) {
ui__warning("The %s event is not supported.\n",
ui__error("The %s event is not supported.\n",
event_name(pos));
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
usage_with_options(record_usage, record_options);

if (rec->force && rec->append_file) {
fprintf(stderr, "Can't overwrite and append at the same time."
" You need to choose between -f and -A");
ui__error("Can't overwrite and append at the same time."
" You need to choose between -f and -A");
usage_with_options(record_usage, record_options);
} else if (rec->append_file) {
rec->write_mode = WRITE_APPEND;
Expand All @@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
}

if (nr_cgroups && !rec->opts.target.system_wide) {
fprintf(stderr, "cgroup monitoring only available in"
" system-wide mode\n");
ui__error("cgroup monitoring only available in"
" system-wide mode\n");
usage_with_options(record_usage, record_options);
}

Expand Down Expand Up @@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno;

perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
ui__error("%s", errbuf);

err = -saved_errno;
goto out_free_fd;
Expand Down Expand Up @@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
else if (rec->opts.freq) {
rec->opts.default_interval = rec->opts.freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
ui__error("frequency and count are zero, aborting\n");
err = -EINVAL;
goto out_free_fd;
}
Expand Down
14 changes: 6 additions & 8 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)

if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
ui__warning("Selected --sort parent, but no "
ui__error("Selected --sort parent, but no "
"callchain data. Did you call "
"'perf record' without -g?\n");
return -EINVAL;
}
if (symbol_conf.use_callchain) {
ui__warning("Selected -g but no callchain data. Did "
ui__error("Selected -g but no callchain data. Did "
"you call 'perf record' without -g?\n");
return -1;
}
Expand All @@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
!symbol_conf.use_callchain) {
symbol_conf.use_callchain = true;
if (callchain_register_param(&callchain_param) < 0) {
ui__warning("Can't register callchain "
"params.\n");
ui__error("Can't register callchain params.\n");
return -EINVAL;
}
}

if (sort__branch_mode == 1) {
if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
fprintf(stderr, "selected -b but no branch data."
" Did you call perf record without"
" -b?\n");
ui__error("Selected -b but no branch data. "
"Did you call perf record without -b?\n");
return -1;
}
}
Expand Down Expand Up @@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep)
}

if (nr_samples == 0) {
ui__warning("The %s file has no samples!\n", session->filename);
ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}

Expand Down
24 changes: 12 additions & 12 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,22 +953,22 @@ static void perf_top__start_counters(struct perf_top *top)
attr->config = PERF_COUNT_SW_CPU_CLOCK;
if (counter->name) {
free(counter->name);
counter->name = strdup(event_name(counter));
counter->name = NULL;
}
goto try_again;
}

if (err == ENOENT) {
ui__warning("The %s event is not supported.\n",
ui__error("The %s event is not supported.\n",
event_name(counter));
goto out_err;
} else if (err == EMFILE) {
ui__warning("Too many events are opened.\n"
ui__error("Too many events are opened.\n"
"Try again after reducing the number of events\n");
goto out_err;
}

ui__warning("The sys_perf_event_open() syscall "
ui__error("The sys_perf_event_open() syscall "
"returned with %d (%s). /bin/dmesg "
"may provide additional information.\n"
"No CONFIG_PERF_EVENTS=y kernel support "
Expand All @@ -978,7 +978,7 @@ static void perf_top__start_counters(struct perf_top *top)
}

if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) {
ui__warning("Failed to mmap with %d (%s)\n",
ui__error("Failed to mmap with %d (%s)\n",
errno, strerror(errno));
goto out_err;
}
Expand All @@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top)
{
if (!top->sort_has_symbols) {
if (symbol_conf.use_callchain) {
ui__warning("Selected -g but \"sym\" not present in --sort/-s.");
ui__error("Selected -g but \"sym\" not present in --sort/-s.");
return -EINVAL;
}
} else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) {
if (callchain_register_param(&callchain_param) < 0) {
ui__warning("Can't register callchain params.\n");
ui__error("Can't register callchain params.\n");
return -EINVAL;
}
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)

if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
display_thread), top)) {
printf("Could not create display thread.\n");
ui__error("Could not create display thread.\n");
exit(-1);
}

Expand All @@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top)

param.sched_priority = top->realtime_prio;
if (sched_setscheduler(0, SCHED_FIFO, &param)) {
printf("Could not set realtime priority.\n");
ui__error("Could not set realtime priority.\n");
exit(-1);
}
}
Expand Down Expand Up @@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno;

perf_target__strerror(&top.target, status, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
ui__error("%s", errbuf);

status = -saved_errno;
goto out_delete_evlist;
Expand All @@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)

if (!top.evlist->nr_entries &&
perf_evlist__add_default(top.evlist) < 0) {
pr_err("Not enough memory for event selector list\n");
ui__error("Not enough memory for event selector list\n");
return -ENOMEM;
}

Expand All @@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
else if (top.freq) {
top.default_interval = top.freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
ui__error("frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct perf_record_opts {
unsigned int freq;
unsigned int mmap_pages;
unsigned int user_freq;
int branch_stack;
u64 branch_stack;
u64 default_interval;
u64 user_interval;
};
Expand Down
Loading

0 comments on commit 65a50c9

Please sign in to comment.