[LTP] [RFC PATCH] readahead02: detect cache stats via mincore per testfile
Li Wang
liwang@redhat.com
Wed Nov 26 09:31:06 CET 2025
On Wed, Nov 26, 2025 at 4:15 PM Jan Stancek <jstancek@redhat.com> wrote:
> 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?
>
Maybe yes, but the problem is that when we use mincore() to
determine the resident memory that usually requires a few more
loops to wait for the I/O cache to be completed.
Like last time, I used mincore() to determine MAP_DROPPABLE
page reclaimed in commit 94a6901d7e982f3e52b, it also needs
incert usleep(100000) there for waiting.
So the point is to flexibly use mincore() function and customise
what we need in different scenarios. By now I don't see other test
has the same requirement for get_file_cached_bytes(const char *path, size_t
length),
hence now I would keep it in readahead02.
Or, let's hear other voices, maybe I missed something.
--
Regards,
Li Wang
More information about the ltp
mailing list