authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-28 16:27:28-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-28 16:27:28-07:00
log077994abb66be93f38142ee55243fee8cdc3a5da
treee582768a119c42bc5326e2ff23ae5b7cb5b9e093
parentc4ad6be0023ad351a59f53cab7c59fccecb6f82d
parentbc0bf4e97ac7ac45731b7a7e629e680e51d8eefe
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17318 from gh-fork-dump/linux-5.6-cachestat

Update Linux syscalls for 5.5 and add a wrapper for `cachestat`

3 files changed, 38 insertions(+), 2 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};
lib/std/os/linux/syscalls.zig+10
...@@ -442,6 +442,7 @@ pub const X86 = enum(usize) {...@@ -442,6 +442,7 @@ pub const X86 = enum(usize) {
442 process_mrelease = 448,442 process_mrelease = 448,
443 futex_waitv = 449,443 futex_waitv = 449,
444 set_mempolicy_home_node = 450,444 set_mempolicy_home_node = 450,
445 cachestat = 451,
445};446};
446447
447pub const X64 = enum(usize) {448pub const X64 = enum(usize) {
...@@ -807,6 +808,7 @@ pub const X64 = enum(usize) {...@@ -807,6 +808,7 @@ pub const X64 = enum(usize) {
807 process_mrelease = 448,808 process_mrelease = 448,
808 futex_waitv = 449,809 futex_waitv = 449,
809 set_mempolicy_home_node = 450,810 set_mempolicy_home_node = 450,
811 cachestat = 451,
810};812};
811813
812pub const Arm = enum(usize) {814pub const Arm = enum(usize) {
...@@ -1215,6 +1217,7 @@ pub const Arm = enum(usize) {...@@ -1215,6 +1217,7 @@ pub const Arm = enum(usize) {
1215 process_mrelease = 448,1217 process_mrelease = 448,
1216 futex_waitv = 449,1218 futex_waitv = 449,
1217 set_mempolicy_home_node = 450,1219 set_mempolicy_home_node = 450,
1220 cachestat = 451,
12181221
1219 breakpoint = arm_base + 1,1222 breakpoint = arm_base + 1,
1220 cacheflush = arm_base + 2,1223 cacheflush = arm_base + 2,
...@@ -1607,6 +1610,7 @@ pub const Sparc64 = enum(usize) {...@@ -1607,6 +1610,7 @@ pub const Sparc64 = enum(usize) {
1607 process_mrelease = 448,1610 process_mrelease = 448,
1608 futex_waitv = 449,1611 futex_waitv = 449,
1609 set_mempolicy_home_node = 450,1612 set_mempolicy_home_node = 450,
1613 cachestat = 451,
1610};1614};
16111615
1612pub const Mips = enum(usize) {1616pub const Mips = enum(usize) {
...@@ -2030,6 +2034,7 @@ pub const Mips = enum(usize) {...@@ -2030,6 +2034,7 @@ pub const Mips = enum(usize) {
2030 process_mrelease = Linux + 448,2034 process_mrelease = Linux + 448,
2031 futex_waitv = Linux + 449,2035 futex_waitv = Linux + 449,
2032 set_mempolicy_home_node = Linux + 450,2036 set_mempolicy_home_node = Linux + 450,
2037 cachestat = Linux + 451,
2033};2038};
20342039
2035pub const Mips64 = enum(usize) {2040pub const Mips64 = enum(usize) {
...@@ -2389,6 +2394,7 @@ pub const Mips64 = enum(usize) {...@@ -2389,6 +2394,7 @@ pub const Mips64 = enum(usize) {
2389 process_mrelease = Linux + 448,2394 process_mrelease = Linux + 448,
2390 futex_waitv = Linux + 449,2395 futex_waitv = Linux + 449,
2391 set_mempolicy_home_node = Linux + 450,2396 set_mempolicy_home_node = Linux + 450,
2397 cachestat = Linux + 451,
2392};2398};
23932399
2394pub const PowerPC = enum(usize) {2400pub const PowerPC = enum(usize) {
...@@ -2823,6 +2829,7 @@ pub const PowerPC = enum(usize) {...@@ -2823,6 +2829,7 @@ pub const PowerPC = enum(usize) {
2823 process_mrelease = 448,2829 process_mrelease = 448,
2824 futex_waitv = 449,2830 futex_waitv = 449,
2825 set_mempolicy_home_node = 450,2831 set_mempolicy_home_node = 450,
2832 cachestat = 451,
2826};2833};
28272834
2828pub const PowerPC64 = enum(usize) {2835pub const PowerPC64 = enum(usize) {
...@@ -3229,6 +3236,7 @@ pub const PowerPC64 = enum(usize) {...@@ -3229,6 +3236,7 @@ pub const PowerPC64 = enum(usize) {
3229 process_mrelease = 448,3236 process_mrelease = 448,
3230 futex_waitv = 449,3237 futex_waitv = 449,
3231 set_mempolicy_home_node = 450,3238 set_mempolicy_home_node = 450,
3239 cachestat = 451,
3232};3240};
32333241
3234pub const Arm64 = enum(usize) {3242pub const Arm64 = enum(usize) {
...@@ -3538,6 +3546,7 @@ pub const Arm64 = enum(usize) {...@@ -3538,6 +3546,7 @@ pub const Arm64 = enum(usize) {
3538 process_mrelease = 448,3546 process_mrelease = 448,
3539 futex_waitv = 449,3547 futex_waitv = 449,
3540 set_mempolicy_home_node = 450,3548 set_mempolicy_home_node = 450,
3549 cachestat = 451,
3541};3550};
35423551
3543pub const RiscV64 = enum(usize) {3552pub const RiscV64 = enum(usize) {
...@@ -3848,6 +3857,7 @@ pub const RiscV64 = enum(usize) {...@@ -3848,6 +3857,7 @@ pub const RiscV64 = enum(usize) {
3848 process_mrelease = 448,3857 process_mrelease = 448,
3849 futex_waitv = 449,3858 futex_waitv = 449,
3850 set_mempolicy_home_node = 450,3859 set_mempolicy_home_node = 450,
3860 cachestat = 451,
38513861
3852 riscv_flush_icache = arch_specific_syscall + 15,3862 riscv_flush_icache = arch_specific_syscall + 15,
3853};3863};
tools/generate_linux_syscalls.zig-2
...@@ -262,7 +262,6 @@ pub fn main() !void {...@@ -262,7 +262,6 @@ pub fn main() !void {
262 .argv = &child_args,262 .argv = &child_args,
263 .cwd = linux_path,263 .cwd = linux_path,
264 .cwd_dir = linux_dir,264 .cwd_dir = linux_dir,
265 .max_output_bytes = 20 * 1024,
266 });265 });
267 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});266 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});
268267
...@@ -324,7 +323,6 @@ pub fn main() !void {...@@ -324,7 +323,6 @@ pub fn main() !void {
324 .argv = &child_args,323 .argv = &child_args,
325 .cwd = linux_path,324 .cwd = linux_path,
326 .cwd_dir = linux_dir,325 .cwd_dir = linux_dir,
327 .max_output_bytes = 20 * 1024,
328 });326 });
329 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});327 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});
330328