google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.83k stars 353 forks source link

Priority 2147483647 #918

Open wangkai0055 opened 2 hours ago

wangkai0055 commented 2 hours ago

On Android, I can't directly see the cpu set(255) and thread priority information(120).

LalitMaganti commented 2 hours ago

No idea what this issue means. Can you please provide some more information on what you're trying to do and what's not working?

wangkai0055 commented 2 hours ago

perfetto Image old chrome://tracing/ Image

Priority 2147483647

prio: 255300087112,

It looks different. The data(255 112) we need cannot be directly displayed in perfetto.

LalitMaganti commented 2 hours ago

Naively, that looks like a bug in chrome://tracing.

Priority information in Perfetto and chrome://tracing both come from the sched_switch event.

The ftrace format file for sched_switch is given by https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/src/traced/probes/ftrace/test/data/synthetic/events/sched/sched_switch/format;l=1?q=sched_switch%20f:Perfetto%20f:format&sq=

255300087112 is much much bigger than the max value which can be held inside an int (2147483647).

LalitMaganti commented 2 hours ago

Another potential option is that there is some ftrace event other than sched_switch which is feeding priority information to chrome://tracing but is an event we don't take advantage of. This will need some investigation on your side to see if this is the case and let us know what that event is.

Happy to add support for that event if you let me know what that is and it is easy to do so.

wangkai0055 commented 1 hour ago

binder:5315_6-23932 ( 5315) [000] ...1. 1474.636987: binder_set_priority: proc=5315 thread=23932 old=112 => new=120 desired=120 NTQM0_14567_pre-14567 ( 14159) [000] d..2. 1468.681445: sched_waking: comm=Detect_15664 pid=15664 prio=120 target_cpu=001 NTQM0_14567_pre-14567 ( 14159) [000] d..2. 1468.681504: sched_switch: prev_comm=NTQM0_14567_pre prev_pid=14567 prev_prio=000255001047110 prev_state=S ==> next_comm=Detect_15664 next_pid=15664 next_prio=000255301047120 I think it's the sched_switch that's at work.

wangkai0055 commented 1 hour ago

This information is very important, I have to switch from perfetto to trace to check the cpu and priority.

LalitMaganti commented 1 hour ago

I think it's the sched_switch that's at work.

That's only possible if you have a custom sched_switch event in your kernel. The upstream kernel only has an int field for priority not a long

Note that Perfetto reads the binary ftrace format not the textual format so if you are hacking something in the kernel to tweak the priority in the text output Perfetto does not see that

This is not a solvable problem from our side alone: the reading of the binary pipe is fundamental to how ftrace works and we don't receive the data from the kernel to get the full priority.