Lưu ý
Mục đích của file này là để độc giả tiếng Việt có thể đọc và hiểu tài liệu nhân kernel dễ dàng hơn, không phải để tạo ra một nhánh tài liệu riêng. Nếu bạn có bất kỳ nhận xét hoặc cập nhật nào cho file này, vui lòng thử cập nhật file tiếng Anh gốc trước. Nếu bạn thấy có sự khác biệt giữa bản dịch và bản gốc, hoặc có vấn đề về bản dịch, vui lòng gửi góp ý hoặc patch cho người dịch của file này, hoặc nhờ người bảo trì và người review tài liệu tiếng Việt giúp đỡ.
- Bản gốc:
- Người dịch:
Google Translate (machine translation)
- Phiên bản gốc:
8541d8f725c6
Cảnh báo
Tài liệu này được dịch tự động bằng máy và chưa được review bởi người dịch. Nội dung có thể không chính xác hoặc khó hiểu ở một số chỗ. Khi có sự khác biệt với bản gốc, bản gốc luôn là chuẩn. Bản dịch chất lượng cao (được review) được đặt trong thư mục vi_VN/.
rtla-timerlat-top¶
Đo độ trễ hẹn giờ của hệ điều hành¶
- Phần hướng dẫn sử dụng:
1
SYNOPSIS¶
ZZ0000ZZ [ZZ0001ZZ] ...
DESCRIPTION¶
The rtla timerlat tool is an interface for the timerlat tracer. The timerlat tracer dispatches a kernel thread per-cpu. These threads set a periodic timer to wake themselves up and go back to sleep. After the wakeup, they collect and generate useful information for the debugging of operating system timer latency.
The timerlat tracer outputs information in two ways. It periodically prints the timer latency at the timer IRQ handler and the Thread handler. It also enables the trace of the most relevant information via osnoise: tracepoints.
The rtla timerlat tool sets the options of the timerlat tracer and collects and displays a summary of the results. By default, the collection is done synchronously in kernel space using a dedicated BPF program attached to the timerlat tracer. If either BPF or the osnoise:timerlat_sample tracepoint it attaches to is unavailable, the rtla timerlat tool falls back to using tracefs to process the data asynchronously in user space.
ZZ0000ZZ hiển thị bản tóm tắt đầu ra định kỳ từ thiết bị theo dõi ZZ0003ZZ. Nó cũng cung cấp thông tin cho từng tiếng ồn của hệ điều hành thông qua các điểm theo dõi ZZ0001ZZ có thể được được thấy với tùy chọn ZZ0002ZZ.
OPTIONS¶
-a, --auto us
Set the automatic trace mode. This mode sets some commonly used options while debugging the system. It is equivalent to use -T us -s us -t. By default, timerlat tracer uses FIFO:95 for timerlat threads, thus equivalent to -P f:95.
-p, --period us
Set the timerlat tracer period in microseconds.
-i, --irq us
Stop trace if the IRQ latency is higher than the argument in us.
-T, --thread us
Stop trace if the Thread latency is higher than the argument in us.
-s, --stack us
Save the stack trace at the IRQ if a Thread latency is higher than the argument in us.
-t, --trace [file]
Save the stopped trace to [file|timerlat_trace.txt].
- --dma-latency us
Set the /dev/cpu_dma_latency to us, aiming to bound exit from idle latencies. cyclictest sets this value to 0 by default, use --dma-latency 0 to have similar results.
- --deepest-idle-state n
Disable idle states higher than n for cpus that are running timerlat threads to reduce exit from idle latencies. If n is -1, all idle states are disabled. On exit from timerlat, the idle state setting is restored to its original state before running timerlat.
Requires rtla to be built with libcpupower.
-k, --kernel-threads
Use timerlat kernel-space threads, in contrast of -u.
-u, --user-threads
Set timerlat to run without a workload, and then dispatches user-space workloads to wait on the timerlat_fd. Once the workload is awakened, it goes to sleep again adding so the measurement for the kernel-to-user and user-to-kernel to the tracer output. --user-threads will be used unless the user specify -k.
-U, --user-load
Set timerlat to run without workload, waiting for the user to dispatch a per-cpu task that waits for a new period on the tracing/osnoise/per_cpu/cpu$ID/timerlat_fd. See linux/tools/rtla/example/timerlat_load.py for an example of user-load code.
--bpf-action bpf-program
Loads a BPF program from an ELF file and executes it when a latency threshold is exceeded.
The BPF program must be a valid ELF file loadable with libbpf. The program must contain a function named
action_handler, stored in an ELF section with thetp_prefix. The prefix is used by libbpf to set BPF program type to BPF_PROG_TYPE_TRACEPOINT.The program receives a
struct trace_event_raw_timerlat_sampleparameter containing timerlat sample data.An example is provided in
tools/tracing/rtla/example/timerlat_bpf_action.c. This example demonstrates how to create a BPF program that prints latency information usingbpf_trace_printk()when a threshold is exceeded.Note: BPF actions require BPF support to be available. If BPF is not available or disabled, the tool falls back to tracefs mode and BPF actions are not supported.
--stack-format format
Adjust the format of the stack trace printed during auto-analysis.
The supported values for format are:
truncate Print the stack trace up to the first unknown address (default).
skip Skip unknown addresses.
full Print the entire stack trace, including unknown addresses.
For unknown addresses, the raw pointer is printed.
-q, --quiet
Print only a summary at the end of the session.
-c, --cpus cpu-list
Set the timerlat top tracer to run the sample threads in the cpu-list.
By default, the timerlat top tracer runs the sample threads on all CPUs.
-H, --house-keeping cpu-list
Run rtla control threads only on the given cpu-list.
If omitted, rtla will attempt to auto-migrate its main thread to any CPU that is not running any workload threads.
-d, --duration time[s|m|h|d]
Set the duration of the session.
-D, --debug
Print debug info.
-e, --event sys:event
Enable an event in the trace (-t) session. The argument can be a specific event, e.g., -e sched:sched_switch, or all events of a system group, e.g., -e sched. Multiple -e are allowed. It is only active when -t or -a are set.
--filter <filter>
Filter the previous -e sys:event event with <filter>. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.
- --trigger <trigger>
Enable a trace event trigger to the previous -e sys:event. If the hist: trigger is activated, the output histogram will be automatically saved to a file named system_event_hist.txt. For example, the command:
rtla <command> <mode> -t -e osnoise:irq_noise --trigger=”hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount”
Will automatically save the content of the histogram associated to osnoise:irq_noise event in osnoise_irq_noise_hist.txt.
For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.
-P, --priority o:prio|r:prio|f:prio|d:runtime:period
Set scheduling parameters to the timerlat top tracer threads, the format to set the priority are:
o:prio - use SCHED_OTHER with prio;
r:prio - use SCHED_RR with prio;
f:prio - use SCHED_FIFO with prio;
d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period in nanoseconds.
If not set, tracer threads keep their default priority. For rtla user threads, it is set to SCHED_FIFO with priority 95. For kernel threads, see osnoise and timerlat tracer documentation for the running kernel version.
-C, --cgroup [cgroup]
Set a cgroup to the tracer’s threads. If the -C option is passed without arguments, the tracer’s thread will inherit rtla’s cgroup. Otherwise, the threads will be placed on the cgroup passed to the option.
If not set, the behavior differs between workload types. User workloads created by rtla will inherit rtla’s cgroup. Kernel workloads are assigned the root cgroup.
--warm-up s
After starting the workload, let it run for s seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.
- --trace-buffer-size kB
Set the per-cpu trace buffer size in kB for the tracing output.
If not set, the default tracefs buffer size is used.
--on-threshold action
Defines an action to be executed when tracing is stopped on a latency threshold specified by -a/--auto, -i/--irq, or -T/--thread.
Multiple --on-threshold actions may be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.
Supported actions are:
trace[,file=<filename>]
Saves trace output, optionally taking a filename. Alternative to -t/--trace. Note that unlike -t/--trace, specifying this multiple times will result in the trace being saved multiple times.
signal,num=<sig>,pid=<pid>
Sends signal to process. “parent” might be specified in place of pid to target the parent process of rtla.
shell,command=<command>
Execute shell command.
continue
Continue tracing after actions are executed instead of stopping.
Example:
$ rtla timerlat top -T 20 --on-threshold trace --on-threshold shell,command=”grep ipi_send timerlat_trace.txt” --on-threshold signal,num=2,pid=parent
This will save a trace with the default filename “timerlat_trace.txt”, print its lines that contain the text “ipi_send” on standard output, and send signal 2 (SIGINT) to the parent process.
Performance Considerations:
For time-sensitive actions, it is recommended to run rtla timerlat with BPF support and RT priority. Note that due to implementational limitations, actions might be delayed up to one second after tracing is stopped if BPF mode is not available or disabled.
--on-end action
Defines an action to be executed at the end of tracing.
Multiple --on-end actions can be specified, and they will be executed in the order they are provided. If any action fails, subsequent actions in the list will not be executed.
See the documentation for --on-threshold for the list of supported actions, with the exception that continue has no effect.
Example:
$ rtla timerlat top -d 5s --on-end trace
This runs rtla with the default options, and saves trace output at the end.
-h, --help
Print help menu.
--dump-tasks
prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)
--no-aa
disable auto-analysis, reducing rtla timerlat cpu usage
ZZ0000ZZ ZZ0001ZZ
- Đặt điều kiện dừng theo dõi và chạy mà không thu thập và hiển thị số liệu thống kê.
In bản phân tích tự động nếu hệ thống đạt đến điều kiện dừng theo dõi. Tùy chọn này rất hữu ích để giảm rtla timelat CPU, cho phép gỡ lỗi mà không cần tốn phí thu thập số liệu thống kê.
EXAMPLE¶
Trong ví dụ bên dưới, bộ theo dõi timelat được gửi đi trong CPU ZZ0000ZZ trong chế độ theo dõi tự động, hướng dẫn bộ theo dõi dừng nếu độ trễ ZZ0001ZZ hoặc cao hơn được tìm thấy:
# timerlat -a 40 -c 1-23 -q
Độ trễ hẹn giờ
0 00:00:12 ZZ0000ZZ Độ trễ hẹn giờ chủ đề (chúng tôi)
- CPU COUNT ZZ0001ZZ tối thiểu trung bình tối đa
1 #12322 ZZ0002ZZ 10 3 9 31 2 #12322 ZZ0003ZZ 10 3 9 23 3 #12322 ZZ0004ZZ 8 2 8 34 4 #12322 ZZ0005ZZ 10 2 11 33 5 #12322 ZZ0006ZZ 8 3 8 25 6 #12322 ZZ0007ZZ 16 3 11 35 7 #12322 ZZ0008ZZ 9 2 8 29 8 #12322 ZZ0009ZZ 9 3 9 34 9 #12322 ZZ0010ZZ 8 2 8 24
10 #12322 ZZ0011ZZ 9 3 8 24 11 #12322 ZZ0012ZZ 6 2 7 29 12 #12321 ZZ0013ZZ 5 3 8 23 13 #12319 ZZ0014ZZ 9 3 9 26 14 #12321 ZZ0015ZZ 6 2 8 24 15 #12321 ZZ0016ZZ 12 3 11 27 16 #12318 ZZ0017ZZ 7 3 10 24 17 #12319 ZZ0018ZZ 11 3 9 25 18 #12318 ZZ0019ZZ 8 2 8 20 19 #12319 ZZ0020ZZ 10 2 9 28 20 #12317 ZZ0021ZZ 9 3 8 34 21 #12318 ZZ0022ZZ 8 3 8 28 22 #12319 ZZ0023ZZ 8 3 10 22 23 #12320 ZZ0024ZZ 41 3 11 41
rtla timelat nhấn dừng theo dõi ## ZZ0052ZZ 23 lần truy tìm điểm dừng, phân tích nó ## ZZ0053ZZ độ trễ của trình xử lý: 27,49 us (65,52 %) Độ trễ IRQ: 28,13 us Thời lượng của Timelat IRQ: 9,59 us (22,85 %) Chủ đề chặn: 3,79 us (9,03 %)
objtool:49256 3,79 chúng tôi
- Chặn ngăn xếp luồng
-> bộ đếm thời gian_irq -> __hrtimer_run_queues -> hrtimer_interrupt -> __sysvec_apic_timer_interrupt -> sysvec_apic_timer_interrupt -> asm_sysvec_apic_timer_interrupt -> _raw_spin_unlock_irqrestore -> cgroup_rstat_flush_locked -> cgroup_rstat_flush_irqsafe -> mem_cgroup_flush_stats -> mem_cgroup_wb_stats -> Balance_dirty_pages -> Balance_dirty_pages_ratelimited_flags -> btrfs_buffered_write -> btrfs_do_write_iter -> vfs_write -> __x64_sys_pwrite64 -> do_syscall_64 -> entry_SYSCALL_64_after_hwframe
Độ trễ luồng: 41,96 us (100%)
- Hệ thống đã thoát khỏi độ trễ nhàn rỗi!
Độ trễ IRQ tối đa của bộ đếm thời gian từ lúc không hoạt động: 17,48 us trong cpu 4
Lưu dấu vết vào timelat_trace.txt
Trong trường hợp này, yếu tố chính là độ trễ của ZZ0001ZZ xử lý việc đánh thức ZZ0000ZZ: ZZ0002ZZ. Điều này có thể được gây ra bởi các ngắt che dấu luồng hiện tại, có thể được nhìn thấy trong phần chặn thread stacktrace: luồng hiện tại (ZZ0003ZZ) bị ngắt thông qua các hoạt động ZZ0004ZZ bên trong nhóm mem, trong khi thực hiện ghi syscall trong hệ thống tệp btrfs.
Dấu vết thô được lưu trong tệp ZZ0000ZZ để phân tích thêm.
Lưu ý rằng ZZ0000ZZ đã được gửi đi mà không thay đổi chất đánh dấu ZZ0001ZZ mức độ ưu tiên của chủ đề. Điều đó thường không cần thiết vì những chủ đề này có ưu tiên ZZ0002ZZ theo mặc định, đây là mức ưu tiên phổ biến được sử dụng theo thời gian thực các nhà phát triển hạt nhân để phân tích sự chậm trễ trong việc lập kế hoạch.
SEE ALSO¶
ZZ0000ZZ(1), ZZ0001ZZ(1)
ZZ0000ZZ
SIGINT BEHAVIOR¶
On the first SIGINT, RTLA exits after collecting all outstanding samples up to the point of receiving the signal.
When receiving more than one SIGINT, RTLA discards any outstanding samples, and exits while displaying only samples that have already been processed.
If SIGINT is received during RTLA cleanup, RTLA exits immediately via the default signal handler.
Note: For the purpose of SIGINT behavior, the expiry of duration specified via the -d/--duration option is treated as equivalent to receiving a SIGINT. For example, a SIGINT received after duration expired but samples have not been processed yet will drop any outstanding samples.
Also note that when using the timerlat tool in BPF mode, samples are processed in-kernel; RTLA only copies them out to display them to the user. A second SIGINT does not affect in-kernel sample aggregation.
EXIT STATUS¶
0 Passed: the test did not hit the stop tracing condition
1 Error: invalid argument
2 Failed: the test hit the stop tracing condition
REPORTING BUGS¶
Report bugs to <linux-kernel@vger.kernel.org> and <linux-trace-devel@vger.kernel.org>
LICENSE¶
rtla is Free Software licensed under the GNU GPLv2
COPYING¶
Copyright (C) 2021 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).