Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvements and refactorings from Arnaldo Carvalho de Melo:

New features:

. In perf timechart:
	- Add backtrace support to CPU info
	. Print pid along the name
	. Add support for CPU topology
	. Add new option --highlight'ing threads, be it by name or,
	  if a numeric value is provided, that run more than given duration.
  From Stanislav Fomichev.

Refactorings:

. Rename some struct DSO binary_type related members and methods,
  to clarify its purpose and need for differentiation from symtab_type,
  i.e. one is about the files .text, CFI, etc, i.e. its binary contents,
  and the other is about where the symbol table came from.

. Convert to new topic libraries, starting with an API one (sysfs, debugfs,
  etc), renaming liblk in the process, from Borislav Petkov.

. Get rid of some more panic() like error handling in libtraceevent,
  from Namhyung Kim.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Dec 18, 2013
2 parents 9450d14 + f23b24f commit fa6e8e5
Show file tree
Hide file tree
Showing 26 changed files with 344 additions and 142 deletions.
12 changes: 6 additions & 6 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ cpupower: FORCE
cgroup firewire guest usb virtio vm net: FORCE
$(call descend,$@)

liblk: FORCE
$(call descend,lib/lk)
libapikfs: FORCE
$(call descend,lib/api)

perf: liblk FORCE
perf: libapikfs FORCE
$(call descend,$@)

selftests: FORCE
Expand Down Expand Up @@ -80,10 +80,10 @@ cpupower_clean:
cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean:
$(call descend,$(@:_clean=),clean)

liblk_clean:
$(call descend,lib/lk,clean)
libapikfs_clean:
$(call descend,lib/api,clean)

perf_clean: liblk_clean
perf_clean: libapikfs_clean
$(call descend,$(@:_clean=),clean)

selftests_clean:
Expand Down
18 changes: 11 additions & 7 deletions tools/lib/lk/Makefile → tools/lib/api/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include ../../scripts/Makefile.include
include ../../perf/config/utilities.mak # QUIET_CLEAN

CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
Expand All @@ -7,11 +8,11 @@ AR = $(CROSS_COMPILE)ar
LIB_H=
LIB_OBJS=

LIB_H += debugfs.h
LIB_H += fs/debugfs.h

LIB_OBJS += $(OUTPUT)debugfs.o
LIB_OBJS += $(OUTPUT)fs/debugfs.o

LIBFILE = liblk.a
LIBFILE = libapikfs.a

CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
EXTLIBS = -lelf -lpthread -lrt -lm
Expand All @@ -25,14 +26,17 @@ $(LIBFILE): $(LIB_OBJS)

$(LIB_OBJS): $(LIB_H)

$(OUTPUT)%.o: %.c
libapi_dirs:
$(QUIET_MKDIR)mkdir -p $(OUTPUT)fs/

$(OUTPUT)%.o: %.c libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
$(OUTPUT)%.s: %.c
$(OUTPUT)%.s: %.c libapi_dirs
$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
$(OUTPUT)%.o: %.S
$(OUTPUT)%.o: %.S libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<

clean:
$(RM) $(LIB_OBJS) $(LIBFILE)
$(call QUIET_CLEAN, libapi) $(RM) $(LIB_OBJS) $(LIBFILE)

.PHONY: clean
File renamed without changes.
6 changes: 3 additions & 3 deletions tools/lib/lk/debugfs.h → tools/lib/api/fs/debugfs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __LK_DEBUGFS_H__
#define __LK_DEBUGFS_H__
#ifndef __API_DEBUGFS_H__
#define __API_DEBUGFS_H__

#define _STR(x) #x
#define STR(x) _STR(x)
Expand All @@ -26,4 +26,4 @@ char *debugfs_mount(const char *mountpoint);

extern char debugfs_mountpoint[];

#endif /* __LK_DEBUGFS_H__ */
#endif /* __API_DEBUGFS_H__ */
67 changes: 19 additions & 48 deletions tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,8 +1361,10 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
if (ret >= 0 && pevent->test_filters) {
char *test;
test = pevent_filter_make_string(filter, event->event->id);
printf(" '%s: %s'\n", event->event->name, test);
free(test);
if (test) {
printf(" '%s: %s'\n", event->event->name, test);
free(test);
}
}
}

Expand Down Expand Up @@ -2050,7 +2052,6 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
int left_val = -1;
int right_val = -1;
int val;
int len;

