perf sort: Keep output fields in the same level
authorNamhyung Kim <namhyung@kernel.org>
Fri, 7 Mar 2025 08:08:27 +0000 (00:08 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 20 Mar 2025 16:17:56 +0000 (09:17 -0700)
commita1bbd66627ac2a5c4df6223f6536ac417fdc90a1
treeff71537145694090fc557988b2dc60741c685361
parentf5b07010c13c77541e8ade167d05bef3b8a63739
perf sort: Keep output fields in the same level

This is useful for hierarchy output mode where the first level is
considered as output fields.  We want them in the same level so that it
can show only the remaining groups in the hierarchy.

Before:
  $ perf report -s overhead,sample,period,comm,dso -H --stdio
  ...
  #          Overhead  Samples / Period / Command / Shared Object
  # .................  ..........................................
  #
     100.00%           4035
        100.00%           3835883066
           100.00%           perf
               99.37%           perf
                0.50%           ld-linux-x86-64.so.2
                0.06%           [unknown]
                0.04%           libc.so.6
                0.02%           libLLVM-16.so.1

After:
  $ perf report -s overhead,sample,period,comm,dso -H --stdio
  ...
  #    Overhead       Samples        Period  Command / Shared Object
  # .......................................  .......................
  #
     100.00%          4035    3835883066     perf
         99.37%          4005    3811826223     perf
          0.50%            19      19210014     ld-linux-x86-64.so.2
          0.06%             8       2367089     [unknown]
          0.04%             2       1720336     libc.so.6
          0.02%             1        759404     libLLVM-16.so.1

Acked-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250307080829.354947-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/sort.c