syscalls/preadv203: Add basic RWF_NOWAIT test
PATCH v2 1/1 syscalls/preadv203: Add basic RWF_NOWAIT test
We are attempting to trigger the EAGAIN path for the RWF_NOWAIT flag.
In order to do so the test runs three threads:
* nowait_reader: reads from a random offset from a random file with RWF_NOWAIT flag and expects to get EAGAIN and short read sooner or later
* writer_thread: rewrites random file in order to keep the underlying device bussy so that pages evicted from cache cannot be faulted immediatelly
* cache_dropper: attempts to evict pages from a cache in order for reader to hit evicted page sooner or later
---
This is just the same as previous patch + small (typo) fixes and fallback definition for RWF_NOWAIT.
I've also looked into the BLKFLSBUF ioctl() however that one only seem to drop cached pages but no pages schedulled for writeback, hence it does not generate I/O pressure at all.
include/lapi/preadv2.h | 4 + runtest/syscalls | 2 + testcases/kernel/syscalls/preadv2/.gitignore | 2 + testcases/kernel/syscalls/preadv2/Makefile | 4 + testcases/kernel/syscalls/preadv2/preadv203.c | 267 ++++++++++++++++++ 5 files changed, 279 insertions(+) create mode 100644 testcases/kernel/syscalls/preadv2/preadv203.c
include/lapi/preadv2.h +4 -0
@@ -10,6 +10,10 @@#include "config.h" #include "lapi/syscalls.h" +#ifndef RWF_NOWAIT +# define RWF_NOWAIT 0x00000008 +#endif +#if !defined(HAVE_PREADV2 )/* LO_HI_LONG taken from glibc */
runtest/syscalls +2 -0
@@ -873,6 +873,8 @@ preadv201 preadv201 preadv201_64 preadv201_64 preadv202 preadv202 preadv202_64 preadv202_64 +preadv203 preadv203 +preadv203_64 preadv203_64 profil01 profil01
testcases/kernel/syscalls/preadv2/.gitignore +2 -0
@@ -2,3 +2,5 @@ /preadv201_64 /preadv202 /preadv202_64 +/preadv203 +/preadv203_64
testcases/kernel/syscalls/preadv2/Makefile +4 -0
@@ -11,4 +11,8 @@ include $(abs_srcdir)/../utils/newer_64.mk %_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 +preadv203: CFLAGS += -pthread +preadv203_64: CFLAGS += -pthread +preadv203_64: LDFLAGS += -pthread + include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/preadv2/preadv203.c new file +267 -0
267 lines not on this page · raw message
Signature · 1 line
2.19.2
PATCH v2 1/1 syscalls/preadv203: Add basic RWF_NOWAIT test
Hi!
Ping, anybody has any comments or can be this be this merged?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 syscalls/preadv203: Add basic RWF_NOWAIT test
Quoted 4 lines · Cyril Hrubis
Hi!
Ping, anybody has any comments or can be this be this merged?
I have no objection to this test, but I have a question. Your claim is:
"We are attempting to trigger the EAGAIN path for the RWF_NOWAIT flag."
Seems like you have gone to a great length of effort to achieve this. Wouldn't it be sufficient to do a single preadv2 after fsync+drop_caches in order to observe EAGAIN?
There are several other ways to get EAGAIN, like DIO read/write when page cache *is* populated.
Question is, how much is the test trying to cover.
Thanks,
Amir.
PATCH v2 1/1 syscalls/preadv203: Add basic RWF_NOWAIT test
Hi!
Quoted 9 lines
Quoted 2 lines
Ping, anybody has any comments or can be this be this merged?
I have no objection to this test, but I have a question. Your claim is:
"We are attempting to trigger the EAGAIN path for theRWF_NOWAITflag."Seems like you have gone to a great length of effort to achieve this. Wouldn't it be sufficient to do a single preadv2 after fsync+drop_caches in order to observe EAGAIN?
As far as I can tell the I/O to the device has to be saturated in order to get EAGAIN at least for a subset of filesystems. If I just drop the cache once then attempt to read with the NOWAIT flag it strangely works only for ext2 for me.
So I guess that the manual page is a bit misleading and the NOWAIT flag actually returns EAGAIN only if the calling thread would end up in a queue or waiting for a lock, but I haven't looked into the kernel code to make sure.
Quoted 2 lines
There are several other ways to get EAGAIN, like DIO read/write when page cache *is* populated.
That is a good hint, I will have a look at that case as well.
Quoted 1 line
Question is, how much is the test trying to cover.
Well ideally we should excercise as much kernel code paths as possible... :-)
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 syscalls/preadv203: Add basic RWF_NOWAIT test
In reply to Cyril HrubisHi!
FYI pushed.
Signature · 2 lines
Cyril Hrubis [email protected]