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(
18761876 );
18771877}
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
18791894pub const E = switch (native_arch) {
18801895 .mips, .mipsel => @import("linux/errno/mips.zig").E,
18811896 .sparc, .sparcel, .sparc64 => @import("linux/errno/sparc.zig").E,
......@@ -5829,3 +5844,16 @@ pub const PTRACE = struct {
58295844 pub const SECCOMP_GET_METADATA = 0x420d;
58305845 pub const GET_SYSCALL_INFO = 0x420e;
58315846};
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) {
442442 process_mrelease = 448,
443443 futex_waitv = 449,
444444 set_mempolicy_home_node = 450,
445 cachestat = 451,
445446};
446447
447448pub const X64 = enum(usize) {
......@@ -807,6 +808,7 @@ pub const X64 = enum(usize) {
807808 process_mrelease = 448,
808809 futex_waitv = 449,
809810 set_mempolicy_home_node = 450,
811 cachestat = 451,
810812};
811813
812814pub const Arm = enum(usize) {
......@@ -1215,6 +1217,7 @@ pub const Arm = enum(usize) {
12151217 process_mrelease = 448,
12161218 futex_waitv = 449,
12171219 set_mempolicy_home_node = 450,
1220 cachestat = 451,
12181221
12191222 breakpoint = arm_base + 1,
12201223 cacheflush = arm_base + 2,
......@@ -1607,6 +1610,7 @@ pub const Sparc64 = enum(usize) {
16071610 process_mrelease = 448,
16081611 futex_waitv = 449,
16091612 set_mempolicy_home_node = 450,
1613 cachestat = 451,
16101614};
16111615
16121616pub const Mips = enum(usize) {
......@@ -2030,6 +2034,7 @@ pub const Mips = enum(usize) {
20302034 process_mrelease = Linux + 448,
20312035 futex_waitv = Linux + 449,
20322036 set_mempolicy_home_node = Linux + 450,
2037 cachestat = Linux + 451,
20332038};
20342039
20352040pub const Mips64 = enum(usize) {
......@@ -2389,6 +2394,7 @@ pub const Mips64 = enum(usize) {
23892394 process_mrelease = Linux + 448,
23902395 futex_waitv = Linux + 449,
23912396 set_mempolicy_home_node = Linux + 450,
2397 cachestat = Linux + 451,
23922398};
23932399
23942400pub const PowerPC = enum(usize) {
......@@ -2823,6 +2829,7 @@ pub const PowerPC = enum(usize) {
28232829 process_mrelease = 448,
28242830 futex_waitv = 449,
28252831 set_mempolicy_home_node = 450,
2832 cachestat = 451,
28262833};
28272834
28282835pub const PowerPC64 = enum(usize) {
......@@ -3229,6 +3236,7 @@ pub const PowerPC64 = enum(usize) {
32293236 process_mrelease = 448,
32303237 futex_waitv = 449,
32313238 set_mempolicy_home_node = 450,
3239 cachestat = 451,
32323240};
32333241
32343242pub const Arm64 = enum(usize) {
......@@ -3538,6 +3546,7 @@ pub const Arm64 = enum(usize) {
35383546 process_mrelease = 448,
35393547 futex_waitv = 449,
35403548 set_mempolicy_home_node = 450,
3549 cachestat = 451,
35413550};
35423551
35433552pub const RiscV64 = enum(usize) {
......@@ -3848,6 +3857,7 @@ pub const RiscV64 = enum(usize) {
38483857 process_mrelease = 448,
38493858 futex_waitv = 449,
38503859 set_mempolicy_home_node = 450,
3860 cachestat = 451,
38513861
38523862 riscv_flush_icache = arch_specific_syscall + 15,
38533863};
tools/generate_linux_syscalls.zig-2
......@@ -262,7 +262,6 @@ pub fn main() !void {
262262 .argv = &child_args,
263263 .cwd = linux_path,
264264 .cwd_dir = linux_dir,
265 .max_output_bytes = 20 * 1024,
266265 });
267266 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});
268267
......@@ -324,7 +323,6 @@ pub fn main() !void {
324323 .argv = &child_args,
325324 .cwd = linux_path,
326325 .cwd_dir = linux_dir,
327 .max_output_bytes = 20 * 1024,
328326 });
329327 if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});
330328