Skip to content

Commit

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

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

 - Update vendor events JSON metrics for Intel's Broadwell, Broadwell
   Server, Haswell, Haswell Server, IvyBridge, IvyTown, JakeTown, Sandy
   Bridge, Skylake and SkyLake Server (Andi Kleen)

 - Add vendor event file for Intel's Goldmont Plus V1 (Kan Liang)

 - Move perf_mmap methods from 'perf record' and evlist.c to a separate
   mmap.[ch] pair, to better separate things and pave the way for further
   work on multithreading tools (Arnaldo Carvalho de Melo)

 - Do not check ABI headers in a detached tarball build, as it the kernel
   headers from where we copied tools/include/ are by definition not
   available (Arnaldo Carvalho de Melo)

 - Make 'perf script' use fprintf() like printing, i.e. receiving a FILE
   pointer so that it gets consistent with other tools/ code and allows
   for printing to per-event files (Arnaldo Carvalho de Melo)

 - Error handling fixes (resource release on exit) for 'perf script'
   and 'perf kmem' (Christophe JAILLET)

 - Make some 'perf event attr' tests optional on virtual machines, where
   tested counters are not available (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Oct 24, 2017
2 parents 8776fe7 + 65db92e commit 9b7c854
Show file tree
Hide file tree
Showing 46 changed files with 3,367 additions and 830 deletions.
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ For example Intel Core CPUs typically have four generic performance counters
for the core, plus three fixed counters for instructions, cycles and
ref-cycles. Some special events have restrictions on which counter they
can schedule, and may not support multiple instances in a single group.
When too many events are specified in the group none of them will not
When too many events are specified in the group some of them will not
be measured.

Globally pinned events can limit the number of counters available for
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/arch/arm/annotate/instructions.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <linux/compiler.h>
#include <sys/types.h>
#include <regex.h>

Expand All @@ -23,7 +24,7 @@ static struct ins_ops *arm__associate_instruction_ops(struct arch *arch, const c
return ops;
}

static int arm__annotate_init(struct arch *arch)
static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
{
struct arm_annotate *arm;
int err;
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/arch/arm64/annotate/instructions.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <linux/compiler.h>
#include <sys/types.h>
#include <regex.h>

Expand Down Expand Up @@ -25,7 +26,7 @@ static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const
return ops;
}

static int arm64__annotate_init(struct arch *arch)
static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
{
struct arm64_annotate *arm;
int err;
Expand Down
4 changes: 3 additions & 1 deletion tools/perf/arch/powerpc/annotate/instructions.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <linux/compiler.h>

static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, const char *name)
{
int i;
Expand Down Expand Up @@ -46,7 +48,7 @@ static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, con
return ops;
}

static int powerpc__annotate_init(struct arch *arch)
static int powerpc__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
{
if (!arch->initialized) {
arch->initialized = true;
Expand Down
4 changes: 3 additions & 1 deletion tools/perf/arch/s390/annotate/instructions.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <linux/compiler.h>

static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
{
struct ins_ops *ops = NULL;
Expand All @@ -19,7 +21,7 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na
return ops;
}

static int s390__annotate_init(struct arch *arch)
static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
{
if (!arch->initialized) {
arch->initialized = true;
Expand Down
14 changes: 14 additions & 0 deletions tools/perf/arch/x86/annotate/instructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,17 @@ static int x86__cpuid_parse(struct arch *arch, char *cpuid)

return -1;
}

static int x86__annotate_init(struct arch *arch, char *cpuid)
{
int err = 0;

if (arch->initialized)
return 0;

if (cpuid)
err = x86__cpuid_parse(arch, cpuid);

arch->initialized = true;
return err;
}
3 changes: 2 additions & 1 deletion tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,8 @@ int cmd_kmem(int argc, const char **argv)

if (perf_time__parse_str(&ptime, time_str) != 0) {
pr_err("Invalid time string\n");
return -EINVAL;
ret = -EINVAL;
goto out_delete;
}

if (!strcmp(argv[0], "stat")) {
Expand Down
104 changes: 4 additions & 100 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,107 +129,12 @@ static int process_synthesized_event(struct perf_tool *tool,
return record__write(rec, event, event->header.size);
}

static int
backward_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end)
{
struct perf_event_header *pheader;
u64 evt_head = head;
int size = mask + 1;

pr_debug2("backward_rb_find_range: buf=%p, head=%"PRIx64"\n", buf, head);
pheader = (struct perf_event_header *)(buf + (head & mask));
*start = head;
while (true) {
if (evt_head - head >= (unsigned int)size) {
pr_debug("Finished reading backward ring buffer: rewind\n");
if (evt_head - head > (unsigned int)size)
evt_head -= pheader->size;
*end = evt_head;
return 0;
}

pheader = (struct perf_event_header *)(buf + (evt_head & mask));

if (pheader->size == 0) {
pr_debug("Finished reading backward ring buffer: get start\n");
*end = evt_head;
return 0;
}

evt_head += pheader->size;
pr_debug3("move evt_head: %"PRIx64"\n", evt_head);
}
WARN_ONCE(1, "Shouldn't get here\n");
return -1;
}

static int
rb_find_range(void *data, int mask, u64 head, u64 old,
u64 *start, u64 *end, bool backward)
static int record__pushfn(void *to, void *bf, size_t size)
{
if (!backward) {
*start = old;
*end = head;
return 0;
}

return backward_rb_find_range(data, mask, head, start, end);
}

static int
record__mmap_read(struct record *rec, struct perf_mmap *md,
bool overwrite, bool backward)
{
u64 head = perf_mmap__read_head(md);
u64 old = md->prev;
u64 end = head, start = old;
unsigned char *data = md->base + page_size;
unsigned long size;
void *buf;
int rc = 0;

if (rb_find_range(data, md->mask, head,
old, &start, &end, backward))
return -1;

if (start == end)
return 0;
struct record *rec = to;

rec->samples++;

size = end - start;
if (size > (unsigned long)(md->mask) + 1) {
WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");

md->prev = head;
perf_mmap__consume(md, overwrite || backward);
return 0;
}

if ((start & md->mask) + size != (end & md->mask)) {
buf = &data[start & md->mask];
size = md->mask + 1 - (start & md->mask);
start += size;

if (record__write(rec, buf, size) < 0) {
rc = -1;
goto out;
}
}

buf = &data[start & md->mask];
size = end - start;
start += size;

if (record__write(rec, buf, size) < 0) {
rc = -1;
goto out;
}

md->prev = head;
perf_mmap__consume(md, overwrite || backward);
out:
return rc;
return record__write(rec, bf, size);
}

static volatile int done;
Expand Down Expand Up @@ -576,8 +481,7 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
struct auxtrace_mmap *mm = &maps[i].auxtrace_mmap;

if (maps[i].base) {
if (record__mmap_read(rec, &maps[i],
evlist->overwrite, backward) != 0) {
if (perf_mmap__push(&maps[i], evlist->overwrite, backward, rec, record__pushfn) != 0) {
rc = -1;
goto out;
}
Expand Down
Loading

0 comments on commit 9b7c854

Please sign in to comment.