Commit 059c6d68 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

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

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

 into perf/core

Pull perf updates from Arnaldo:

perf/core improvements and fixes:

perf record:

  - Introduce --switch-output-event to use arbitrary events to be setup
    and read from a side band thread and, when they take place a signal
    be sent to the main 'perf record' thread, reusing the --switch-output
    code to take perf.data snapshots from the --overwrite ring buffer, e.g.:

	# perf record --overwrite -e sched:* \
		      --switch-output-event syscalls:*connect* \
		      workload

    will take perf.data.YYYYMMDDHHMMSS snapshots up to around the
    connect syscalls.

  Stephane Eranian:

  - Add --num-synthesize-threads option to control degree of parallelism of the
    synthesize_mmap() code which is scanning /proc/PID/task/PID/maps and can be
    time consuming. This mimics pre-existing behaviour in 'perf top'.

Intel PT:

  Adrian Hunter:

  - Add support for synthesizing branch stacks for regular events (cycles,
    instructions, etc) from Intel PT data.

perf bench:

  Ian Rogers:

  - Add a multi-threaded synthesize benchmark.

  - Add kallsyms parsing benchmark.

  Tommi Rantala:

  - Fix div-by-zero if runtime is zero.

perf synthetic events:

  - Remove use of sscanf from /proc reading when parsing pre-existing
    threads to generate synthetic PERF_RECORD_{FORK,MMAP,COMM,etc} events.

tools api:

  - Add a lightweight buffered reading API.

libsymbols:

  - Parse kallsyms using new lightweight buffered reading io API.

perf parse-events:

  - Fix memory leaks found on parse_events.

perf mem2node:

  - Avoid double free related to realloc().

perf stat:

  Jin Yao:

  - Zero all the 'ena' and 'run' array slot stats for interval mode.

  - Improve runtime stat for interval mode

  Kajol Jain:

  - Enable Hz/hz printing for --metric-only option

  - Enhance JSON/metric infrastructure to handle "?".

perf tests:

  Kajol Jain:

  - Added test for runtime param in metric expression.

  Tommi Rantala:

  - Fix data path in the session topology test.

perf vendor events power9:

  Kajol Jain:

 - Add hv_24x7 socket/chip level metric events

Coresight:

  Leo Yan:

  - Move definition of 'traceid_list' global variable from header file.

  Mike Leach:

  - Update to build with latest opencsd version.

perf pmu:

  Shaokun Zhang:

  - Fix function name in comment, its get_cpuid_str(), not get_cpustr()

  Stephane Eranian:

  - Add perf_pmu__find_by_type() helper

perf script:

  Stephane Eranian:

  - Remove extraneous newline in perf_sample__fprintf_regs().

  Ian Rogers:

  - Avoid NULL dereference on symbol.

tools feature:

  Stephane Eranian:

  - Add support for detecting libpfm4.

perf symbol:

  Thomas Richter:

  - Fix kernel symbol address display in TUI verbose mode.

perf cgroup:

  Tommi Rantala:

  - Avoid needless closing of unopened fd

libperf:

  He Zhe:

  - Add NULL pointer check for cpu_map iteration and NULL
    assignment for all_cpus.

  Ian Rogers:

  - Fix a refcount leak in evlist method.

  Arnaldo Carvalho de Melo:

  - Rename the code in tools/perf/util, i.e. perf tooling specific, that
    operates on 'struct evsel' to evsel__, leaving the perf_evsel__
    namespace for the routines in tools/lib/perf/ that operate on
    'struct perf_evsel__'.

tools/perf specific libraries:

  Konstantin Khlebnikov:

  - Fix reading new topology attribute "core_cpus"

  - Simplify checking if SMT is active.

perf flamegraph:

  Arnaldo Carvalho de Melo:

  - Use /bin/bash for report and record scripts, just like all other
    such scripts, fixing a package dependency bug in a Linaro
    OpenEmbedded build checker.

perf evlist:

  Jagadeesh Pagadala:

  - Remove duplicate headers.

Miscelaneous:

  Zou Wei:

  - Remove unneeded semicolon in libtraceevent, 'perf c2c' and others.

  - Fix warning assignment of 0/1 to bool variable in 'perf report'

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parents 4bd30106 19ce2321
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -98,7 +98,8 @@ FEATURE_TESTS_EXTRA := \
         llvm                           \
         llvm-version                   \
         clang                          \
         libbpf
         libbpf                         \
         libpfm4

FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)

+5 −1
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ FILES= \
         test-libaio.bin			\
         test-libzstd.bin			\
         test-clang-bpf-global-var.bin		\
         test-file-handle.bin
         test-file-handle.bin			\
         test-libpfm4.bin

FILES := $(addprefix $(OUTPUT),$(FILES))

@@ -331,6 +332,9 @@ $(OUTPUT)test-clang-bpf-global-var.bin:
$(OUTPUT)test-file-handle.bin:
	$(BUILD)

$(OUTPUT)test-libpfm4.bin:
	$(BUILD) -lpfm

###############################

clean:
+2 −2
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@
/*
 * Check OpenCSD library version is sufficient to provide required features
 */
#define OCSD_MIN_VER ((0 << 16) | (11 << 8) | (0))
#define OCSD_MIN_VER ((0 << 16) | (14 << 8) | (0))
#if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER)
#error "OpenCSD >= 0.11.0 is required"
#error "OpenCSD >= 0.14.0 is required"
#endif

int main(void)
+9 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include <sys/types.h>
#include <perfmon/pfmlib.h>

int main(void)
{
	pfm_initialize();
	return 0;
}

tools/lib/api/io.h

0 → 100644
+115 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Lightweight buffered reading library.
 *
 * Copyright 2019 Google LLC.
 */
#ifndef __API_IO__
#define __API_IO__

#include <stdlib.h>
#include <unistd.h>

struct io {
	/* File descriptor being read/ */
	int fd;
	/* Size of the read buffer. */
	unsigned int buf_len;
	/* Pointer to storage for buffering read. */
	char *buf;
	/* End of the storage. */
	char *end;
	/* Currently accessed data pointer. */
	char *data;
	/* Set true on when the end of file on read error. */
	bool eof;
};

static inline void io__init(struct io *io, int fd,
			    char *buf, unsigned int buf_len)
{
	io->fd = fd;
	io->buf_len = buf_len;
	io->buf = buf;
	io->end = buf;
	io->data = buf;
	io->eof = false;
}

/* Reads one character from the "io" file with similar semantics to fgetc. */
static inline int io__get_char(struct io *io)
{
	char *ptr = io->data;

	if (io->eof)
		return -1;

	if (ptr == io->end) {
		ssize_t n = read(io->fd, io->buf, io->buf_len);

		if (n <= 0) {
			io->eof = true;
			return -1;
		}
		ptr = &io->buf[0];
		io->end = &io->buf[n];
	}
	io->data = ptr + 1;
	return *ptr;
}

/* Read a hexadecimal value with no 0x prefix into the out argument hex. If the
 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
 * returns the character after the hexadecimal value which may be -1 for eof.
 * If the read value is larger than a u64 the high-order bits will be dropped.
 */
static inline int io__get_hex(struct io *io, __u64 *hex)
{
	bool first_read = true;

	*hex = 0;
	while (true) {
		int ch = io__get_char(io);

		if (ch < 0)
			return ch;
		if (ch >= '0' && ch <= '9')
			*hex = (*hex << 4) | (ch - '0');
		else if (ch >= 'a' && ch <= 'f')
			*hex = (*hex << 4) | (ch - 'a' + 10);
		else if (ch >= 'A' && ch <= 'F')
			*hex = (*hex << 4) | (ch - 'A' + 10);
		else if (first_read)
			return -2;
		else
			return ch;
		first_read = false;
	}
}

/* Read a positive decimal value with out argument dec. If the first character
 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
 * character after the decimal value which may be -1 for eof. If the read value
 * is larger than a u64 the high-order bits will be dropped.
 */
static inline int io__get_dec(struct io *io, __u64 *dec)
{
	bool first_read = true;

	*dec = 0;
	while (true) {
		int ch = io__get_char(io);

		if (ch < 0)
			return ch;
		if (ch >= '0' && ch <= '9')
			*dec = (*dec * 10) + ch - '0';
		else if (first_read)
			return -2;
		else
			return ch;
		first_read = false;
	}
}

#endif /* __API_IO__ */
Loading