H.Potter
H.Potter

Reputation: 157

I try to ftrace open system call but trace record is all about SyS_read

I tried to trace the open() system call using this code.

#include <stdio.h>
#include <fcntl.h>

int main()
{
    char *path = "/home/[my account]/text.txt";

    int fd;
    fd = open(path, O_RDWR);

    return 0;
}

And I compiled it with

gcc -o open open.c

And started to 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'

And what I got with cat trace is only about SyS_read.. There is nothing related to SyS_open..

(I check with cat set_graph_function like below :

root@[server name]:/sys/kernel/debug/tracing# cat set_graph_function
SyS_read
SyS_open

And confirm that SyS_open is not missed.)

# 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   |  }

Why there is only SyS_read even though I write a code with open() ?

I tried to drop caches and did it again but the result was exactly the same.

And also I have know idea why SyS_read showed up despite the fact that I only used open().

Upvotes: 0

Views: 633

Answers (0)

Related Questions