このコードを使用して open システム コールをトレースしようとしました。
#include <stdio.h>
#include <fcntl.h>
int main()
{
char *path = "/home/[my account]/text.txt";
int fd;
fd = open(path, O_RDWR);
return 0;
}
そして、私はそれをコンパイルしました
gcc -o open open.c
そして、Ftrace を開始しました。
echo SyS_open > set_graph_function
echo SyS_read >> set_graph_function
sh -c 'echo $$ > set_ftrace_pid; echo 1 > tracing_on;
exec /home/[my account]/open'
そして、私が得たのcat trace
はSyS_read
..に関連するものは何もありませんSyS_open
..
(以下のように cat set_graph_function で確認します:
root@[server name]:/sys/kernel/debug/tracing# cat set_graph_function
SyS_read
SyS_open
SyS_open
漏れがないことを確認してください。)
# CPU DURATION FUNCTION CALLS
# | | | | | | |
17) | SyS_read() {
17) | __fdget_pos() {
17) 0.137 us | __fget_light();
17) 1.285 us | }
17) | vfs_read() {
17) | rw_verify_area() {
17) | security_file_permission() {
17) | apparmor_file_permission() {
17) | common_file_perm() {
17) 0.041 us | aa_file_perm();
17) 0.493 us | }
17) 0.934 us | }
17) 0.040 us | __fsnotify_parent();
17) 0.042 us | fsnotify();
17) 2.843 us | }
17) 3.194 us | }
17) | __vfs_read() {
17) | new_sync_read() {
17) | ext4_file_read_iter() {
17) | generic_file_read_iter() {
17) | _cond_resched() {
17) 0.040 us | rcu_all_qs();
17) 0.387 us | }
17) | pagecache_get_page() {
17) 0.225 us | find_get_entry();
17) 0.573 us | }
17) 0.046 us | mark_page_accessed();
17) | _cond_resched() {
17) 0.040 us | rcu_all_qs();
17) 0.393 us | }
17) | touch_atime() {
17) | __atime_needs_update() {
17) | current_time() {
17) 0.042 us | current_kernel_time64();
17) 0.039 us | timespec_trunc();
17) 0.972 us | }
17) 1.321 us | }
17) 1.692 us | }
17) 4.990 us | }
17) 5.351 us | }
17) 5.766 us | }
17) 6.161 us | }
17) 0.039 us | __fsnotify_parent();
17) 0.045 us | fsnotify();
17) + 10.735 us | }
17) + 13.187 us | }
SyS_read
でコードを書いているのになぜしかないのopen()
ですか?
キャッシュを削除しようとして、もう一度やり直しましたが、結果はまったく同じでした。
またSyS_read
、使用したのはopen()
.