From: Matteo Croce <technoboy85@gmail.com>
To: linux-man@vger.kernel.org
Cc: Nhat Pham <nphamcs@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Matteo Croce <teknoraver@meta.com>
Subject: [PATCH] man/man2/cachestat.2: add a man page for cachestat()
Date: Thu, 22 May 2025 17:21:49 -0400 [thread overview]
Message-ID: <20250522212149.36049-1-technoboy85@gmail.com> (raw)
From: Matteo Croce <teknoraver@meta.com>
Add a missing man page for cachestat().
The text was converted from the commit message:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cf264e1329fb0307e044f7675849f9f38b44c11a
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: Matteo Croce <teknoraver@meta.com>
---
man/man2/cachestat.2 | 109 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 man/man2/cachestat.2
diff --git a/man/man2/cachestat.2 b/man/man2/cachestat.2
new file mode 100644
index 000000000..f741e3695
--- /dev/null
+++ b/man/man2/cachestat.2
@@ -0,0 +1,109 @@
+.\" Copyright, the authors of the Linux man-pages project
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH CACHESTAT 2 (date) "Linux man-pages (unreleased)"
+.SH NAME
+cachestat \- query the page cache statistics of a file
+.SH SYNOPSIS
+.B #include <sys/mman.h>
+.PP
+.B struct cachestat_range {
+.br
+.RS
+__u64 off;
+.br
+__u64 len;
+.RE
+.B };
+.PP
+.B struct cachestat {
+.br
+.RS
+__u64 nr_cache;
+.br
+__u64 nr_dirty;
+.br
+__u64 nr_writeback;
+.br
+__u64 nr_evicted;
+.br
+__u64 nr_recently_evicted;
+.RE
+.B };
+.PP
+.BI "int cachestat(unsigned int " fd ", struct cachestat_range *" cstat_range ","
+.br
+.BI " struct cachestat *" cstat ", unsigned int " flags ");"
+.SH DESCRIPTION
+.B cachestat()
+queries the number of cached pages, dirty pages, pages marked for writeback, evicted pages, and recently evicted pages in the byte range specified by
+.I off
+and
+.I len
+in the
+.B cachestat_range
+structure.
+.PP
+An evicted page is one that was previously in the page cache but has since been evicted.
+A page is considered recently evicted if its reentry into the cache would indicate active usage under memory pressure.
+.PP
+The results are returned in a
+.B cachestat
+structure, pointed to by the
+.I cstat
+argument.
+.PP
+The
+.I off
+and
+.I len
+fields must be non-negative. If
+.I len > 0
+, the queried range is
+.B [off, off + len]
+. If
+.I len == 0
+, the range is from
+.I off
+to the end of the file.
+.PP
+The
+.I flags
+argument is reserved for future use and must be set to
+.B 0
+.
+.PP
+Currently,
+.B hugetlbfs
+files are not supported.
+.PP
+Note that the status of a page may change after
+.B cachestat()
+retrieves it but before the values are returned to the application; thus, the values may be slightly outdated.
+.SH RETURN VALUE
+On success,
+.B cachestat()
+returns 0. On error, \-1 is returned and
+.I errno
+is set appropriately.
+.SH ERRORS
+.TP
+.B EFAULT
+.I cstat
+or
+.I cstat_range
+points to an invalid address.
+.TP
+.B EINVAL
+Invalid
+.I flags
+value.
+.TP
+.B EBADF
+Invalid file descriptor.
+.TP
+.B EOPNOTSUPP
+The file descriptor refers to a
+.B hugetlbfs
+file, which is unsupported.
--
2.49.0
next reply other threads:[~2025-05-22 21:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 21:21 Matteo Croce [this message]
2025-05-24 18:21 ` [PATCH] man/man2/cachestat.2: add a man page for cachestat() Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250522212149.36049-1-technoboy85@gmail.com \
--to=technoboy85@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=linux-man@vger.kernel.org \
--cc=nphamcs@gmail.com \
--cc=teknoraver@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.