Commit d17cccbe authored by Ingo Molnar's avatar Ingo Molnar

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

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

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

* Fix up /proc/PID/maps parsing, where perfectly fine mmap entries
  were being trown away when synthesizing PERF_RECORD_MMAP for
  preexisting threads, prevenging symbol resolution to work
  for those threads, broken in the MMAP2 removal. Reported and
  pinpointed by Markus Trippelsdorf,

* Fix mem leak in the python 'perf script' backend, due to missing Py_DECREFs
  on dict entries, fix from Joseph Schuchart.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 959f5854 2fd869f0
...@@ -213,7 +213,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, ...@@ -213,7 +213,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
&event->mmap.pgoff, &event->mmap.pgoff,
execname); execname);
if (n != 8) if (n != 5)
continue; continue;
if (prot[2] != 'x') if (prot[2] != 'x')
......
...@@ -56,6 +56,17 @@ static void handler_call_die(const char *handler_name) ...@@ -56,6 +56,17 @@ static void handler_call_die(const char *handler_name)
Py_FatalError("problem in Python trace event handler"); Py_FatalError("problem in Python trace event handler");
} }
/*
* Insert val into into the dictionary and decrement the reference counter.
* This is necessary for dictionaries since PyDict_SetItemString() does not
* steal a reference, as opposed to PyTuple_SetItem().
*/
static void pydict_set_item_string_decref(PyObject *dict, const char *key, PyObject *val)
{
PyDict_SetItemString(dict, key, val);
Py_DECREF(val);
}
static void define_value(enum print_arg_type field_type, static void define_value(enum print_arg_type field_type,
const char *ev_name, const char *ev_name,
const char *field_name, const char *field_name,
...@@ -279,11 +290,11 @@ static void python_process_tracepoint(union perf_event *perf_event ...@@ -279,11 +290,11 @@ static void python_process_tracepoint(union perf_event *perf_event
PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); PyTuple_SetItem(t, n++, PyInt_FromLong(pid));
PyTuple_SetItem(t, n++, PyString_FromString(comm)); PyTuple_SetItem(t, n++, PyString_FromString(comm));
} else { } else {
PyDict_SetItemString(dict, "common_cpu", PyInt_FromLong(cpu)); pydict_set_item_string_decref(dict, "common_cpu", PyInt_FromLong(cpu));
PyDict_SetItemString(dict, "common_s", PyInt_FromLong(s)); pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s));
PyDict_SetItemString(dict, "common_ns", PyInt_FromLong(ns)); pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns));
PyDict_SetItemString(dict, "common_pid", PyInt_FromLong(pid)); pydict_set_item_string_decref(dict, "common_pid", PyInt_FromLong(pid));
PyDict_SetItemString(dict, "common_comm", PyString_FromString(comm)); pydict_set_item_string_decref(dict, "common_comm", PyString_FromString(comm));
} }
for (field = event->format.fields; field; field = field->next) { for (field = event->format.fields; field; field = field->next) {
if (field->flags & FIELD_IS_STRING) { if (field->flags & FIELD_IS_STRING) {
...@@ -313,7 +324,7 @@ static void python_process_tracepoint(union perf_event *perf_event ...@@ -313,7 +324,7 @@ static void python_process_tracepoint(union perf_event *perf_event
if (handler) if (handler)
PyTuple_SetItem(t, n++, obj); PyTuple_SetItem(t, n++, obj);
else else
PyDict_SetItemString(dict, field->name, obj); pydict_set_item_string_decref(dict, field->name, obj);
} }
if (!handler) if (!handler)
...@@ -370,21 +381,21 @@ static void python_process_general_event(union perf_event *perf_event ...@@ -370,21 +381,21 @@ static void python_process_general_event(union perf_event *perf_event
if (!handler || !PyCallable_Check(handler)) if (!handler || !PyCallable_Check(handler))
goto exit; goto exit;
PyDict_SetItemString(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
PyDict_SetItemString(dict, "attr", PyString_FromStringAndSize( pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
(const char *)&evsel->attr, sizeof(evsel->attr))); (const char *)&evsel->attr, sizeof(evsel->attr)));
PyDict_SetItemString(dict, "sample", PyString_FromStringAndSize( pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize(
(const char *)sample, sizeof(*sample))); (const char *)sample, sizeof(*sample)));
PyDict_SetItemString(dict, "raw_buf", PyString_FromStringAndSize( pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
(const char *)sample->raw_data, sample->raw_size)); (const char *)sample->raw_data, sample->raw_size));
PyDict_SetItemString(dict, "comm", pydict_set_item_string_decref(dict, "comm",
PyString_FromString(thread->comm)); PyString_FromString(thread->comm));
if (al->map) { if (al->map) {
PyDict_SetItemString(dict, "dso", pydict_set_item_string_decref(dict, "dso",
PyString_FromString(al->map->dso->name)); PyString_FromString(al->map->dso->name));
} }
if (al->sym) { if (al->sym) {
PyDict_SetItemString(dict, "symbol", pydict_set_item_string_decref(dict, "symbol",
PyString_FromString(al->sym->name)); PyString_FromString(al->sym->name));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment