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

Commit 2f5e9880 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:

  * Show progress on histogram collapsing, that can take a long time, from
    Namhyung Kim.

  * Support "$vars" meta argument syntax for local variables, allowing
    asking for all possible variables at a given probe point to be
    collected when it hits, from Masami Hiramatsu.

  * Address the root cause of that 'perf sched' stack initialization build
    slowdown, by programmatically setting a big array after moving the
    global variable back to the stack. Fix from Adrian Hunter.

  * Do not repipe attributes to a perf.data file in 'perf inject',
    fix from Adrian Hunter

  * Change the procps visible command-name of invididual benchmark tests
    plus cleanups, from Ingo Molnar.

  * Do not accept parse_tag_value() overflow, fix from Adrian Hunter.

  * Validate that mmap_pages is not too big. From Adrian Hunter.

  * Fix non-debug build, from Adrian Hunter.

  * Clarify the "sample parsing" test entry, from Arnaldo Carvalho de Melo.

  * Consider PERF_SAMPLE_TRANSACTION in the "sample parsing" test,
    from Arnaldo Carvalho de Melo.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents aa30a2e0 c1fb5651
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -487,6 +487,7 @@ ifndef NO_SLANG
  LIB_OBJS += $(OUTPUT)ui/tui/util.o
  LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
  LIB_OBJS += $(OUTPUT)ui/tui/progress.o
  LIB_H += ui/tui/tui.h
  LIB_H += ui/browser.h
  LIB_H += ui/browsers/map.h
  LIB_H += ui/keysyms.h
+3 −3
Original line number Diff line number Diff line
@@ -118,11 +118,11 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
				    ann->print_line, ann->full_paths, 0, 0);
}

