[LTP] [PATCH 1/1] readahead02: Sleep 1.5 msec to fix problem on bare metal

Cyril Hrubis chrubis@suse.cz
Fri Nov 21 11:41:17 CET 2025


Hi!
> This fixes ppc64le bare metal. It looks like kernel needs some time to
> update counters.

In this case I think that something is needed for the kernel to actually
do some readahead. The readahead() syscall is supposed to initiate
readahead but kernel will need some time for the actual readahead to
happen. And how much time will depend on the I/O speed and saturation of
the I/O bus/disk.

Adding a short sleep is a good start. However I'm afraid that we will
need a bit more complex solution to this problem. Maybe do a short
sleep, check the cache size and if it increased more than some
threshold, sleep again.

Something as:

	int retries = MAX_RETRIES;
	unsigned long cached_prev, cached_cur = get_cached_size();

	do {
		usleep(SHORT_SLEEP);

		cached_prev = cached_cur;
		cached_cur = get_cached_size();

		if (cached_cur < cached_prev)
			break;

		if (cached_cur-cached_prev < CACHE_INC_THRESHOLD)
			break;

	} while (retries-- > 0);

> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/syscalls/readahead/readahead02.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> index f007db187e..05537ca991 100644
> --- a/testcases/kernel/syscalls/readahead/readahead02.c
> +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> @@ -173,6 +173,7 @@ static int read_testfile(struct tcase *tc, int do_readahead,
>  
>  			i++;
>  			offset += readahead_length;
> +			usleep(1500);
>  		} while ((size_t)offset < fsize);
>  		tst_res(TINFO, "readahead calls made: %zu", i);
>  		*cached = get_cached_size();
> -- 
> 2.51.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list