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 fixes from Ingo Molnar:
 "Misc fixes on the kernel and tooling side - nothing in particular
  stands out"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
  perf/core: Fix the perf_cpu_time_max_percent check
  perf/core: Fix perf_event_enable_on_exec() timekeeping (again)
  perf/core: Remove confusing comment and move put_ctx()
  perf record: Honor --quiet option properly
  perf annotate: Add -q/--quiet option
  perf diff: Add -q/--quiet option
  perf report: Add -q/--quiet option
  perf utils: Check verbose flag properly
  perf utils: Add perf_quiet_option()
  perf record: Add -a as default target
  perf stat: Add -a as default target
  perf tools: Fail on using multiple bits long terms without value
  perf tools: Move new_term arguments into struct parse_events_term template
  perf build: Add special fixdep cleaning rule
  perf tools: Replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map
  perf header: Make build_cpu_topology skip offline/absent CPUs
  perf cpumap: Add cpu__max_present_cpu()
  perf session: Fix DEBUG=1 build with clang
  tools lib traceevent: It's preempt not prempt
  perf python: Filter out -specs=/a/b/c from the python binding cc options
  ...
  • Loading branch information
torvalds committed Feb 28, 2017
2 parents 74efe07 + 1572e45 commit 3f26b0c
Show file tree
Hide file tree
Showing 55 changed files with 260 additions and 137 deletions.
12 changes: 4 additions & 8 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
int ret = proc_dointvec(table, write, buffer, lenp, ppos);
int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);

if (ret || !write)
return ret;
Expand Down Expand Up @@ -3522,6 +3522,8 @@ static void perf_event_enable_on_exec(int ctxn)
if (enabled) {
clone_ctx = unclone_ctx(ctx);
ctx_resched(cpuctx, ctx, event_type);
} else {
ctx_sched_in(ctx, cpuctx, EVENT_TIME, current);
}
perf_ctx_unlock(cpuctx, ctx);

Expand Down Expand Up @@ -9955,6 +9957,7 @@ SYSCALL_DEFINE5(perf_event_open,
* of swizzling perf_event::ctx.
*/
perf_remove_from_context(group_leader, 0);
put_ctx(gctx);

list_for_each_entry(sibling, &group_leader->sibling_list,
group_entry) {
Expand Down Expand Up @@ -9993,13 +9996,6 @@ SYSCALL_DEFINE5(perf_event_open,
perf_event__state_init(group_leader);
perf_install_in_context(ctx, group_leader, group_leader->cpu);
get_ctx(ctx);

/*
* Now that all events are installed in @ctx, nothing
* references @gctx anymore, so drop the last reference we have
* on it.
*/
put_ctx(gctx);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions tools/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ all: $(OUTPUT)fixdep

clean:
$(call QUIET_CLEAN, fixdep)
$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)rm -f fixdep
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)rm -f $(OUTPUT)fixdep

$(OUTPUT)fixdep-in.o: FORCE
$(Q)$(MAKE) $(build)=fixdep
Expand Down
3 changes: 3 additions & 0 deletions tools/build/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj
fixdep:
$(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep

fixdep-clean:
$(Q)$(MAKE) -C $(srctree)/tools/build clean

.PHONY: fixdep
4 changes: 2 additions & 2 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5225,13 +5225,13 @@ int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec)
}

/**
* pevent_data_prempt_count - parse the preempt count from the record
* pevent_data_preempt_count - parse the preempt count from the record
* @pevent: a handle to the pevent
* @rec: the record to parse
*
* This returns the preempt count from a record.
*/
int pevent_data_prempt_count(struct pevent *pevent, struct pevent_record *rec)
int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec)
{
return parse_common_pc(pevent, rec->data);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void pevent_data_lat_fmt(struct pevent *pevent,
int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
int pevent_data_prempt_count(struct pevent *pevent, struct pevent_record *rec);
int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec);
int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec);
const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
struct cmdline;
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/Documentation/perf-annotate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ OPTIONS
--verbose::
Be more verbose. (Show symbol address, etc)