static void hists__find_annotations(struct hists *self,
static void hists__find_annotations(struct hists *hists,
				    struct perf_evsel *evsel,
				    struct perf_annotate *ann)
{
	struct rb_node *nd = rb_first(&self->entries), *next;
	struct rb_node *nd = rb_first(&hists->entries), *next;
	int key = K_RIGHT;

	while (nd) {
@@ -247,7 +247,7 @@ static int __cmd_annotate(struct perf_annotate *ann)

		if (nr_samples > 0) {
			total_nr_samples += nr_samples;
			hists__collapse_resort(hists);
			hists__collapse_resort(hists, NULL);
			hists__output_resort(hists);

			if (symbol_conf.event_group &&
+122 −117
Original line number Diff line number Diff line
/*
 *
 * builtin-bench.c
 *
 * General benchmarking subsystem provided by perf
 * General benchmarking collections provided by perf
 *
 * Copyright (C) 2009, Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
 *
 */

/*
 * Available benchmark collection list:
 *
 * Available subsystem list:
 *  sched ... scheduler and IPC mechanism
 *  sched ... scheduler and IPC performance
 *  mem   ... memory access performance
 *
 *  numa  ... NUMA scheduling and MM performance
 */

#include "perf.h"
#include "util/util.h"
#include "util/parse-options.h"
@@ -25,112 +22,92 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>

struct bench_suite {
typedef int (*bench_fn_t)(int argc, const char **argv, const char *prefix);

struct bench {
	const char	*name;
	const char	*summary;
	int (*fn)(int, const char **, const char *);
	bench_fn_t	fn;
};
						\
/* sentinel: easy for help */
#define suite_all { "all", "Test all benchmark suites", NULL }

#ifdef HAVE_LIBNUMA_SUPPORT
static struct bench_suite numa_suites[] = {
	{ "mem",
	  "Benchmark for NUMA workloads",
	  bench_numa },
	suite_all,
	{ NULL,
	  NULL,
	  NULL                  }
static struct bench numa_benchmarks[] = {
	{ "mem",	"Benchmark for NUMA workloads",			bench_numa		},
	{ "all",	"Test all NUMA benchmarks",			NULL			},
	{ NULL,		NULL,						NULL			}
};
#endif

static struct bench_suite sched_suites[] = {
	{ "messaging",
	  "Benchmark for scheduler and IPC mechanisms",
	  bench_sched_messaging },
	{ "pipe",
	  "Flood of communication over pipe() between two processes",
	  bench_sched_pipe      },
	suite_all,
	{ NULL,
	  NULL,
	  NULL                  }
static struct bench sched_benchmarks[] = {
	{ "messaging",	"Benchmark for scheduling and IPC",		bench_sched_messaging	},
	{ "pipe",	"Benchmark for pipe() between two processes",	bench_sched_pipe	},
	{ "all",	"Test all scheduler benchmarks",		NULL			},
	{ NULL,		NULL,						NULL			}
};

static struct bench_suite mem_suites[] = {
	{ "memcpy",
	  "Simple memory copy in various ways",
	  bench_mem_memcpy },
	{ "memset",
	  "Simple memory set in various ways",
	  bench_mem_memset },
	suite_all,
	{ NULL,
	  NULL,
	  NULL             }
static struct bench mem_benchmarks[] = {
	{ "memcpy",	"Benchmark for memcpy()",			bench_mem_memcpy	},
	{ "memset",	"Benchmark for memset() tests",			bench_mem_memset	},
	{ "all",	"Test all memory benchmarks",			NULL			},
	{ NULL,		NULL,						NULL			}
};

struct bench_subsys {
struct collection {
	const char	*name;
	const char	*summary;
	struct bench_suite *suites;
	struct bench	*benchmarks;
};

static struct bench_subsys subsystems[] = {
static struct collection collections[] = {
	{ "sched",	"Scheduler and IPC benchmarks",		sched_benchmarks	},
	{ "mem",	"Memory access benchmarks",			mem_benchmarks		},
#ifdef HAVE_LIBNUMA_SUPPORT
	{ "numa",
	  "NUMA scheduling and MM behavior",
	  numa_suites },
	{ "numa",	"NUMA scheduling and MM benchmarks",		numa_benchmarks		},
#endif
	{ "sched",
	  "scheduler and IPC mechanism",
	  sched_suites },
	{ "mem",
	  "memory access performance",
	  mem_suites },
	{ "all",		/* sentinel: easy for help */
	  "all benchmark subsystem",
	  NULL },
	{ NULL,
	  NULL,
	  NULL       }
	{ "all",	"All benchmarks",				NULL			},
	{ NULL,		NULL,						NULL			}
};

static void dump_suites(int subsys_index)
/* Iterate over all benchmark collections: */
#define for_each_collection(coll) \
	for (coll = collections; coll->name; coll++)

/* Iterate over all benchmarks within a collection: */
#define for_each_bench(coll, bench) \
	for (bench = coll->benchmarks; bench->name; bench++)

static void dump_benchmarks(struct collection *coll)
{
	int i;
	struct bench *bench;

	printf("# List of available suites for %s...\n\n",
	       subsystems[subsys_index].name);
	printf("\n        # List of available benchmarks for collection '%s':\n\n", coll->name);

	for (i = 0; subsystems[subsys_index].suites[i].name; i++)
		printf("%14s: %s\n",
		       subsystems[subsys_index].suites[i].name,
		       subsystems[subsys_index].suites[i].summary);
	for_each_bench(coll, bench)
		printf("%14s: %s\n", bench->name, bench->summary);

	printf("\n");
	return;
}

static const char *bench_format_str;

/* Output/formatting style, exported to benchmark modules: */
int bench_format = BENCH_FORMAT_DEFAULT;

static const struct option bench_options[] = {
	OPT_STRING('f', "format", &bench_format_str, "default",
		    "Specify format style"),
	OPT_STRING('f', "format", &bench_format_str, "default", "Specify format style"),
	OPT_END()
};

static const char * const bench_usage[] = {
	"perf bench [<common options>] <subsystem> <suite> [<options>]",
	"perf bench [<common options>] <collection> <benchmark> [<options>]",
	NULL
};

static void print_usage(void)
{
	struct collection *coll;
	int i;

	printf("Usage: \n");
@@ -138,11 +115,10 @@ static void print_usage(void)
		printf("\t%s\n", bench_usage[i]);
	printf("\n");

	printf("# List of available subsystems...\n\n");
	printf("        # List of all available benchmark collections:\n\n");

	for (i = 0; subsystems[i].name; i++)
		printf("%14s: %s\n",
		       subsystems[i].name, subsystems[i].summary);
	for_each_collection(coll)
		printf("%14s: %s\n", coll->name, coll->summary);
	printf("\n");
}

@@ -159,44 +135,74 @@ static int bench_str2int(const char *str)
	return BENCH_FORMAT_UNKNOWN;
}

static void all_suite(struct bench_subsys *subsys)	  /* FROM HERE */
/*
 * Run a specific benchmark but first rename the running task's ->comm[]
 * to something meaningful:
 */
static int run_bench(const char *coll_name, const char *bench_name, bench_fn_t fn,
		     int argc, const char **argv, const char *prefix)
{
	int i;
	int size;
	char *name;
	int ret;

	size = strlen(coll_name) + 1 + strlen(bench_name) + 1;

	name = zalloc(size);
	BUG_ON(!name);

	scnprintf(name, size, "%s-%s", coll_name, bench_name);

	prctl(PR_SET_NAME, name);
	argv[0] = name;

	ret = fn(argc, argv, prefix);

	free(name);

	return ret;
}

static void run_collection(struct collection *coll)
{
	struct bench *bench;
	const char *argv[2];
	struct bench_suite *suites = subsys->suites;

	argv[1] = NULL;
	/*
	 * TODO:
	 * preparing preset parameters for
	 *
	 * Preparing preset parameters for
	 * embedded, ordinary PC, HPC, etc...
	 * will be helpful
	 * would be helpful.
	 */
	for (i = 0; suites[i].fn; i++) {
		printf("# Running %s/%s benchmark...\n",
		       subsys->name,
		       suites[i].name);
	for_each_bench(coll, bench) {
		if (!bench->fn)
			break;
		printf("# Running %s/%s benchmark...\n", coll->name, bench->name);
		fflush(stdout);

		argv[1] = suites[i].name;
		suites[i].fn(1, argv, NULL);
		argv[1] = bench->name;
		run_bench(coll->name, bench->name, bench->fn, 1, argv, NULL);
		printf("\n");
	}
}

static void all_subsystem(void)
static void run_all_collections(void)
{
	int i;
	for (i = 0; subsystems[i].suites; i++)
		all_suite(&subsystems[i]);
	struct collection *coll;

	for_each_collection(coll)
		run_collection(coll);
}

int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
{
	int i, j, status = 0;
	struct collection *coll;
	int ret = 0;

	if (argc < 2) {
		/* No subsystem specified. */
		/* No collection specified. */
		print_usage();
		goto end;
	}
@@ -206,7 +212,7 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)

	bench_format = bench_str2int(bench_format_str);
	if (bench_format == BENCH_FORMAT_UNKNOWN) {
		printf("Unknown format descriptor:%s\n", bench_format_str);
		printf("Unknown format descriptor: '%s'\n", bench_format_str);
		goto end;
	}

@@ -216,52 +222,51 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
	}

	if (!strcmp(argv[0], "all")) {
		all_subsystem();
		run_all_collections();
		goto end;
	}

	for (i = 0; subsystems[i].name; i++) {
		if (strcmp(subsystems[i].name, argv[0]))
	for_each_collection(coll) {
		struct bench *bench;

		if (strcmp(coll->name, argv[0]))
			continue;

		if (argc < 2) {
			/* No suite specified. */
			dump_suites(i);
			/* No bench specified. */
			dump_benchmarks(coll);
			goto end;
		}

		if (!strcmp(argv[1], "all")) {
			all_suite(&subsystems[i]);
			run_collection(coll);
			goto end;
		}

		for (j = 0; subsystems[i].suites[j].name; j++) {
			if (strcmp(subsystems[i].suites[j].name, argv[1]))
		for_each_bench(coll, bench) {
			if (strcmp(bench->name, argv[1]))
				continue;

			if (bench_format == BENCH_FORMAT_DEFAULT)
				printf("# Running %s/%s benchmark...\n",
				       subsystems[i].name,
				       subsystems[i].suites[j].name);
				printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name);
			fflush(stdout);
			status = subsystems[i].suites[j].fn(argc - 1,
							    argv + 1, prefix);
			ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1, prefix);
			goto end;
		}

		if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
			dump_suites(i);
			dump_benchmarks(coll);
			goto end;
		}

		printf("Unknown suite:%s for %s\n", argv[1], argv[0]);
		status = 1;
		printf("Unknown benchmark: '%s' for collection '%s'\n", argv[1], argv[0]);
		ret = 1;
		goto end;
	}

	printf("Unknown subsystem:%s\n", argv[0]);
	status = 1;
	printf("Unknown collection: '%s'\n", argv[0]);
	ret = 1;

end:
	return status;
	return ret;
}
+3 −4
Original line number Diff line number Diff line
@@ -303,12 +303,11 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,
	return -1;
}

static int hists__add_entry(struct hists *self,
static int hists__add_entry(struct hists *hists,
			    struct addr_location *al, u64 period,
			    u64 weight, u64 transaction)
{
	if (__hists__add_entry(self, al, NULL, period, weight, transaction)
	    != NULL)
	if (__hists__add_entry(hists, al, NULL, period, weight, transaction) != NULL)
		return 0;
	return -ENOMEM;
}
@@ -370,7 +369,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
	list_for_each_entry(evsel, &evlist->entries, node) {
		struct hists *hists = &evsel->hists;

		hists__collapse_resort(hists);
		hists__collapse_resort(hists, NULL);
	}
}

+16 −11
Original line number Diff line number Diff line
@@ -72,12 +72,17 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
				   union perf_event *event,
				   struct perf_evlist **pevlist)
{
	struct perf_inject *inject = container_of(tool, struct perf_inject,
						  tool);
	int ret;

	ret = perf_event__process_attr(tool, event, pevlist);
	if (ret)
		return ret;

	if (!inject->pipe_output)
		return 0;

	return perf_event__repipe_synth(tool, event);
}

@@ -162,38 +167,38 @@ static int perf_event__repipe_tracing_data(struct perf_tool *tool,
	return err;
}

static int dso__read_build_id(struct dso *self)
static int dso__read_build_id(struct dso *dso)
{
	if (self->has_build_id)
	if (dso->has_build_id)
		return 0;

	if (filename__read_build_id(self->long_name, self->build_id,
				    sizeof(self->build_id)) > 0) {
		self->has_build_id = true;
	if (filename__read_build_id(dso->long_name, dso->build_id,
				    sizeof(dso->build_id)) > 0) {
		dso->has_build_id = true;
		return 0;
	}

	return -1;
}

static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,
				struct machine *machine)
{
	u16 misc = PERF_RECORD_MISC_USER;
	int err;

	if (dso__read_build_id(self) < 0) {
		pr_debug("no build_id found for %s\n", self->long_name);
	if (dso__read_build_id(dso) < 0) {
		pr_debug("no build_id found for %s\n", dso->long_name);
		return -1;
	}

	if (self->kernel)
	if (dso->kernel)
		misc = PERF_RECORD_MISC_KERNEL;

	err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
	err = perf_event__synthesize_build_id(tool, dso, misc, perf_event__repipe,
					      machine);
	if (err) {
		pr_err("Can't synthesize build_id event for %s\n", self->long_name);
		pr_err("Can't synthesize build_id event for %s\n", dso->long_name);
		return -1;
	}

Loading