linuxperf

What does `TASK_REPORT_MAX` from the `sched.h` serve for on Linux?


I am using the perf trace -bla-bla-bla -e sched:sched_switch on a 5.15.53 kernel, however looks like it is not configured to populate all the trace fields.

trace/events/sched.h does publish the prev_state=%s%s, nevertheless I can not get why exactly does the TASK_REPORT_MAX - 1 exist there? This macro has no docs on it, nor it is clear for me from the source code what great purpose it serves.

perf trace ... output shows something like:

 0.000 Timer/19125 sched:sched_switch(prev_comm: "Timer", prev_pid: 19125 (Timer), prev_prio: 120, prev_state: 1, next_comm: "swapper/2", next_prio: 120)

Note: prev_state: 1. 1 is definitely not what I would expect to see there based on the link above I've sent. Do I deal with a misconfigured kernel?


Solution

  • These are the defined bit values for task->state: https://elixir.bootlin.com/linux/v5.15.53/source/include/linux/sched.h#L83

    Among them, only the lower 8 bits are "public" (meaningful for userspace). TASK_REPORT_MAX - 1 mask is used to keep only these bits.

    prev_state: 1 means TASK_INTERRUPTIBLE