authorgravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2023-09-28 18:27:37+10:00
committergravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2023-09-28 18:58:05+10:00
logbc0bf4e97ac7ac45731b7a7e629e680e51d8eefe
tree4db8ba4f7e1fe0aa7b720c9b2972416290451104
parent5f456b2b97bc4a4c4860fd7cb6287c400e215eae

Linux: Add cachestat wrapper.

Can be tested using this program I whipped up: https://gist.github.com/The-King-of-Toasters/aee448f5975c50f735fd1946794574f7

1 files changed, 28 insertions(+), 0 deletions(-)

lib/std/os/linux.zig+28
...@@ -1876,6 +1876,21 @@ pub fn ptrace(...@@ -1876,6 +1876,21 @@ pub fn ptrace(
1876 );1876 );
1877}1877}
18781878
1879pub fn cachestat(
1880 fd: fd_t,
1881 cstat_range: *const cache_stat_range,
1882 cstat: *cache_stat,
1883 flags: u32,
1884) usize {
1885 return syscall4(
1886 .cachestat,
1887 @as(usize, @bitCast(@as(isize, fd))),
1888 @intFromPtr(cstat_range),
1889 @intFromPtr(cstat),
1890 flags,
1891 );
1892}
1893
1879pub const E = switch (native_arch) {1894pub const E = switch (native_arch) {
1880 .mips, .mipsel => @import("linux/errno/mips.zig").E,1895 .mips, .mipsel => @import("linux/errno/mips.zig").E,
1881 .sparc, .sparcel, .sparc64 => @import("linux/errno/sparc.zig").E,1896 .sparc, .sparcel, .sparc64 => @import("linux/errno/sparc.zig").E,
...@@ -5829,3 +5844,16 @@ pub const PTRACE = struct {...@@ -5829,3 +5844,16 @@ pub const PTRACE = struct {
5829 pub const SECCOMP_GET_METADATA = 0x420d;5844 pub const SECCOMP_GET_METADATA = 0x420d;
5830 pub const GET_SYSCALL_INFO = 0x420e;5845 pub const GET_SYSCALL_INFO = 0x420e;
5831};5846};
5847
5848pub const cache_stat_range = extern struct {
5849 off: u64,
5850 len: u64,
5851};
5852
5853pub const cache_stat = extern struct {
5854 cache: u64,
5855 dirty: u64,
5856 writeback: u64,
5857 evicted: u64,
5858 recently_evicted: u64,
5859};