Patch "perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-sched-timehist-fixed-timestamp-error-when-unabl.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9488e25cbecacbcf7a90b4f16720333cd9a8871f
Author: Yang Jihong <yangjihong@xxxxxxxxxxxxx>
Date:   Mon Aug 19 10:47:20 2024 +0800

    perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time
    
    [ Upstream commit 39c243411bdb8fb35777adf49ee32549633c4e12 ]
    
    If sched_in event for current task is not recorded, sched_in timestamp
    will be set to end_time of time window interest, causing an error in
    timestamp show. In this case, we choose to ignore this event.
    
    Test scenario:
    
      perf[1229608] does not record the first sched_in event, run time and sch delay are both 0
    
      # perf sched timehist
      Samples of sched_switch event do not have callchains.
                 time    cpu  task name                       wait time  sch delay   run time
                              [tid/pid]                          (msec)     (msec)     (msec)
      --------------- ------  ------------------------------  ---------  ---------  ---------
       2090450.763231 [0000]  perf[1229608]                       0.000      0.000      0.000
       2090450.763235 [0000]  migration/0[15]                     0.000      0.001      0.003
       2090450.763263 [0001]  perf[1229608]                       0.000      0.000      0.000
       2090450.763268 [0001]  migration/1[21]                     0.000      0.001      0.004
       2090450.763302 [0002]  perf[1229608]                       0.000      0.000      0.000
       2090450.763309 [0002]  migration/2[27]                     0.000      0.001      0.007
       2090450.763338 [0003]  perf[1229608]                       0.000      0.000      0.000
       2090450.763343 [0003]  migration/3[33]                     0.000      0.001      0.004
    
    Before:
    
      arbitrarily specify a time window of interest, timestamp will be set to an incorrect value
    
      # perf sched timehist --time 100,200
      Samples of sched_switch event do not have callchains.
                 time    cpu  task name                       wait time  sch delay   run time
                              [tid/pid]                          (msec)     (msec)     (msec)
      --------------- ------  ------------------------------  ---------  ---------  ---------
           200.000000 [0000]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0001]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0002]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0003]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0004]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0005]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0006]  perf[1229608]                       0.000      0.000      0.000
           200.000000 [0007]  perf[1229608]                       0.000      0.000      0.000
    
     After:
    
      # perf sched timehist --time 100,200
      Samples of sched_switch event do not have callchains.
                 time    cpu  task name                       wait time  sch delay   run time
                              [tid/pid]                          (msec)     (msec)     (msec)
      --------------- ------  ------------------------------  ---------  ---------  ---------
    
    Fixes: 853b74071110bed3 ("perf sched timehist: Add option to specify time window of interest")
    Signed-off-by: Yang Jihong <yangjihong@xxxxxxxxxxxxx>
    Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
    Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
    Cc: David Ahern <dsa@xxxxxxxxxxxxxxxxxxx>
    Cc: Ian Rogers <irogers@xxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: James Clark <james.clark@xxxxxxx>
    Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
    Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
    Cc: Mark Rutland <mark.rutland@xxxxxxx>
    Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240819024720.2405244-1-yangjihong@xxxxxxxxxxxxx
    Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 1c9e06c1d0089..cf8dc3910ef21 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2553,9 +2553,12 @@ static int timehist_sched_change_event(struct perf_tool *tool,
 	 * - previous sched event is out of window - we are done
 	 * - sample time is beyond window user cares about - reset it
 	 *   to close out stats for time window interest
+	 * - If tprev is 0, that is, sched_in event for current task is
+	 *   not recorded, cannot determine whether sched_in event is
+	 *   within time window interest - ignore it
 	 */
 	if (ptime->end) {
-		if (tprev > ptime->end)
+		if (!tprev || tprev > ptime->end)
 			goto out;
 
 		if (t > ptime->end)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux