Hi Ricardo, On Tue, Sep 06, 2022 at 06:09:18PM +0000, Ricardo Koller wrote: > Move the generic userfaultfd code out of demand_paging_test.c into a > common library, userfaultfd_util. This library consists of a setup and a > stop function. The setup function starts a thread for handling page > faults using the handler callback function. This setup returns a > uffd_desc object which is then used in the stop function (to wait and > destroy the threads). > > Reviewed-by: Ben Gardon <bgardon@xxxxxxxxxx> > Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx> > --- [...] > diff --git a/tools/testing/selftests/kvm/include/userfaultfd_util.h b/tools/testing/selftests/kvm/include/userfaultfd_util.h > new file mode 100644 > index 000000000000..a1a386c083b0 > --- /dev/null > +++ b/tools/testing/selftests/kvm/include/userfaultfd_util.h > @@ -0,0 +1,46 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * KVM userfaultfd util > + * Adapted from demand_paging_test.c nit: Don't reference demand_paging_test.c, as it won't make sense unless the reader also looks at this diff. > + * > + * Copyright (C) 2018, Red Hat, Inc. > + * Copyright (C) 2019-2022 Google LLC > + */ [...] > diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c > new file mode 100644 > index 000000000000..4395032ccbe4 > --- /dev/null > +++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c > @@ -0,0 +1,187 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * KVM userfaultfd util > + * Adapted from demand_paging_test.c > + * > + * Copyright (C) 2018, Red Hat, Inc. > + * Copyright (C) 2019, Google, Inc. > + * Copyright (C) 2022, Google, Inc. nit: use the same copyrights as the header file. With that: Reviewed-by: Oliver Upton <oliver.upton@xxxxxxxxx>