[LTP] [RFC PATCH] readahead02: detect cache stats via mincore per testfile
Jan Stancek
jstancek@redhat.com
Wed Nov 26 09:14:52 CET 2025
On Wed, Nov 26, 2025 at 8:35 AM Li Wang via ltp <ltp@lists.linux.it> wrote:
>
> Stop sampling global “Cached” from /proc/meminfo and instead measure how
> many bytes of the current test file are resident via mincore(). This lets
> the test report per-file cache usage, removes the MEMINFO dependency, and
> makes the readahead wait loop watch the actual file cache growth.
>
> Because the mincore values are already in bytes we no longer juggle
> cached_high/cached_low deltas nor scale by 1024. The cache-capacity gate
> now compares cached_max directly against testfile_size, and the user-
> visible kB prints are derived from the byte counters.
>
> Note: this patch besed on Cyril's change:
> https://lists.linux.it/pipermail/ltp/2025-November/045718.html
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
> .../kernel/syscalls/readahead/readahead02.c | 86 ++++++++++++-------
> 1 file changed, 53 insertions(+), 33 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> index e0f56e989..00ab470c4 100644
> --- a/testcases/kernel/syscalls/readahead/readahead02.c
> +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> @@ -36,7 +36,6 @@
>
> static char testfile[PATH_MAX] = "testfile";
> #define DROP_CACHES_FNAME "/proc/sys/vm/drop_caches"
> -#define MEMINFO_FNAME "/proc/meminfo"
> #define PROC_IO_FNAME "/proc/self/io"
> #define DEFAULT_FILESIZE (64 * 1024 * 1024)
> #define INITIAL_SHORT_SLEEP_US 10000
> @@ -110,13 +109,45 @@ static unsigned long get_bytes_read(void)
> return ret;
> }
>
> -static unsigned long get_cached_size(void)
> +static unsigned long get_file_cached_bytes(const char *path, size_t length)
Atm. I don't see an issue with this approach, just wondering whether
this function would be useful
to have somewhere in lib, what do you think?
More information about the ltp
mailing list