On 5/31/2018 1:43 AM, Andi Kleen wrote:
On Wed, May 30, 2018 at 10:20:45PM +0800, Jin Yao wrote:
When doing pmu sampling and then running a script with
perf script -s script.py, the process_event function gets
dictionary with some fields from the perf ring buffer
(like ip, sym, callchain etc).

But we miss quite a few fields we report now, for example,
LBRs,data source,weight,transaction,iregs,uregs,and etc.

This patch reports these fields for perf script python
processing.

We need documentation and an example script using it.


OK, I will add an example with some field explanations to Documentation/perf-script-python.txt.

+               PyObject *pyelem;
+
+               pyelem = PyDict_New();
+               if (!pyelem)
+                       Py_FatalError("couldn't create Python dictionary");
+

I think we need a field for the dso here.


I will add new fields "from_dsoname" and "to_dsoname" in v2.

+               pydict_set_item_string_decref(pyelem, "from",
+                   PyLong_FromUnsignedLongLong(br->entries[i].from));
+               pydict_set_item_string_decref(pyelem, "to",
+                   PyLong_FromUnsignedLongLong(br->entries[i].to));
+               pydict_set_item_string_decref(pyelem, "mispred",
+                   PyLong_FromUnsignedLongLong(br->entries[i].flags.mispred));
+               pydict_set_item_string_decref(pyelem, "predicted",
+                   
PyLong_FromUnsignedLongLong(br->entries[i].flags.predicted));
+               pydict_set_item_string_decref(pyelem, "in_tx",
+                   PyLong_FromUnsignedLongLong(br->entries[i].flags.in_tx));
+               pydict_set_item_string_decref(pyelem, "abort",


These could be booleans.

+                   PyLong_FromUnsignedLongLong(br->entries[i].flags.abort));
+               pydict_set_item_string_decref(pyelem, "cycles",
+                   PyLong_FromUnsignedLongLong(br->entries[i].flags.cycles));

I will use PyBool_FromLong() for mispred/predicted/in_tx/abort in v2.


Would be nice to get access to the binary code too (see how perf script
brstackinsn does it). That could be a followon patch.


OK, fine, I will see how perf script brstackinsn does.

Thanks
Jin Yao

Thanks,

-Andi

Reply via email to