• Yang Jihong's avatar
    perf sched timehist: Fix -g/--call-graph option failure · 6e4b3987
    Yang Jihong authored
    When 'perf sched' enables the call-graph recording, sample_type of dummy
    event does not have PERF_SAMPLE_CALLCHAIN, timehist_check_attr() checks
    that the evsel does not have a callchain, and set show_callchain to 0.
    
    Currently 'perf sched timehist' only saves callchain when processing the
    'sched:sched_switch event', timehist_check_attr() only needs to determine
    whether the event has PERF_SAMPLE_CALLCHAIN.
    
    Before:
    
      # perf sched record -g true
      [ perf record: Woken up 0 times to write data ]
      [ perf record: Captured and wrote 4.153 MB perf.data (7536 samples) ]
      # perf sched timehist
      Samples do not have callchains.
                 time    cpu  task name                       wait time  sch delay   run time
                              [tid/pid]                          (msec)     (msec)     (msec)
      --------------- ------  ------------------------------  ---------  ---------  ---------
        147851.826019 [0000]  perf[285035]                        0.000      0.000      0.000
        147851.826029 [0000]  migration/0[15]                     0.000      0.003      0.009
        147851.826063 [0001]  perf[285035]                        0.000      0.000      0.000
        147851.826069 [0001]  migration/1[21]                     0.000      0.003      0.006
      <SNIP>
    
    After:
    
      # perf sched record -g true
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 2.572 MB perf.data (822 samples) ]
      # perf sched timehist
             time cpu task name        waittime  sch delay  runtime
                        [tid/pid]        (msec)  (msec)    (msec)
      ----------- --- ---------------  --------  --------  -----
      4193.035164 [0] perf[277062]        0.000     0.000   0.000 __traceiter_sched_switch <- __traceiter_sched_switch <- __sched_text_start <- preempt_schedule_common <- __cond_resched <- __wait_for_common <- wait_for_completion
      4193.035174 [0] migration/0[15]     0.000     0.003   0.009 __traceiter_sched_switch <- __traceiter_sched_switch <- __sched_text_start <- smpboot_thread_fn <- kthread <- ret_from_fork
      4193.035207 [1] perf[277062]        0.000     0.000   0.000 __traceiter_sched_switch <- __traceiter_sched_switch <- __sched_text_start <- preempt_schedule_common <- __cond_resched <- __wait_for_common <- wait_for_completion
      4193.035214 [1] migration/1[21]     0.000     0.003   0.007 __traceiter_sched_switch <- __traceiter_sched_switch <- __sched_text_start <- smpboot_thread_fn <- kthread <- ret_from_fork
      <SNIP>
    
    Fixes: 9c95e4ef ("perf evlist: Add evlist__findnew_tracking_event() helper")
    Reviewed-by: default avatarIan Rogers <irogers@google.com>
    Signed-off-by: default avatarYang Jihong <yangjihong@bytedance.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Yang Jihong <yangjihong1@huawei.com>
    Link: https://lore.kernel.org/r/20240401062724.1006010-2-yangjihong@bytedance.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    6e4b3987
builtin-sched.c 92.4 KB