On Wed, Feb 14, 2024 at 9:24 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote: > > On Tue, Feb 13, 2024 at 10:37:03PM -0800, Ian Rogers wrote: > > Commit 91e467bc568f ("perf machine: Use hashtable for machine > > threads") made the iteration of thread tids unordered. The perf report > > --tasks output now shows child threads in an order determined by the > > hashing. For example, in this snippet tid 3 appears after tid 256 even > > though they have the same ppid 2: > > > > ``` > > $ perf report --tasks > > % pid tid ppid comm > > 0 0 -1 |swapper > > 2 2 0 | kthreadd > > 256 256 2 | kworker/12:1H-k > > 693761 693761 2 | kworker/10:1-mm > > 1301762 1301762 2 | kworker/1:1-mm_ > > 1302530 1302530 2 | kworker/u32:0-k > > 3 3 2 | rcu_gp > > ... > > ``` > > > > The output is easier to read if threads appear numerically > > increasing. To allow for this, read all threads into a list then sort > > with a comparator that orders by the child task's of the first common > > parent. The list creation and deletion are created as utilities on > > machine. The indentation is possible by counting the number of > > parents a child has. > > > > With this change the output for the same data file is now like: > > ``` > > $ perf report --tasks > > % pid tid ppid comm > > 0 0 -1 |swapper > > 1 1 0 | systemd > > 823 823 1 | systemd-journal > > 853 853 1 | systemd-udevd > > 3230 3230 1 | systemd-timesyn > > 3236 3236 1 | auditd > > 3239 3239 3236 | audisp-syslog > > 3321 3321 1 | accounts-daemon > > > Since we're adding extra code for sorting wouldn't be more convenient to > have this done in an graphically hierarchical output? > > But maybe to make this honour asking for a CSV output the above is > enough? Or can we have both, i.e. for people just doing --tasks, the > hirarchical way, for CSV, then like above, with the comma separator. > > But then perf stat has -x to ask for CSV that is used by the more > obscure --exclude-other option :-\ > > Maybe we need a --csv that is consistent accross all tools. I've no objection to a graphical/CSV output, I was in this code as I was restructuring it for memory savings. Fixing the output ordering was a side-effect, the "graphical" sorting/indentation is mentioned as it is carrying forward a behavior from the previous code but done in a somewhat different way. Let's have other output things as follow up work. Thanks, Ian > - Arnaldo