On Wed, 15 Nov 2023 at 10:50, David Howells dhowells@redhat.com wrote:
(3) Add a function to set up a userspace VM, attach the VM to the kunit testing thread, create an anonymous file, stuff some pages into the file and map the file into the VM to act as a buffer that can be used with UBUF/IOVEC iterators.
I map an anonymous file with pages attached rather than using MAP_ANON so that I can check the pages obtained from iov_iter_extract_pages() without worrying about them changing due to swap, migrate, etc.. [?] Is this the best way to do things? Mirroring execve, it requires a number of extra core symbols to be exported. Should this be done in the core code?
Do you really need to do this as a kunit test in the kernel itself?
Why not just make it a user-space test as part of tools/testing/selftests?
That's what it smells like to me. You're doing user-level tests, but you're doing them in the wrong place, so you need to jump through all these hoops that you really shouldn't.
Linus