Lines Matching +full:wait +full:- +full:on +full:- +full:read

1 // SPDX-License-Identifier: GPL-2.0
3 * memfd GUP test-case
5 * fuse_mnt.c program to provide a fake direct-IO FUSE mount-point for us. This
6 * file-system delays _all_ reads by 1s and forces direct-IO. This means, any
7 * read() on files in that file-system will pin the receive-buffer pages for at
10 * We use this trick to race ADD_SEALS against a write on a memfd object. The
12 * the read() syscall with our memory-mapped memfd object as receive buffer to
34 #include <sys/wait.h>
97 printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", in mfd_assert_add_seals()
116 printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected with EBUSY: %m\n", in mfd_busy_add_seals()
160 static int global_mfd = -1;
170 * SEAL_WRITE. This _must_ fail as the parent thread has a read() into in sealing_thread_fn()
172 * We then wait one more second and try sealing again. This time it in sealing_thread_fn()
176 /* wait 200ms for FUSE-request to be active */ in sealing_thread_fn()
184 * implement page-replacements or other fancy ways to avoid racing in sealing_thread_fn()
190 /* wait 1s more so the FUSE-request is done */ in sealing_thread_fn()
237 printf("error: please pass path to file in fuse_mnt mount-point\n"); in main()
268 /* create new memfd-object */ in main()
273 /* mmap memfd-object for writing */ in main()
276 /* pass mfd+mapping to a separate sealing-thread which tries to seal in main()
282 /* Use read() on the FUSE file to read into our memory-mapped memfd in main()
284 * memfd-object. in main()
285 * If @fd is on the memfd-fake-FUSE-FS, the read() is delayed by 1s. in main()
286 * This guarantees that the receive-buffer is pinned for 1s until the in main()
289 r = read(fd, p, mfd_def_size); in main()
291 printf("read() failed: %m\n"); in main()
294 printf("unexpected EOF on read()\n"); in main()
300 /* Wait for sealing-thread to finish and verify that it in main()
305 /* *IF* the memfd-object was sealed at the time our read() returned, in main()
306 * then the kernel did a page-replacement or canceled the read() (or in main()
309 * In case the memfd-object was *not* sealed, the read() was successfull in main()
312 * in this test-cases, we have explicit 200ms delays which should be in main()
313 * enough to avoid any in-flight writes. */ in main()
317 printf("memfd sealed during read() but data not discarded\n"); in main()
320 printf("memfd sealed after read() but data discarded\n"); in main()