mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
perf tools: Support reading PERF_FORMAT_LOST
The recent kernel added lost count can be read from either read(2) or ring buffer data with PERF_SAMPLE_READ. As it's a variable length data we need to access it according to the format info. But for perf tools use cases, PERF_FORMAT_ID is always set. So we can only check PERF_FORMAT_LOST bit to determine the data format. Add sample_read_value_size() and next_sample_read_value() helpers to make it a bit easier to access. Use them in all places where it reads the struct sample_read_value. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20220819003644.508916-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
6d395a5135
commit
f52679b788
6 changed files with 108 additions and 42 deletions
|
@ -642,15 +642,19 @@ exit:
|
|||
return pylist;
|
||||
}
|
||||
|
||||
static PyObject *get_sample_value_as_tuple(struct sample_read_value *value)
|
||||
static PyObject *get_sample_value_as_tuple(struct sample_read_value *value,
|
||||
u64 read_format)
|
||||
{
|
||||
PyObject *t;
|
||||
|
||||
t = PyTuple_New(2);
|
||||
t = PyTuple_New(3);
|
||||
if (!t)
|
||||
Py_FatalError("couldn't create Python tuple");
|
||||
PyTuple_SetItem(t, 0, PyLong_FromUnsignedLongLong(value->id));
|
||||
PyTuple_SetItem(t, 1, PyLong_FromUnsignedLongLong(value->value));
|
||||
if (read_format & PERF_FORMAT_LOST)
|
||||
PyTuple_SetItem(t, 2, PyLong_FromUnsignedLongLong(value->lost));
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -681,12 +685,17 @@ static void set_sample_read_in_dict(PyObject *dict_sample,
|
|||
Py_FatalError("couldn't create Python list");
|
||||
|
||||
if (read_format & PERF_FORMAT_GROUP) {
|
||||
for (i = 0; i < sample->read.group.nr; i++) {
|
||||
PyObject *t = get_sample_value_as_tuple(&sample->read.group.values[i]);
|
||||
struct sample_read_value *v = sample->read.group.values;
|
||||
|
||||
i = 0;
|
||||
sample_read_group__for_each(v, sample->read.group.nr, read_format) {
|
||||
PyObject *t = get_sample_value_as_tuple(v, read_format);
|
||||
PyList_SET_ITEM(values, i, t);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
PyObject *t = get_sample_value_as_tuple(&sample->read.one);
|
||||
PyObject *t = get_sample_value_as_tuple(&sample->read.one,
|
||||
read_format);
|
||||
PyList_SET_ITEM(values, 0, t);
|
||||
}
|
||||
pydict_set_item_string_decref(dict_sample, "values", values);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue