Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve cgroup inode in fanotify as soon as possible #265

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

bobrik
Copy link
Contributor

@bobrik bobrik commented Sep 13, 2023

In #264 we reduced the amount of syscalls, here we reorder them to get the inode first.

Before:

ivan@vm:~$ sudo strace -f -TT -e open_by_handle_at,newfstatat,readlinkat -p $(pidof ebpf_exporter)
strace: Process 14153 attached with 11 threads
[pid 14153] open_by_handle_at(7, {handle_bytes=8, handle_type=254, f_handle="\x36\x00\x00\x00\x00\x00\x00\x00"}, O_RDONLY) = 13 <0.000764>
[pid 14153] readlinkat(AT_FDCWD, "/proc/self/fd/13", "/sys/fs/cgroup/system.slice", 128) = 27 <0.000815>
[pid 14153] newfstatat(AT_FDCWD, "/sys/fs/cgroup/system.slice/systemd-resolved.service", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0 <0.000839>

After:

ivan@vm:~$ sudo strace -f -TT -e open_by_handle_at,newfstatat,readlinkat -p $(pidof ebpf_exporter)
strace: Process 13925 attached with 10 threads
[pid 13931] open_by_handle_at(7, {handle_bytes=8, handle_type=254, f_handle="\x36\x00\x00\x00\x00\x00\x00\x00"}, O_RDONLY) = 13 <0.000700>
[pid 13931] newfstatat(13, "systemd-resolved.service", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0 <0.001069>
[pid 13931] readlinkat(AT_FDCWD, "/proc/self/fd/13", "/sys/fs/cgroup/system.slice", 128) = 27 <0.000774>

In cloudflare#264 we reduced
the amount of syscalls, here we reorder them to get the inode first.

Before:

```
ivan@vm:~$ sudo strace -f -TT -e open_by_handle_at,newfstatat,readlinkat -p $(pidof ebpf_exporter)
strace: Process 14153 attached with 11 threads
[pid 14153] open_by_handle_at(7, {handle_bytes=8, handle_type=254, f_handle="\x36\x00\x00\x00\x00\x00\x00\x00"}, O_RDONLY) = 13 <0.000764>
[pid 14153] readlinkat(AT_FDCWD, "/proc/self/fd/13", "/sys/fs/cgroup/system.slice", 128) = 27 <0.000815>
[pid 14153] newfstatat(AT_FDCWD, "/sys/fs/cgroup/system.slice/systemd-resolved.service", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0 <0.000839>
```

After:

```
ivan@vm:~$ sudo strace -f -TT -e open_by_handle_at,newfstatat,readlinkat -p $(pidof ebpf_exporter)
strace: Process 13925 attached with 10 threads
[pid 13931] open_by_handle_at(7, {handle_bytes=8, handle_type=254, f_handle="\x36\x00\x00\x00\x00\x00\x00\x00"}, O_RDONLY) = 13 <0.000700>
[pid 13931] newfstatat(13, "systemd-resolved.service", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0 <0.001069>
[pid 13931] readlinkat(AT_FDCWD, "/proc/self/fd/13", "/sys/fs/cgroup/system.slice", 128) = 27 <0.000774>
```
@bobrik bobrik merged commit f9a4fdd into cloudflare:master Sep 13, 2023
7 checks passed
@bobrik bobrik deleted the ivan/inode-first branch September 13, 2023 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant