Skip to content

Commit a119a9a

Browse files
committed
x/sys/unix: add cachestat system call
The cachestat system call is an alternative to mincore that offers more extensive page cache statistics, aiming to enhance scalability. It was added on Linux 6.5. Fixes golang/go#61917
1 parent 8ccaaf0 commit a119a9a

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

unix/linux/types.go

+17
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,20 @@ struct my_can_bittiming_const {
461461
462462
struct riscv_hwprobe {};
463463
#endif
464+
465+
// copied from /usr/include/uapi/linux/mman.h
466+
struct cachestat_range {
467+
__u64 off;
468+
__u64 len;
469+
};
470+
471+
struct cachestat {
472+
__u64 nr_cache;
473+
__u64 nr_dirty;
474+
__u64 nr_writeback;
475+
__u64 nr_evicted;
476+
__u64 nr_recently_evicted;
477+
};
464478
*/
465479
import "C"
466480

@@ -5813,3 +5827,6 @@ const (
58135827
type SchedAttr C.struct_sched_attr
58145828

58155829
const SizeofSchedAttr = C.sizeof_struct_sched_attr
5830+
5831+
type Cachestat C.struct_cachestat
5832+
type CachestatRange C.struct_cachestat_range

unix/syscall_linux.go

+2
Original file line numberDiff line numberDiff line change
@@ -2482,3 +2482,5 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
24822482
}
24832483
return attr, nil
24842484
}
2485+
2486+
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat, flags uint) (err error)

unix/zsyscall_linux.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux.go

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)