-q::
--quiet::
Do not show any message. (Suppress -v)

-D::
--dump-raw-trace::
Dump raw trace in ASCII.
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ OPTIONS
Be verbose, for instance, show the raw counts in addition to the
diff.

-q::
--quiet::
Do not show any message. (Suppress -v)

-f::
--force::
Don't do ownership validation.
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ OPTIONS

-a::
--all-cpus::
System-wide collection from all CPUs.
System-wide collection from all CPUs (default if no target is specified).

-p::
--pid=::
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ OPTIONS
--verbose::
Be more verbose. (show symbol address, etc)

-q::
--quiet::
Do not show any message. (Suppress -v)

-n::
--show-nr-samples::
Show the number of samples for each symbol
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-stat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ report::

-a::
--all-cpus::
system-wide collection from all CPUs
system-wide collection from all CPUs (default if no target is specified)

-c::
--scale::
Expand Down
7 changes: 7 additions & 0 deletions tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)

ifeq ($(CC), clang)
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
endif

FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
Expand Down Expand Up @@ -601,6 +605,9 @@ else
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
ifeq ($(CC), clang)
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
endif
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)

ifneq ($(feature-libpython), 1)
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,13 @@ config-clean:
$(call QUIET_CLEAN, config)
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null

clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean fixdep-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detected
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
$(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
$(OUTPUT)pmu-events/pmu-events.c
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show symbol address, etc)"),
OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"),
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
Expand Down Expand Up @@ -463,6 +464,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
annotate.sym_hist_filter = argv[0];
}

if (quiet)
perf_quiet_option();

file.path = input_name;

annotate.session = perf_session__new(&file, false, &annotate.tool);
Expand Down
14 changes: 10 additions & 4 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ static void hists__process(struct hists *hists)
hists__precompute(hists);
hists__output_resort(hists, NULL);

hists__fprintf(hists, true, 0, 0, 0, stdout,
hists__fprintf(hists, !quiet, 0, 0, 0, stdout,
symbol_conf.use_callchain);
}

Expand Down Expand Up @@ -739,12 +739,14 @@ static void data_process(void)
hists__link(hists_base, hists);
}

fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
perf_evsel__name(evsel_base));
if (!quiet) {
fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
perf_evsel__name(evsel_base));
}

first = false;

if (verbose || data__files_cnt > 2)
if (verbose > 0 || ((data__files_cnt > 2) && !quiet))
data__fprintf();

/* Don't sort callchain for perf diff */
Expand Down Expand Up @@ -807,6 +809,7 @@ static const char * const diff_usage[] = {
static const struct option options[] = {
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show symbol address, etc)"),
OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
"Show only items with match in baseline"),
OPT_CALLBACK('c', "compute", &compute,
Expand Down Expand Up @@ -1328,6 +1331,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)

argc = parse_options(argc, argv, options, diff_usage, 0);

if (quiet)
perf_quiet_option();

if (symbol__init(NULL) < 0)
return -1;

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ static int parse_record_events(const struct option *opt,

fprintf(stderr, "%-13s%-*s%s\n",
e->tag,
verbose ? 25 : 0,
verbose ? perf_mem_events__name(j) : "",
verbose > 0 ? 25 : 0,
verbose > 0 ? perf_mem_events__name(j) : "",
e->supported ? ": available" : "");
}
exit(0);
Expand Down
8 changes: 6 additions & 2 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static int record__open(struct record *rec)
try_again:
if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
if (verbose)
if (verbose > 0)
ui__warning("%s\n", msg);
goto try_again;
}
Expand Down Expand Up @@ -1677,8 +1677,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)

argc = parse_options(argc, argv, record_options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (quiet)
perf_quiet_option();

/* Make system wide (-a) the default target. */
if (!argc && target__none(&rec->opts.target))
usage_with_options(record_usage, record_options);
rec->opts.target.system_wide = true;

if (nr_cgroups && !rec->opts.target.system_wide) {
usage_with_options_msg(record_usage, record_options,
Expand Down
21 changes: 16 additions & 5 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
size_t size = sizeof(buf);
int socked_id = hists->socket_filter;

if (quiet)
return 0;

if (symbol_conf.filter_relative) {
nr_samples = hists->stats.nr_non_filtered_samples;
nr_events = hists->stats.total_non_filtered_period;
Expand Down Expand Up @@ -372,7 +375,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
{
struct perf_evsel *pos;

fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples);
if (!quiet) {
fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
evlist->stats.total_lost_samples);
}

evlist__for_each_entry(evlist, pos) {
struct hists *hists = evsel__hists(pos);
const char *evname = perf_evsel__name(pos);
Expand All @@ -382,7 +389,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
continue;

hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout,
hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
symbol_conf.use_callchain);
fprintf(stdout, "\n\n");
}
Expand Down Expand Up @@ -716,6 +723,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
"input file name"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show symbol address, etc)"),
OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
Expand Down Expand Up @@ -863,6 +871,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
report.symbol_filter_str = argv[0];
}

if (quiet)
perf_quiet_option();

if (symbol_conf.vmlinux_name &&
access(symbol_conf.vmlinux_name, R_OK)) {
pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
Expand Down Expand Up @@ -983,14 +994,14 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
goto error;
}

if (report.header || report.header_only) {
if ((report.header || report.header_only) && !quiet) {
perf_session__fprintf_info(session, stdout,
report.show_full_info);
if (report.header_only) {
ret = 0;
goto error;
}
} else if (use_browser == 0) {
} else if (use_browser == 0 && !quiet) {
fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
stdout);
}
Expand All @@ -1009,7 +1020,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
* providing it only in verbose mode not to bloat too
* much struct symbol.
*/
if (verbose) {
if (verbose > 0) {
/*
* XXX: Need to provide a less kludgy way to ask for
* more space per symbol, the u32 is for the index on
Expand Down
12 changes: 6 additions & 6 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static struct task_desc *register_pid(struct perf_sched *sched,
BUG_ON(!sched->tasks);
sched->tasks[task->nr] = task;

if (verbose)
if (verbose > 0)
printf("registered task #%ld, PID %ld (%s)\n", sched->nr_tasks, pid, comm);

return task;
Expand Down Expand Up @@ -794,7 +794,7 @@ replay_wakeup_event(struct perf_sched *sched,
const u32 pid = perf_evsel__intval(evsel, sample, "pid");
struct task_desc *waker, *wakee;

if (verbose) {
if (verbose > 0) {
printf("sched_wakeup event %p\n", evsel);

printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid);
Expand Down Expand Up @@ -822,7 +822,7 @@ static int replay_switch_event(struct perf_sched *sched,
int cpu = sample->cpu;
s64 delta;

if (verbose)
if (verbose > 0)
printf("sched_switch event %p\n", evsel);

if (cpu >= MAX_CPUS || cpu < 0)
Expand Down Expand Up @@ -870,7 +870,7 @@ static int replay_fork_event(struct perf_sched *sched,
goto out_put;
}

if (verbose) {
if (verbose > 0) {
printf("fork event\n");
printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid);
printf("... child: %s/%d\n", thread__comm_str(child), child->tid);
Expand Down Expand Up @@ -1573,7 +1573,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,

timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp));
color_fprintf(stdout, color, " %12s secs ", stimestamp);
if (new_shortname || (verbose && sched_in->tid)) {
if (new_shortname || (verbose > 0 && sched_in->tid)) {
const char *pid_color = color;

if (thread__has_color(sched_in))
Expand Down Expand Up @@ -2050,7 +2050,7 @@ static void save_task_callchain(struct perf_sched *sched,

if (thread__resolve_callchain(thread, cursor, evsel, sample,
NULL, NULL, sched->max_stack + 2) != 0) {
if (verbose)
if (verbose > 0)
error("Failed to resolve callchain. Skipping\n");

return;
Expand Down
Loading

0 comments on commit 3f26b0c

Please sign in to comment.