目录
-
eas_one_small_task
setup阶段:
- configure and enable tracing(/sys/kernel/tracing):
- 分析解析后的trace
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- echo 0 > tracing_on //disable tracing
- 创建一个while(1) task eas_one_small_t,每sleep 1ms起来运行一下,5s后结束。
- echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == small_task_tid获得task eas_one_small_t的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid != small_task_tid获得task eas_one_small_t的结束running时间;
- 统计所有running时间段的时间和
- 通过capacity获取小核的cpuset,当trace发生在小核时,累加running时间到小核correct_us;累加所有running时间到total_us;
- correct_us/total_us ≥ 90% ? pass : fail
即当task在小核累加运行时间占总运行时间的90%以上时,case测试通过
sh-4.4# ./eas_one_small_task
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_one_small_task.c:94: INFO: Minimum correct cluster time percentage: 90%
Small task executing for 5s...
Total time task scheduled: 108208 usec
Time scheduled on a little CPU: 108208 usec (100%)
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_one_small_task.c:113: PASS: Small task ran appropriately on small CPUs.
Summary:
passed 1
failed 0
skipped 0
warnings 0
sh-4.4#
-
eas_one_big_task
setup阶段:
- configure and enable tracing(/sys/kernel/tracing):
- 分析解析后的trace
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- echo 0 > tracing_on //disable tracing
- 创建一个while(1) task eas_one_big_tas,持续运行3s后结束。
- echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == big_task_tid获得task eas_one_big_tas的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid != big_task_tid获得task eas_one_big_tas的结束running时间;
- 通过1/2中记录的时间戳,计算一个running时间段的时间
- 通过capacity获取大核的cpuset,当trace发生在大核时,累加running时间到大核correct_us;累加所有running时间到total_us;
- 记录task eas_one_big_tas开始执行的时间:start_ts_usec
记录task eas_one_big_tas开始在大核执行的时间:upmigration_ts_usec
计算task eas_one_big_tas从开始执行到迁移到大核的延时:upmigration_latency_usec= upmigration_ts_usec – start_ts_usec - correct_us/total_us ≥ 90% ? pass : fail
即当task在小核累加运行时间占总运行时间的90%以上时,case测试通过
sh-4.4# ./eas_one_big_task
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_one_big_task.c:109: INFO: Minimum correct cluster time percentage: 90%
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_one_big_task.c:111: INFO: Maximum upmigration latency: 100000 usec
Big task executing for 3s...
Total time task scheduled: 3000382 usec
Time scheduled on a big CPU: 2977518 usec (99%)
Upmigration latency: 22965 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_one_big_task.c:132: PASS: Task placement/migration latency met requirements.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
eas_small_to_big
setup阶段:
- configure and enable tracing(/sys/kernel/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a) 创建一个 task eas_small_to_bi,作为小task每sleep 1ms起来运行一下,持续3s;
b) 在trace中打印“CPU HOG”的trace marker;
c) 作为一个大task持续运行3s后结束。 - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task eas_small_to_bi的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task eas_small_to_bi的结束running时间;
- 通过1/2中记录的时间戳,计算一个running时间段的时间
- 记录“CPU HOG”Trace marker时间戳:cpuhog_ts_usec;
记录task迁移到大核刚开始running的时间戳:upmigrate_ts_usec (在cpuhog_ts_usec之后第一个<t->next_pid == task_tid> 且不在小核上的
trace log对应的时间戳) - 记录大task在upmigration后,在小核错误的运行时间:too_small_cpu_us (在cpuhog_ts_usec及upmigrate_ts_usec时间之后,此时task已经是big task,task在小核的运行时间);
- 记录小task在大核的运行时间:too_big_cpu_us (在cpuhog_ts_usec之前,task是small task)
- 记录big task的running时间:big_task_us (在小核和大核上big task running的所有时间)
- 记录small task的running时间:small_task_us (在小核和大核上small task running的所有时间)
- 计算大task upmigration的delay时间:upmigration_ts_usec
- (too_big_cpu_us/small_task_us > 10% || too_small_cpu_us/big_task_us > 10% || upmigration_ts_usec > 100ms) ? fail : pass
即小task在大核运行时间占小task总运行时间的10%以下,大task在upmigration后在小核的运行时间占大task总运行时间的10%一下,并且大task的upmigration delay小于100ms时,case测试通过
sh-4.4# ./eas_small_to_big
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_to_big.c:144: INFO: Maximum incorrect cluster time percentage: 10%
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_to_big.c:146: INFO: Maximum upmigration latency: 100000 usec
Small task executing for 3s...
Changing to big task...
Time incorrectly scheduled on big when task was small: 0 usec (0% of small task CPU time)
Time incorrectly scheduled on small when task was big, after upmigration: 0 usec (0% of big task CPU time)
Upmigration latency: 29516 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_to_big.c:167: PASS: Task placement and migration latency goals were met.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
eas_big_to_small
setup阶段:
- configure and enable tracing(/sys/kernel/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a) 创建一个 task eas_big_to_smal,作为一个大task持续运行3s;
b) 在trace中打印“SMALL TASK”的trace marker;
c) 作为小task每sleep 1ms起来运行一下,持续3s后结束。 - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task eas_big_to_smal的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task eas_big_to_smal的结束running时间;
- 通过1/2中记录的时间戳,计算一个running时间段的时间
- 记录“SMALL TASK”Trace marker时间戳:smalltask_tm_usec;
记录小task开始running的时间戳:smalltask_ts_usec (在smalltask_tm_usec之后第一个<t->next_pid == task_tid> trace log对应的时间戳)
记录小task开始在小核ruuning的时间戳:downmigrate_ts_usec (在smalltask_ts_usec之后第一个在小核的<t->next_pid == task_tid> trace log对应的时间戳) - 记录大task在小核的运行时间:too_small_cpu_us (在smalltask_ts_usec之前是大task,作为大task在小核运行的时间);
- 记录小task在大核的运行时间:too_big_cpu_us (在smalltask_ts_usec之后是小task,并且在downmigrate_ts_usec之后,即小task down migrate到小核之后,又错误的在大核运行的时间)
- 记录big task的running时间:big_task_us (在小核和大核上big task running的所有时间)
- 记录small task的running时间:small_task_us (在小核和大核上small task running的所有时间)
- 计算变为小task后 down migration的delay时间:downmigrate_latency_usec = downmigrate_ts_usec - smalltask_ts_usec
- (too_big_cpu_us/small_task_us > 10% || too_small_cpu_us/big_task_us > 10% || downmigrate_latency_usec > 100ms) ? fail : pass
即小task在大核运行时间占小task总运行时间的10%以下,大task在upmigration后在小核的运行时间占大task总运行时间的10%一下,并且小task的downmigration delay小于100ms时,case测试通过
sh-4.4# ./eas_big_to_small
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_big_to_small.c:144: INFO: Maximum incorrect cluster time percentage: 10%
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_big_to_small.c:146: INFO: Maximum downmigration latency: 100000 usec
Big task executing for 3s...
Changing to small task...
Time incorrectly scheduled on small when task was big: 22493 usec (0% of big task CPU time)
Time incorrectly scheduled on big when task was small, after downmigration: 0 usec (0% of small task CPU time)
Downmigration latency: 98975 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_big_to_small.c:167: PASS: Task placement/migration latency goals met.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
eas_small_big_toggle
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a) 创建一个 task eas_small_big_t;
b) 在trace中打印“SMALL TASK”的trace marker;
c) 作为小task(每sleep 1ms起来运行一下),持续1s;
d) 在trace中打印“CPU HOG” trace marker;
e) 作为大task(持续)运行1s;
f) 重复c/d 10次 - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task eas_small_big_t的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task eas_small_big_t的结束running时间;
- 通过1/2中记录的时间戳,计算一个running时间段的时间
- a) 记录每个cycle中大task开始running的时间戳:cpuhog_ts_usec (“CPU HOG”Trace marker时间戳);
b) 记录每个cycle中小task开始running的时间戳:smalltask_ts_usec(”SMALL TASK”Trace marker对应的时间戳)
c) 记录每个cycle中小task开始在小核ruuning的时间戳:downmigrate_ts_usec (在”SMALL TASK”tracer marker之后第一个在小核的<t->next_pid == task_tid> trace log对应的时间戳)
d) 记录每个cycle中大task开始在大核running的时间戳:upmigrate_ts_usec (在”CPU HOG”tracer marker之后第一个在大核的<t->next_pid == task_tid> trace log对应的时间戳) - a) 在“CPU HOG” trace marker时间点,计算当前cycle中小task downmigrate latency = downmigrate_ts_usec - smalltask_ts_usec,计算完成后为下一个cycle记录downmigrate_ts_usec和smalltask_ts_usec将它们置零。取所有cycle中的最大值:max_downmigrate_lantency_usec
b) 在“SMALL TASK” trace marker时间点,计算此时间点前一个cycle中,大task upmigrate latency = upmigrate_ts_usec - cpuhog_ts_usec,计算完成后为记录当前cycle的upmigrate_ts_usec和cpuhog_ts_usec将它们置零。取所有cycle中的最大值:max_upmigrate_lantency_usec
- 累加大task在小核的运行时间:too_small_cpu_us (在“CPU HOG” trace marker之后作为大task run,且在upmigrate_ts_usec迁移到大核之后,错误的在小核运行的时间)
- 记录小task在大核的运行时间:too_big_cpu_us (在SMALL TASK” trace marker之后作为小task run,且在downmigrate_ts_usec迁移到小核之后,错误的在大核运行的时间)
- 记录big task的running时间:big_task_us (在小核和大核上big task running的所有时间)
- 记录small task的running时间:small_task_us (在小核和大核上small task running的所有时间)
- (too_big_cpu_us/small_task_us > 10% || too_small_cpu_us/big_task_us > 10% || max_downmigrate_latency_usec > 100ms) || max_upmigrate_lantency_usec > 100ms ? fail : pass
即小task在大核运行时间占小task总运行时间的10%以下,大task在upmigration后在小核的运行时间占大task总运行时间的10%以下,并且小task的最大downmigration delay小于100ms时,大task的最大upmigration delay小于100ms,case测试通过
sh-4.4# ./eas_small_big_toggle
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_big_toggle.c:197: INFO: Maximum incorrect cluster time percentage: 10%
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_big_toggle.c:199: INFO: Maximum downmigration latency: 100000 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_big_toggle.c:201: INFO: Maximum upmigration latency: 100000 usec
Task alternating between big and small for 20 sec
Time incorrectly scheduled on big when task was small, after downmigration: 0 usec (0% of small task CPU time)
Time incorrectly scheduled on small when task was big, after upmigration: 0 usec (0% of big task CPU time)
small task time: 840238
big task time: 9357025
Maximum upmigration time: 30498
Maximum downmigration time: 106469
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_small_big_toggle.c:222: FAIL: Task placement and migration latency goals were not met.
Summary:
passed 0
failed 1
skipped 0
warnings 0
-
eas_two_big_three_small
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - 创建5个 task eas_two_big_thr, 两个大task和三个小task,都运行3s;
- echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段(分别对每个task):
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task eas_two_big_thr的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task eas_two_big_thr的结束running时间;
- 通过1/2中记录的时间戳,计算task一个running时间段的时间:segment_us
- 累加大task在小核的运行时间:incorrect_us[j] (4≥ j ≥ 3);
累加小task在大核的运行时间:incorrect_us[j] (2≥ j ≥ 0) - 记录各个task running的总时间:total_us[j]
- (incorrect_us[j]/total_us[j] > 10%) ? fail : true
分别计算每个task在错误cpu(大task在小核上运行,小task在大核上运行)上运行的时间占该task总运行时间的10%以下,即为pass
4.1.2 测试结果
sh-4.4# ./eas_two_big_three_small
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_two_big_three_small.c:114: INFO: Maximum incorrect cluster time percentage: 10%
Tasks running for 3 sec
Total time little task scheduled: 74833 Time scheduled on big CPU: 0 (0%)
Total time little task scheduled: 74548 Time scheduled on big CPU: 0 (0%)
Total time little task scheduled: 74580 Time scheduled on big CPU: 0 (0%)
Total time big task scheduled: 2999467 Time scheduled on little CPU: 18015 (0%)
Total time big task scheduled: 2999750 Time scheduled on little CPU: 18013 (0%)
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/eas_two_big_three_small.c:137: PASS: Task placement goals were met.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_cfs_prio
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - 创建4个 cfs task sched_cfs_prio, 优先级分别为[-15, -5, 5, 15],设置cpu affinity在cpu0,5s后退出;
- echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段(分别对每个task):
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task eas_cfs_prio的开始running时间;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task eas_cfs_prio的结束running时间;
- 通过1/2中记录的时间戳,计算task一个running时间段的时间:segment_us
- 分别累加每个task的运行时间;
- 记录各个task running的总时间:total_us[j]
- 根据task在user space的nice值对应在kernel中的权重:
-15:29154
-5:3121
5:335
15:36
sum of weights:29154+3121+335+36=32646
计算每个task期望的运行时间:
29154/32646 = 89.3%,4465ms
3121/32646 = 9.56%,478ms
335/32646 = 1.02%,51ms
36/32646 = 0.11%, 5.5ms - 定义lower_bound和upper_bound,如果task的运行时间runtime_us:upper_bound ≥ runtime_us ≥ lower_bound,即为pass
lower_bound: max{(lower_bound_us = expected_us - 20000us) (lower_bound_pct = expected_us * 80%)}
upper_bound:max{(upper_bound_us = expected_us + 30000us) (upper_bound_pct = expected_us * 105%)}
sh-4.4# ./sched_cfs_prio
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
Running 4 CFS tasks concurrently for 5 sec
Task runtimes:
Task a (nice -15): 4476 ms (expected 4465 ms)
Task b (nice -5) : 478 ms (expected 478 ms)
Task c (nice 5) : 76 ms (expected 51 ms)
Task d (nice 15) : 12 ms (expected 5 ms)
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_cfs_prio.c:205: PASS: Task runtimes within allowed margins of expected values.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_dl_runtime
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - 创建一个cfs task,在task的执行函数中通过sched_setattr修改task属性为DLtask:
初始化
attr.size = sizeof(attr)
attr.sched_flags = 0
attr.sched_nice = 0
attr.sched_priority = 0
attr.sched_runtime = 5000000
attr.sched_period = 20000000
attr.sched_deadline = 10000000
即创建一个DL task,周期为20ms,在10ms deadline时间内要至少运行5ms。task共运行3s,每运行5ms通过sched_yield让出CPU,schedule idle task。目前为止没有创建新的task(CFS or RT)和DL绑定在同一个CPU上运行,只和idle task进行co-schedule。DL task不能通过sched_setaffinity设置绑定CPU,只能通过CPUSET设置,详细资料参考:
https://stackoverflow.com/questions/50165719/sched-setaffinity-for-sched-deadline
https://elixir.bootlin.com/linux/v4.17-rc3/source/Documentation/scheduler/sched-deadline.txt#L634
- echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task sched_dl_runtim的开始running时间start_ts_us;
- 在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task sched_dl_runtim的结束running时间end_ts_us;
- 在task第一次开始running时,设置sched_period到期时间戳(next_period_ts_us = start_ts_us + 20000)和sched_deadline到期时间戳(sched_deadline_ts_us = start_ts_us + 10000)
- 在task结束running时,
a)累加task在这个sched_period内运行的时间period_exec_time_us;
b)如果此次task的结束时间超过task在当前sched_period的sched_deadline时间, 设置此次task的结束时间为sched_deadline时间;
c)reset start_ts_us = 0 - 如果trace的时间戳超过一个sched_period,
a)如果task在这个period时间段内,running的总时间period_exec_time_us < 5ms,即没达到最小运行时间的要求,测试fail;
b)累加统计的sched_peroid计数:periods_parsed
c)修改下一个sched_peroid到期时间戳:next_period_ts_us += 20000
修改下一个sched_deadline到期时间戳:next_deadline_ts_us +=20000 - 所有trace log行分析完成后,输出periods_parsed的pass log
sh-4.4# ./sched_dl_runtime
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
150 periods parsed successfully.
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_dl_runtime.c:192: PASS: DL task ran as expected.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_latency_dl
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a)创建一个CFS task,sleep 5ms后,打印“WAKING”的trace_marker,释放semaphore,运行1s后退出。
b)创建一个RT task,在task的执行函数中通过sched_setattr修改task属性为DLtask,等待semaphore,等到semaphore后退出。
当前还没实现绑定一个DL task到指定的cpu,但是DL task的优先级最高,即使被wakeup到不同于CFS task 正在running的CPU,也不影响测试成绩。
DL task不能通过sched_setaffinity设置绑定CPU,只能通过CPUSET设置,详细资料参考:
https://stackoverflow.com/questions/50165719/sched-setaffinity-for-sched-deadline
https://elixir.bootlin.com/linux/v4.17-rc3/source/Documentation/scheduler/sched-deadline.txt#L634
- echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 通过dl_task_tid和sched_wakup event,获取DL task被wakeup的时间
- 通过trace中的next_pid = dl_task_tid和sched_switch event,获取DL task开始running的时间
- 计算DL task从wakup到running的delay:dl_exec_latency_us
- 如果dl_exec_latency_us > 100us,测试fail
sh-4.4# ./sched_latency_dl
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
DL exec latency: 202 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_latency_dl.c:155: FAIL: DL task did not execute within expected latency of 100 usec.
Summary:
passed 0
failed 1
skipped 0
warnings 0
-
sched_latency_rt
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a)创建一个CFS task,绑定到cpu0,sleep 5ms后,打印“WAKING”的trace_marker,释放semaphore,运行1s后退出。
b)创建一个RT task,绑定到cpu0,等待semaphore,等到semaphore后退出。 - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- 通过rt_task_tid和sched_wakup event,获取RT task被wakeup的时间
- 通过trace中的next_pid = rt_task_tid和sched_switch event,获取RT task开始running的时间
- 计算RT task从wakup到开始running的delay:rt_exec_latency_us
- 如果rt_exec_latency_us > 100us,测试fail
sh-4.4# ./sched_latency_rt
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
RT exec latency: 10 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_latency_rt.c:140: PASS: RT task executed within required latency of 100 usec..
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_prio_3_fifo
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch sched_wakeup sched_process_exit > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a)创建6个不同优先级的RT thread,初始化每个thread对应的函数及sem信号量,分别为:
thread_name prio function_name semaphore
rt_low_a(la) 70 rt_low_fn_a(lfa) sem_low_a(sla)
rt_low_b(lb) 70 rt_low_fn_b(lfb) sem_low_b(slb)
rt_med_a(ma) 75 rt_med_fn_a(mfa) sem_med_a(sma)
rt_med_b(mb) 75 rt_med_fn_b(mfb) sem_med_b(smb)
rt_high_a(ha) 80 rt_high_fn_a(hfa) sem_high_a(sha)
rt_high_b(hb) 80 rt_high_fn_b(hfb) sem_high_b(shb)
b)各RT thread在function中设置cpu affinity(cpu0),lfa在s(3)后,打印”TEST START” trace marker,随后释放锁,标识测试从此开始。函数逻辑关系如下:
lfa->s(3)->post(&slb)->r(3)
lfb------->wait(&slb)->post(&sma)àr(1)
mfa---------------------->wait(&sma)>s(3)->post(&smb)->r(3)
mfb------------------------------------------------>wait(&smb)->post(&sha)
hfa------------------------------------------------------------------>wait(&sha)->s(1)->post(shb)->r(3)
hfb-------------------------------------------------------------------------------------------->wait(shb)
PS:
s(3): sleep 3ms
r(1): run 1ms
wait: sem_wait
post: sem_post - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
通过数组expected_event evnets[]定义期望的task行为:
- rt_low_fn_a wakeup rt_low_fn_b (相同优先级的task按enqueue先后顺序运行)
(TODO)3ms goes by, rt_low_fn_a exits - rt_low_fn_b starts running
- rt_low_fn_b wakeup rt_med_fn_a (rt_med_a优先级高,抢占rt_low_b)
- rt_med_fn_a starts running (sleeps 3ms immediately)
- rt_low_b continue running for 1ms
(TODO)1ms goes by, rt_low_b exits - rt_med_fn_a wakeup after 3ms sleep
- rt_med_fn_a continue running
- rt_med_fn_a wakeup rt_med_fn_b (相同优先级,rt_med_fn_a先运行不被抢占)
(TODO)3ms goes by, rt_med_fn_a exits - rt_med_fn_b starts running
- rt_med_fn_b wakeup rt_high_fn_a (rt_high_a优先级高,抢占rt_med_b)
- rt_high_fn_a starts running (sleep 1ms immediately)
- rt_med_fn_b continue running (exit immediately)
(TODO) rt_med_fn_b exit immediately - rt_high_fn_a wakeup after 1ms sleep
- rt_high_fn_a starts running
- rt_high_fn_a wakup rt_high_fn_b (相同优先级,rt_high_fn_a先运行不被抢占)
(TODO)3ms goes by, rt_high_fn_a exit - rt_high_fn_b starts running
sh-4.4# ./sched_latency_rt
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
RT exec latency: 10 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_latency_rt.c:140: PASS: RT task executed within required latency of 100 usec..
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_prio_3_rr
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_switch sched_wakeup sched_process_exit > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a)创建3个相同优先级的RT RR thread,初始化每个thread对应的函数,分别为:
thread_name prio function_name
rt_a 70 rt_a_fn
rt_b 70 rt_b_fn
rt_c 70 rt_c_fn
b)各RT thread在function中设置cpu affinity(cpu0),rt_a_fn在sleep 3ms后,打印”TEST START” trace marker,随后释放锁,标识测试从此开始。函数逻辑关系如下:
rt_a_fn->s(3)---------------->sem_post(&sem)/sem_post(&sem)->r(10000)
rt_b_fn->sem_wait(&sem)-------------------------------------------->r(10000)
rt_c_fn->sem_wait(&sem)-------------------------------------------->r(10000)
PS:
s(3): sleep 3ms
r(10000): running 10000ms
wait: sem_wait
post: sem_post - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
分别计算3个RT RR thread的运行时常:
- 在trace event 是sched_switch的 trace log中,通过t->next_pid == task_tid获得task sched_prio_3_rr的开始running时间
在trace event 是sched_switch的 trace log中,通过t->prev_pid == task_tid获得task sched_prio_3_rr的结束running时间 - 累加各个running section的时常,计算得到每个thread的running time及总时长:
a_exec_us
b_exec_us
c_exec_us
total = a_exec_us + b_exec_us + c_exec_us - 32% ≤ ({a,b,c}_exec_us / total) ≤ 34%, pass
sh-4.4# ./sched_latency_rt
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
RT exec latency: 10 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_latency_rt.c:140: PASS: RT task executed within required latency of 100 usec..
Summary:
passed 1
failed 0
skipped 0
-
sugov_latency
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_process_exit sched_process_fork cpu_frequency > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - a)创建一个CFS task
b)绑定到CPU number最大CPU x上
c)sleep 200us,等待task迁移到绑定的CPU上
d)循环sleep 100ms,直到task降到最低频
f)打印trace marker “affined”
g)作为task running 500ms
h)打印trace marker “small task”
i)作为小task running 500ms - echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
- loop trace marker “affined”,记录trace的id:start_idx
- loop trace marker “small task”,记录trace的id:sleep_idx
- 在start_idx和sleep_idx之间寻找第一次出现最高频点的trace,记录最高频点值:max_freq_seen,记录trace的id:max_freq_seen_idx
- 在sleep_idx和结束的trace之间寻找第一次出现最低频点的trace,记录最低频点值:min_freq_seen,记录trace的id:min_freq_seen_idx
- /sys/devices/system/cpu/cpux/cpufreq/scaling_max_freq中获取CPU x的最高频
- /sys/devices/system/cpu/cpux/cpufreq/scaling_min_freq中获取CPU x的最低频
- 计算升频延时:increase_latency_usec= timestamp[max_freq_seen_idx] - timestamp[start_idx]
- 计算降频延时:decrease_latency_usec= timestamp[min_freq_seen_idx] – timestamp[sleep_idx]
- 如果升频延时(increase_latency_usec > 70ms) || (decrease_latency_usec > 70ms), test fail
sh-4.4# ./sugov_latency
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sugov_latency.c:200: INFO: Max acceptable latency to fmax: 70000 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sugov_latency.c:202: INFO: Max acceptable latency to fmin: 70000 usec
CPU hog will be bound to CPU 7.
CPU7 reached 2002 MHz during test (scaling_max_freq 2002 MHz).
CPU7 reached 1228 MHz after test (scaling_min_freq 1228 Mhz).
Increase latency: 21309 usec
Decrease latency: 9196 usec
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sugov_latency.c:224: PASS: Governor met latency targets.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sugov_wakeups
setup阶段:
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_process_exit sched_process_fork cpu_frequency > set_event //setup trace event
echo > trace //clear trace log buffer
echo 1 > tracing_on //enable tracing - sleep 10s
- echo 0 > tracing_on //disable tracing
- 加载trace,并按定义的结构体struct trace_record{}格式进行解析
- 分析解析后的trace
verify阶段:
通过在trace查找“next_comm=sugov”,表示schedutil governor thread被唤醒,统计次数:num_sugov_wakeups > 100,测试失败
sh-4.4# ./sugov_wakeups
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sugov_wakeups.c:34: INFO: Observing sugov wakeups over 10 sec, 100 wakeups allowed
24 sugov wakeups occurred.
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sugov_wakeups.c:62: PASS: Wakeups from schedutil governor were below threshold.
Summary:
passed 1
failed 0
skipped 0
warnings 0
-
sched_boost
setup阶段:
- 初始化信号量:
test_sem用于父(控制线程)子(执行线程)线程间测试执行的同步;
result_sem用于父子线程间测试结果的同步 - 检查节点/dev/stune是存在(可读)
- 在/dev/stune下创建测试路径
STUNE_TEST_PATH= “/dev/stune/test”, 测试在此节点下进行 - 检查通用stune参数配置节点是否存在,并初始化
- 创建子线程test_thread,用于具体执行某一个stune配置的测试
- configure and enable tracing(/sys/kernel/debugging/tracing):
echo 0 > tracing_on //disable tracing
echo 16384 > buffer_size_kb //setup buffer size
echo sched_boost_cpu sched_switch > set_event //setup trace event - 循环执行不同boost设置的测试并解析trace
父进程sched_boost | 子进程test_thread |
run_test (test_index=0; test_index<NUM_TESTS); | 创建子进程test_thread, 并开始执行test_fn; |
sem_post(&test_sem); |
|
| do_work(), 等待不相干系统负载running完; |
echo 0 > tracing_on, disable trace; |
|
不同boost值的测试完成,remove test目录; |
|
PS: do_work创建一个signal,每run 1000us,sleep 19000us。共执行500ms,即250个run/sleep周期,这个pattern的负载是一个小负载,约等于0.
verify阶段:
a)在分析buffer中的trace时,loop所有test_cpu上sched_boost_cpu event,取得经过boost后最大boost_cpu_util,保存到test_utils[test_index]数组中;
b)同过公式test_boost[i]*10计算出target_util, 比较test_util在如下范围内pass:
(test_boost[i]*10 – 50)≤test_util[i]≤(test_boost[i]*10+50)
ssh-4.4# ./sched_boost
/home/apuser/sprdebian_trunk/platform/test/ltp/lib/tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
Running 5 tests for 1 sec
CPU hog will be bound to CPU 7.
Max util seen for boost 0: 42
Max util seen for boost 25: 287
Max util seen for boost 50: 536
Max util seen for boost 75: 785
Max util seen for boost 100: 1024
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_boost.c:142: PASS: Test 0 (boost 0) passed with util 42 (allowed -50 - 50).
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_boost.c:142: PASS: Test 1 (boost 25) passed with util 287 (allowed 200 - 300).
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_boost.c:142: PASS: Test 2 (boost 50) passed with util 536 (allowed 450 - 550).
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_boost.c:142: PASS: Test 3 (boost 75) passed with util 785 (allowed 700 - 800).
/home/apuser/sprdebian_trunk/platform/test/ltp/testcases/unisoc/sched/eas/sched_boost.c:142: PASS: Test 4 (boost 100) passed with util 1024 (allowed 950 - 1050).
Summary:
passed 5
failed 0
skipped 0
warnings 0