[v2,0/4] perf sched: Fix task state report

Message ID 20240122070859.1394479-2-zegao@tencent.com
Headers
Series perf sched: Fix task state report |

Message

Ze Gao Jan. 22, 2024, 7:08 a.m. UTC
  No functional changes introduced in v2, just got v1 rebased onto
the tip of perf-tools-next for a clean apply.

---

Hi,

The problems of task state report in both libtraceevent
and perf sched has been reported in [1]. In short, they
parsed the wrong state due to relying on the outdated
hardcoded state string to interpret the raw bitmask
from the record, which left the messes to maintain the
backward compatibilities for both tools.

[1] has not managed to make itself into the kernel, the
problems and the solutions are well studied though.

Luckily, as suggested by Steven, perf/libtraceevent
records the print format, especially the __print_flags()
part of the in-kernel tracepoint sched_switch in its
metadata, and we have a chance to build the state str
on the fly by parsing it.

Now that libtraceevent has landed this solution in [2],
we now apply the same idea to perf as well.

Regards,

        -- Ze

[1]: https://lore.kernel.org/lkml/20230803083352.1585-1-zegao@tencent.com/
[2]: https://lore.kernel.org/linux-trace-devel/20231224140732.7d41698d@rorschach.local.home/

Ze Gao (4):
  perf sched: Sync state char array with the kernel
  perf util: Add helpers to parse task state string from libtraceevent
  perf util: Add evsel__taskstate() to parse the task state info instead
  perf sched: Commit to evsel__taskstate() to parse task state info

 tools/perf/builtin-sched.c |  57 +++------------
 tools/perf/util/evsel.c    | 146 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/evsel.h    |   1 +
 3 files changed, 157 insertions(+), 47 deletions(-)
  

Comments

Namhyung Kim Jan. 24, 2024, 12:38 a.m. UTC | #1
On Mon, 22 Jan 2024 02:08:55 -0500, Ze Gao wrote:
> No functional changes introduced in v2, just got v1 rebased onto
> the tip of perf-tools-next for a clean apply.
> 

Applied to perf-tools-next except for the last refactoring one.
I'll test it separately.

Best regards,
  
Ze Gao Jan. 24, 2024, 2:08 a.m. UTC | #2
On Wed, Jan 24, 2024 at 8:38 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Mon, 22 Jan 2024 02:08:55 -0500, Ze Gao wrote:
> > No functional changes introduced in v2, just got v1 rebased onto
> > the tip of perf-tools-next for a clean apply.
> >
>
> Applied to perf-tools-next except for the last refactoring one.
> I'll test it separately.

Awesome!

Thanks,
        -- Ze

> Best regards,
> --
> Namhyung Kim <namhyung@kernel.org>