switch (arg->op.type) {
case FILTER_OP_AND:
Expand Down Expand Up @@ -2097,11 +2098,7 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
default:
break;
}
str = malloc_or_die(6);
if (val)
strcpy(str, "TRUE");
else
strcpy(str, "FALSE");
asprintf(&str, val ? "TRUE" : "FALSE");
break;
}
}
Expand All @@ -2119,10 +2116,7 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
break;
}

len = strlen(left) + strlen(right) + strlen(op) + 10;
str = malloc_or_die(len);
snprintf(str, len, "(%s) %s (%s)",
left, op, right);
asprintf(&str, "(%s) %s (%s)", left, op, right);
break;

case FILTER_OP_NOT:
Expand All @@ -2138,16 +2132,10 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
right_val = 0;
if (right_val >= 0) {
/* just return the opposite */
str = malloc_or_die(6);
if (right_val)
strcpy(str, "FALSE");
else
strcpy(str, "TRUE");
asprintf(&str, right_val ? "FALSE" : "TRUE");
break;
}
len = strlen(right) + strlen(op) + 3;
str = malloc_or_die(len);
snprintf(str, len, "%s(%s)", op, right);
asprintf(&str, "%s(%s)", op, right);
break;

default:
Expand All @@ -2161,11 +2149,9 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)

static char *val_to_str(struct event_filter *filter, struct filter_arg *arg)
{
char *str;

str = malloc_or_die(30);
char *str = NULL;

snprintf(str, 30, "%lld", arg->value.val);
asprintf(&str, "%lld", arg->value.val);

return str;
}
Expand All @@ -2181,7 +2167,6 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
char *rstr;
char *op;
char *str = NULL;
int len;

lstr = arg_to_str(filter, arg->exp.left);
rstr = arg_to_str(filter, arg->exp.right);
Expand Down Expand Up @@ -2220,12 +2205,11 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
op = "^";
break;
default:
die("oops in exp");
op = "[ERROR IN EXPRESSION TYPE]";
break;
}

len = strlen(op) + strlen(lstr) + strlen(rstr) + 4;
str = malloc_or_die(len);
snprintf(str, len, "%s %s %s", lstr, op, rstr);
asprintf(&str, "%s %s %s", lstr, op, rstr);
out:
free(lstr);
free(rstr);
Expand All @@ -2239,7 +2223,6 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)
char *rstr;
char *str = NULL;
char *op = NULL;
int len;

lstr = arg_to_str(filter, arg->num.left);
rstr = arg_to_str(filter, arg->num.right);
Expand Down Expand Up @@ -2270,10 +2253,7 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)
if (!op)
op = "<=";

len = strlen(lstr) + strlen(op) + strlen(rstr) + 4;
str = malloc_or_die(len);
sprintf(str, "%s %s %s", lstr, op, rstr);

asprintf(&str, "%s %s %s", lstr, op, rstr);
break;

default:
Expand All @@ -2291,7 +2271,6 @@ static char *str_to_str(struct event_filter *filter, struct filter_arg *arg)
{
char *str = NULL;
char *op = NULL;
int len;

switch (arg->str.type) {
case FILTER_CMP_MATCH:
Expand All @@ -2309,12 +2288,8 @@ static char *str_to_str(struct event_filter *filter, struct filter_arg *arg)
if (!op)
op = "!~";

len = strlen(arg->str.field->name) + strlen(op) +
strlen(arg->str.val) + 6;
str = malloc_or_die(len);
snprintf(str, len, "%s %s \"%s\"",
arg->str.field->name,
op, arg->str.val);
asprintf(&str, "%s %s \"%s\"",
arg->str.field->name, op, arg->str.val);
break;

default:
Expand All @@ -2326,15 +2301,11 @@ static char *str_to_str(struct event_filter *filter, struct filter_arg *arg)

static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
{
char *str;
char *str = NULL;

switch (arg->type) {
case FILTER_ARG_BOOLEAN:
str = malloc_or_die(6);
if (arg->boolean.value)
strcpy(str, "TRUE");
else
strcpy(str, "FALSE");
asprintf(&str, arg->boolean.value ? "TRUE" : "FALSE");
return str;

case FILTER_ARG_OP:
Expand Down Expand Up @@ -2369,7 +2340,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
*
* Returns a string that displays the filter contents.
* This string must be freed with free(str).
* NULL is returned if no filter is found.
* NULL is returned if no filter is found or allocation failed.
*/
char *
pevent_filter_make_string(struct event_filter *filter, int event_id)
Expand Down
16 changes: 16 additions & 0 deletions tools/perf/Documentation/perf-timechart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,25 @@ $ perf timechart

Written 10.2 seconds of trace to output.svg.

Record system-wide timechart:

$ perf timechart record

then generate timechart and highlight 'gcc' tasks:

$ perf timechart --highlight gcc

-n::
--proc-num::
Print task info for at least given number of tasks.
-t::
--topology::
Sort CPUs according to topology.
--highlight=<duration_nsecs|task_name>::
Highlight tasks (using different color) that run more than given
duration or tasks with given name. If number is given it's interpreted
as number of nanoseconds. If non-numeric string is given it's
interpreted as task name.

RECORD OPTIONS
--------------
Expand Down
33 changes: 16 additions & 17 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ FLEX = flex
BISON = bison
STRIP = strip

LK_DIR = $(srctree)/tools/lib/lk/
LIB_DIR = $(srctree)/tools/lib/api/
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/

# include config/Makefile by default and rule out
Expand Down Expand Up @@ -127,20 +127,20 @@ strip-libs = $(filter-out -l%,$(1))
ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
ifneq ($(subdir),)
LK_PATH=$(OUTPUT)/../lib/lk/
LIB_PATH=$(OUTPUT)/../lib/api/
else
LK_PATH=$(OUTPUT)
LIB_PATH=$(OUTPUT)
endif
else
TE_PATH=$(TRACE_EVENT_DIR)
LK_PATH=$(LK_DIR)
LIB_PATH=$(LIB_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
export LIBTRACEEVENT

LIBLK = $(LK_PATH)liblk.a
export LIBLK
LIBAPIKFS = $(LIB_PATH)libapikfs.a
export LIBAPIKFS

# python extension build directories
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
Expand All @@ -151,7 +151,7 @@ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so

PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBLK)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS)

$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
$(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
Expand Down Expand Up @@ -441,7 +441,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o
BUILTIN_OBJS += $(OUTPUT)builtin-mem.o

PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
PERFLIBS = $(LIB_FILE) $(LIBAPIKFS) $(LIBTRACEEVENT)

# We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain. If
Expand Down Expand Up @@ -730,19 +730,19 @@ $(LIBTRACEEVENT)-clean:
install-traceevent-plugins: $(LIBTRACEEVENT)
$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) install_plugins

LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
LIBAPIKFS_SOURCES = $(wildcard $(LIB_PATH)fs/*.[ch])

# if subdir is set, we've been called from above so target has been built
# already
$(LIBLK): $(LIBLK_SOURCES)
$(LIBAPIKFS): $(LIBAPIKFS_SOURCES)
ifeq ($(subdir),)
$(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a
$(QUIET_SUBDIR0)$(LIB_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libapikfs.a
endif

$(LIBLK)-clean:
$(LIBAPIKFS)-clean:
ifeq ($(subdir),)
$(call QUIET_CLEAN, liblk)
@$(MAKE) -C $(LK_DIR) O=$(OUTPUT) clean >/dev/null
$(call QUIET_CLEAN, libapikfs)
@$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
endif

help:
Expand Down Expand Up @@ -881,12 +881,11 @@ config-clean:
$(call QUIET_CLEAN, config)
@$(MAKE) -C config/feature-checks clean >/dev/null

clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean
clean: $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(GTK_OBJS)
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
$(call QUIET_CLEAN, Documentation)
@$(MAKE) -C Documentation O=$(OUTPUT) clean >/dev/null
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
$(python-clean)

#
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "util/parse-options.h"
#include "util/trace-event.h"
#include "util/debug.h"
#include <lk/debugfs.h>
#include <api/fs/debugfs.h>
#include "util/tool.h"
#include "util/stat.h"
#include "util/top.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "util/strfilter.h"
#include "util/symbol.h"
#include "util/debug.h"
#include <lk/debugfs.h>
#include <api/fs/debugfs.h>
#include "util/parse-options.h"
#include "util/probe-finder.h"
#include "util/probe-event.h"
Expand Down
Loading

0 comments on commit fa6e8e5

Please sign in to comment.