Merge tag 'perf-core-for-mingo-4.20-20181008' 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 building the python bindings with python3, which fixes some problems with building with clang on Clear Linux (Eduardo Habkost) - Fix coverity warnings, fixing up some error paths and plugging some temporary small buffer leaks (Sanskriti Sharma) - Adopt a wrapper for strerror_r() for the same reasons as recently for libbpf (Steven Rostedt) - S390 does not support watchpoints in perf test 22', check if that test is supported by the arch. (Thomas Richter) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <linux/list.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/types.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
#include "../perf.h"
|
||||
#include "event.h"
|
||||
|
@@ -5,16 +5,18 @@ from subprocess import Popen, PIPE
|
||||
from re import sub
|
||||
|
||||
def clang_has_option(option):
|
||||
return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
|
||||
return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ]
|
||||
|
||||
cc = getenv("CC")
|
||||
if cc == "clang":
|
||||
from _sysconfigdata import build_time_vars
|
||||
build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
|
||||
if not clang_has_option("-mcet"):
|
||||
build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
|
||||
if not clang_has_option("-fcf-protection"):
|
||||
build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"])
|
||||
from distutils.sysconfig import get_config_vars
|
||||
vars = get_config_vars()
|
||||
for var in ('CFLAGS', 'OPT'):
|
||||
vars[var] = sub("-specs=[^ ]+", "", vars[var])
|
||||
if not clang_has_option("-mcet"):
|
||||
vars[var] = sub("-mcet", "", vars[var])
|
||||
if not clang_has_option("-fcf-protection"):
|
||||
vars[var] = sub("-fcf-protection", "", vars[var])
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
|
@@ -98,19 +98,25 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
|
||||
|
||||
va_copy(ap_saved, ap);
|
||||
len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
|
||||
if (len < 0)
|
||||
if (len < 0) {
|
||||
va_end(ap_saved);
|
||||
return len;
|
||||
}
|
||||
if (len > strbuf_avail(sb)) {
|
||||
ret = strbuf_grow(sb, len);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
va_end(ap_saved);
|
||||
return ret;
|
||||
}
|
||||
len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
|
||||
va_end(ap_saved);
|
||||
if (len > strbuf_avail(sb)) {
|
||||
pr_debug("this should not happen, your vsnprintf is broken");
|
||||
va_end(ap_saved);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
va_end(ap_saved);
|
||||
return strbuf_setlen(sb, sb->len + len);
|
||||
}
|
||||
|
||||
|
@@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs,
|
||||
"/tmp/perf-XXXXXX");
|
||||
if (!mkstemp(tdata->temp_file)) {
|
||||
pr_debug("Can't make temp file");
|
||||
free(tdata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
temp_fd = open(tdata->temp_file, O_RDWR);
|
||||
if (temp_fd < 0) {
|
||||
pr_debug("Can't read '%s'", tdata->temp_file);
|
||||
free(tdata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -37,10 +37,11 @@ static int get_common_field(struct scripting_context *context,
|
||||
struct tep_format_field *field;
|
||||
|
||||
if (!*size) {
|
||||
if (!pevent->events)
|
||||
|
||||
event = tep_get_first_event(pevent);
|
||||
if (!event)
|
||||
return 0;
|
||||
|
||||
event = pevent->events[0];
|
||||
field = tep_find_common_field(event, type);
|
||||
if (!field)
|
||||
return 0;
|
||||
@@ -158,6 +159,7 @@ void parse_ftrace_printk(struct tep_handle *pevent,
|
||||
printk = strdup(fmt+1);
|
||||
line = strtok_r(NULL, "\n", &next);
|
||||
tep_register_print_string(pevent, printk, addr);
|
||||
free(printk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,25 +194,29 @@ struct tep_event_format *trace_find_next_event(struct tep_handle *pevent,
|
||||
struct tep_event_format *event)
|
||||
{
|
||||
static int idx;
|
||||
int events_count;
|
||||
struct tep_event_format *all_events;
|
||||
|
||||
if (!pevent || !pevent->events)
|
||||
all_events = tep_get_first_event(pevent);
|
||||
events_count = tep_get_events_count(pevent);
|
||||
if (!pevent || !all_events || events_count < 1)
|
||||
return NULL;
|
||||
|
||||
if (!event) {
|
||||
idx = 0;
|
||||
return pevent->events[0];
|
||||
return all_events;
|
||||
}
|
||||
|
||||
if (idx < pevent->nr_events && event == pevent->events[idx]) {
|
||||
if (idx < events_count && event == (all_events + idx)) {
|
||||
idx++;
|
||||
if (idx == pevent->nr_events)
|
||||
if (idx == events_count)
|
||||
return NULL;
|
||||
return pevent->events[idx];
|
||||
return (all_events + idx);
|
||||
}
|
||||
|
||||
for (idx = 1; idx < pevent->nr_events; idx++) {
|
||||
if (event == pevent->events[idx - 1])
|
||||
return pevent->events[idx];
|
||||
for (idx = 1; idx < events_count; idx++) {
|
||||
if (event == (all_events + (idx - 1)))
|
||||
return (all_events + idx);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -241,7 +241,7 @@ static int read_header_files(struct tep_handle *pevent)
|
||||
* The commit field in the page is of type long,
|
||||
* use that instead, since it represents the kernel.
|
||||
*/
|
||||
tep_set_long_size(pevent, pevent->header_page_size_size);
|
||||
tep_set_long_size(pevent, tep_get_header_page_size(pevent));
|
||||
}
|
||||
free(header_page);
|
||||
|
||||
@@ -297,10 +297,8 @@ static int read_event_file(struct tep_handle *pevent, char *sys,
|
||||
}
|
||||
|
||||
ret = do_read(buf, size);
|
||||
if (ret < 0) {
|
||||
free(buf);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = parse_event_file(pevent, buf, size, sys);
|
||||
if (ret < 0)
|
||||
@@ -349,9 +347,12 @@ static int read_event_files(struct tep_handle *pevent)
|
||||
for (x=0; x < count; x++) {
|
||||
size = read8(pevent);
|
||||
ret = read_event_file(pevent, sys, size);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
free(sys);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
free(sys);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user