mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
perf report: Sort child tasks by tid
Commit91e467bc56("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-mm130176213017622 | 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 ... ``` Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20240301053646.1449657-2-irogers@google.com
This commit is contained in:
@@ -280,6 +280,16 @@ int machines__for_each_thread(struct machines *machines,
|
||||
int (*fn)(struct thread *thread, void *p),
|
||||
void *priv);
|
||||
|
||||
struct thread_list {
|
||||
struct list_head list;
|
||||
struct thread *thread;
|
||||
};
|
||||
|
||||
/* Make a list of struct thread_list based on threads in the machine. */
|
||||
int machine__thread_list(struct machine *machine, struct list_head *list);
|
||||
/* Free up the nodes within the thread_list list. */
|
||||
void thread_list__delete(struct list_head *list);
|
||||
|
||||
pid_t machine__get_current_tid(struct machine *machine, int cpu);
|
||||
int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
|
||||
pid_t tid);
|
||||
|
||||
Reference in New Issue
Block a user