Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 152fefa9 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

 into perf/core

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

. Fix some leaks in exit paths.

. Use memdup where applicable

. Remove some die() calls, allowing callers to handle exit paths
  gracefully.

. Correct typo in tools Makefile, fix from Borislav Petkov.

. Add 'perf bench numa mem' NUMA performance measurement suite, from Ingo Molnar.

. Handle dynamic array's element size properly, fix from Jiri Olsa.

. Fix memory leaks on evsel->counts, from Namhyung Kim.

. Make numa benchmark optional, allowing the build in machines where required
  numa libraries are not present, fix from Peter Hurley.

. Add interval printing in 'perf stat', from Stephane Eranian.

. Fix compile warnings in tests/attr.c, from Sukadev Bhattiprolu.

. Fix double free, pclose instead of fclose, leaks and double fclose errors
  found with the cppcheck tool, from Thomas Jarosch.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parents a2d28d0c 5809fde0
Loading
Loading
Loading
Loading
+37 −2
Original line number Original line Diff line number Diff line
@@ -1223,6 +1223,34 @@ static int field_is_long(struct format_field *field)
	return 0;
	return 0;
}
}


static unsigned int type_size(const char *name)
{
	/* This covers all FIELD_IS_STRING types. */
	static struct {
		const char *type;
		unsigned int size;
	} table[] = {
		{ "u8",   1 },
		{ "u16",  2 },
		{ "u32",  4 },
		{ "u64",  8 },
		{ "s8",   1 },
		{ "s16",  2 },
		{ "s32",  4 },
		{ "s64",  8 },
		{ "char", 1 },
		{ },
	};
	int i;

	for (i = 0; table[i].type; i++) {
		if (!strcmp(table[i].type, name))
			return table[i].size;
	}

	return 0;
}

static int event_read_fields(struct event_format *event, struct format_field **fields)
static int event_read_fields(struct event_format *event, struct format_field **fields)
{
{
	struct format_field *field = NULL;
	struct format_field *field = NULL;
@@ -1232,6 +1260,8 @@ static int event_read_fields(struct event_format *event, struct format_field **f
	int count = 0;
	int count = 0;


	do {
	do {
		unsigned int size_dynamic = 0;

		type = read_token(&token);
		type = read_token(&token);
		if (type == EVENT_NEWLINE) {
		if (type == EVENT_NEWLINE) {
			free_token(token);
			free_token(token);
@@ -1390,6 +1420,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f
				field->type = new_type;
				field->type = new_type;
				strcat(field->type, " ");
				strcat(field->type, " ");
				strcat(field->type, field->name);
				strcat(field->type, field->name);
				size_dynamic = type_size(field->name);
				free_token(field->name);
				free_token(field->name);
				strcat(field->type, brackets);
				strcat(field->type, brackets);
				field->name = token;
				field->name = token;
@@ -1478,10 +1509,14 @@ static int event_read_fields(struct event_format *event, struct format_field **f
		if (field->flags & FIELD_IS_ARRAY) {
		if (field->flags & FIELD_IS_ARRAY) {
			if (field->arraylen)
			if (field->arraylen)
				field->elementsize = field->size / field->arraylen;
				field->elementsize = field->size / field->arraylen;
			else if (field->flags & FIELD_IS_DYNAMIC)
				field->elementsize = size_dynamic;
			else if (field->flags & FIELD_IS_STRING)
			else if (field->flags & FIELD_IS_STRING)
				field->elementsize = 1;
				field->elementsize = 1;
			else
			else if (field->flags & FIELD_IS_LONG)
				field->elementsize = event->pevent->long_size;
				field->elementsize = event->pevent ?
						     event->pevent->long_size :
						     sizeof(long);
		} else
		} else
			field->elementsize = field->size;
			field->elementsize = field->size;


+4 −0
Original line number Original line Diff line number Diff line
@@ -114,6 +114,10 @@ with it. --append may be used here. Examples:


perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage
perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage


-I msecs::
--interval-print msecs::
	print count deltas every N milliseconds (minimum: 100ms)
	example: perf stat -I 1000 -e cycles -a sleep 5


EXAMPLES
EXAMPLES
--------
--------
+13 −0
Original line number Original line Diff line number Diff line
@@ -47,6 +47,8 @@ include config/utilities.mak
# backtrace post unwind.
# backtrace post unwind.
#
#
# Define NO_BACKTRACE if you do not want stack backtrace debug feature
# Define NO_BACKTRACE if you do not want stack backtrace debug feature
#
# Define NO_LIBNUMA if you do not want numa perf benchmark


$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
	@$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
	@$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -838,6 +840,17 @@ ifndef NO_BACKTRACE
       endif
       endif
endif
endif


ifndef NO_LIBNUMA
	FLAGS_LIBNUMA = $(ALL_CFLAGS) $(ALL_LDFLAGS) -lnuma
	ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y)
		msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
	else
		BASIC_CFLAGS += -DLIBNUMA_SUPPORT
		BUILTIN_OBJS += $(OUTPUT)bench/numa.o
		EXTLIBS += -lnuma
	endif
endif

ifdef ASCIIDOC8
ifdef ASCIIDOC8
	export ASCIIDOC8
	export ASCIIDOC8
endif
endif
+1 −0
Original line number Original line Diff line number Diff line
@@ -155,6 +155,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
		if (lookup_path(buf))
		if (lookup_path(buf))
			goto out;
			goto out;
		free(buf);
		free(buf);
		buf = NULL;
	}
	}


	if (!strcmp(arch, "arm"))
	if (!strcmp(arch, "arm"))
+1 −0
Original line number Original line Diff line number Diff line
#ifndef BENCH_H
#ifndef BENCH_H
#define BENCH_H
#define BENCH_H


extern int bench_numa(int argc, const char **argv, const char *prefix);
extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
extern int bench_mem_memcpy(int argc, const char **argv,
extern int bench_mem_memcpy(int argc, const char **argv,
Loading