Skip to content

Commit de16787

Browse files
sched: minor revisions, typo and indent
ftrace: trace options, and how to use func_stack_trace option. Signed-off-by: Leon <[email protected]>
1 parent c6b118d commit de16787

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

kernel/sched/sched_rt.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static inline u64 sched_avg_period(void)
863863
* `sched_rt_runtime_exceeded()`返回值为 **1** 时,`update_curr_rt()`会设置重新调度标志,表示需要限流。
864864
* `sched_rt_runtime_exceeded()`返回值为 **0** 时,实时任务至少不会因为 RT Throttling 的原因被抢占(当然,还有其他别的原因而被抢占)。
865865
* `rt_rq->rt_queued` 作为实时调度队列的标志位,大于 0 时表示未被限流。
866-
* 被限流的是调度实体是进程是比较简单,只是简单地关闭 `rt_rq->rt_queued = 0`,不会改变进程状态。
866+
* 被限流的是调度实体是进程时比较简单,只是简单地关闭 `rt_rq->rt_queued = 0`,不会改变进程状态。
867867
* 被限流的调度实体是调度组的情况比较复杂。调度实体会被移出所属调度组的实时调度队列,但也不会处于任何一个睡眠队列,因为它并不是真正睡眠,而且它也不是一个进程。
868868
* 实时调度队列 `rt_rq->rt_queued = 0`
869869
* 等到限流被放开时,它会被放回实时调度队列

kernel/sched/sched_rt_load_balance.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,8 @@ static void pull_rt_task(struct rq *this_rq)
873873
*/
874874
/*有一个 p 的优先级比它在的 CPU 上正在运行的任务的优先级高的机会。这就是 p 正好被唤醒
875875
但还没有来得及被调度到。我们只在 p 的优先级比它当前运行队列上正在运行的任务优先级低的
876-
时候去拉。
877-
因为马上有机会被调度的进程没必要拉,所以这里 skip 该进程*/
876+
时候去拉。
877+
因为马上有机会被调度的进程没必要拉,所以这里 skip 该进程*/
878878
if (p->prio < src_rq->curr->prio)
879879
goto skip;
880880
/*否则,开始下面的迁移操作*/

kernel/trace/ftrace.md

+68-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ cpus=8
482482
* [KernelShark](http://rostedt.homelinux.com/kernelshark/)
483483
* [Using KernelShark to analyze the real-time scheduler](https://lwn.net/Articles/425583/)
484484

485-
## trace_options
485+
## 跟踪选项
486+
### trace_options
486487
* `/sys/kernel/debug/tracing/trace_options`文件
487488
```
488489
# cat /sys/kernel/debug/tracing/trace_options
@@ -515,6 +516,72 @@ cpus=8
515516
notest_nop_accept
516517
notest_nop_refuse
517518
```
519+
* 通过修改`/sys/kernel/debug/tracing/options`下的文件可以使能这些`trace_options`
520+
521+
#### latency-format
522+
* 该选项会改变 trace 输出。使能的时候,trace 会显示关于延迟的额外的信息
523+
```
524+
# tracer: irqsoff
525+
#
526+
# irqsoff latency trace v1.1.5 on 3.8.0-test+
527+
# --------------------------------------------------------------------
528+
# latency: 259 us, #4/4, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)
529+
# -----------------
530+
# | task: ps-6143 (uid:0 nice:0 policy:0 rt_prio:0)
531+
# -----------------
532+
# => started at: __lock_task_sighand
533+
# => ended at: _raw_spin_unlock_irqrestore
534+
#
535+
#
536+
# _------=> CPU#
537+
# / _-----=> irqs-off
538+
# | / _----=> need-resched
539+
# || / _---=> hardirq/softirq
540+
# ||| / _--=> preempt-depth
541+
# |||| / delay
542+
# cmd pid ||||| time | caller
543+
# \ / ||||| \ | /
544+
ps-6143 2d... 0us!: trace_hardirqs_off <-__lock_task_sighand
545+
ps-6143 2d..1 259us+: trace_hardirqs_on <-_raw_spin_unlock_irqrestore
546+
ps-6143 2d..1 263us+: time_hardirqs_on <-_raw_spin_unlock_irqrestore
547+
ps-6143 2d..1 306us : <stack trace>
548+
=> trace_hardirqs_on_caller
549+
=> trace_hardirqs_on
550+
=> _raw_spin_unlock_irqrestore
551+
=> do_task_stat
552+
=> proc_tgid_stat
553+
=> proc_single_show
554+
=> seq_read
555+
=> vfs_read
556+
=> sys_read
557+
=> system_call_fastpath
558+
```
559+
#### stacktrace
560+
* 当设置该 option 时,任何 **trace event** 的栈跟踪将会被记录下来
561+
562+
### function tracer option
563+
#### func_stack_trace
564+
* 如果说设置`function_graph tracer`+`set_graph_function`可以跟踪到一个函数往下的调用路径,那么`function tracer`+`set_ftrace_filter`+`func_stack_trace`则可以跟踪到它往上的调用路径
565+
* 需使能`CONFIG_STACKTRACE`内核选项
566+
* 只有当`current_tracer`设置为 **function tracer** 时才会出现
567+
* 当设置该 option 时,每个函数被记录的时候,它的栈跟踪也会被记录
568+
* **NOTE:** 在使能该选项时,务必同时设置`set_ftrace_filter`,否则系统性能会严重下降。并且在清除过滤函数的时候记得关闭该选项。
569+
* Example:
570+
```
571+
$ echo rtc_timer_enqueue > /sys/kernel/debug/tracing/set_ftrace_filter
572+
$ echo function > /sys/kernel/debug/tracing/current_tracer
573+
$ echo 1 > /sys/kernel/debug/tracing/options/func_stack_trace
574+
$ echo 1 > /sys/kernel/debug/tracing/tracing_on
575+
$ cat /sys/kernel/debug/tracing/trace_pipe
576+
rtc_test.2029-2902 [001] .... 7694.641987: rtc_timer_enqueue <-rtc_update_irq_enable
577+
rtc_test.2029-2902 [001] .... 7694.642015: <stack trace>
578+
=> rtc_timer_enqueue
579+
=> rtc_update_irq_enable
580+
=> rtc_dev_ioctl
581+
=> do_vfs_ioctl
582+
=> SyS_ioctl
583+
=> system_call_fastpath
584+
```
518585

519586
# Reference
520587

0 commit comments

Comments
 (0)