Re: [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb

2023-10-05 Thread Breno Leitao
On Wed, Oct 04, 2023 at 08:22:08PM -0400, Rik van Riel wrote: > On Wed, 2023-10-04 at 10:11 -0700, Breno Leitao wrote: > > > > +char *huge_ptr; > > + > > +/* Touch the memory while it is being madvised() */ > > +void *touch(void *unused) > > +{ > > +   char *ptr = (char *)huge_ptr; > > + > > +

Re: [PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb

2023-10-04 Thread Rik van Riel
On Wed, 2023-10-04 at 10:11 -0700, Breno Leitao wrote: > > +char *huge_ptr; > + > +/* Touch the memory while it is being madvised() */ > +void *touch(void *unused) > +{ > +   char *ptr = (char *)huge_ptr; > + > +   if (!ptr) { > +   fprintf(stderr, "Failed to allocate memory\n"

[PATCH 2/2] selftests/mm: Add a new test for madv and hugetlb

2023-10-04 Thread Breno Leitao
Create a selftest that exercises the conflict between page faults and madvise(MADV_DONTNEED) in the same huge page. Do it by running two threads that touches the huge page and madvise(MADV_DONTNEED) at the same time. In case of a SIGBUS coming at pagefault, the test should fail, since we hit the b