Re: [PATCH v2 10/11] selftests/mm: move uffd* routines from vm_util.c to uffd-common.c

From: Peter Xu
Date: Mon Jun 05 2023 - 15:25:39 EST


On Mon, Jun 05, 2023 at 12:09:56PM -0700, John Hubbard wrote:
> On 6/5/23 08:59, Peter Xu wrote:
> ...
> > > -$(OUTPUT)/uffd-stress: uffd-common.c
> > > -$(OUTPUT)/uffd-unit-tests: uffd-common.c
> > > +$(OUTPUT)/uffd-stress: uffd-common.c
> > > +$(OUTPUT)/uffd-unit-tests: uffd-common.c
> > > +$(OUTPUT)/hugepage-mremap: uffd-common.c
> > > +$(OUTPUT)/write_to_hugetlbfs: uffd-common.c
> > > +$(OUTPUT)/ksm_functional_tests: uffd-common.c
> >
> > Sorry, John, I still cannot follow..
> >
> > As I said before uffd-common.[ch] was for uffd stress/unit tests. I
> > confess my fault to not have named it uffd-test-common.[ch] already.
>
> Actually, given that there is nothing *except* test code in this
> directory, I think your original choice of file names is just right.
>
> >
> > I think it's fine to keep uffd_*() helpers in vm_util.[ch] for now, until
> > it grows. Just like if one day we'll have a pagemap.c test we don't
> > necessary need to move pagemap_*() helpers from vm_utils.[ch] into
> > pagemap.[ch]. It just keeps common test helpers.
> >
> > Can we avoid linking those into other tests in whatever way? Maybe
> > renaming it to uffd-test-common.[ch] may be cleaner?
> >
>
> It sounds like you are suggesting this:
>
> $(OUTPUT)/uffd-stress: uffd-common.c uffd-test-common.c
> $(OUTPUT)/uffd-unit-tests: uffd-common.c uffd-test-common.c
> $(OUTPUT)/hugepage-mremap: uffd-test-common.c
> $(OUTPUT)/write_to_hugetlbfs: uffd-test-common.c
> $(OUTPUT)/ksm_functional_tests: uffd-test-common.c
>
> ...approximately. Do I have that correct? I can arrange it that way
> if you feel it's a better end result. (And it's better than leaving
> uffd*() helpers in vm_utils, imho.)

Yes, as long as we don't link (especially) the uffd test specific globals
into non-uffd test programs I'll have no issue. Thanks.

--
Peter Xu