diff mbox series

selftests: iommu: add config needed for iommufd_fail_nth

Message ID 20240325090048.1423908-1-usama.anjum@collabora.com
State Accepted
Commit 2760c51b8040d7cffedc337939e7475a17cc4b19
Headers show
Series selftests: iommu: add config needed for iommufd_fail_nth | expand

Commit Message

Muhammad Usama Anjum March 25, 2024, 9 a.m. UTC
Add FAULT_INJECTION_DEBUG_FS and FAILSLAB configurations which are
needed by iommufd_fail_nth test.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
While building and running these tests on x86, defconfig had these
configs enabled. But ARM64's defconfig doesn't enable these configs.
Hence the config options are being added explicitly in this patch.
---
 tools/testing/selftests/iommu/config | 2 ++
 1 file changed, 2 insertions(+)

Comments

Muhammad Usama Anjum March 26, 2024, 1:09 p.m. UTC | #1
Even after applying this config patch and following snippet (which doesn't
terminate the program if mmap doesn't allocate exactly as the hint), I'm
finding failed tests.

@@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
        assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
        vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
                   mmap_flags, -1, 0);
-       assert(vrc == self->buffer);
+       assert(vrc == self->buffer);// ???

On x86:
# Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
On ARM64:
# Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0

The log files are attached.

On 3/25/24 2:00 PM, Muhammad Usama Anjum wrote:
> Add FAULT_INJECTION_DEBUG_FS and FAILSLAB configurations which are
> needed by iommufd_fail_nth test.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> While building and running these tests on x86, defconfig had these
> configs enabled. But ARM64's defconfig doesn't enable these configs.
> Hence the config options are being added explicitly in this patch.
> ---
>  tools/testing/selftests/iommu/config | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/iommu/config b/tools/testing/selftests/iommu/config
> index 110d73917615d..02a2a1b267c1e 100644
> --- a/tools/testing/selftests/iommu/config
> +++ b/tools/testing/selftests/iommu/config
> @@ -1,3 +1,5 @@
>  CONFIG_IOMMUFD=y
> +CONFIG_FAULT_INJECTION_DEBUG_FS=y
>  CONFIG_FAULT_INJECTION=y
>  CONFIG_IOMMUFD_TEST=y
> +CONFIG_FAILSLAB=y
Jason Gunthorpe March 26, 2024, 3:03 p.m. UTC | #2
On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
> Even after applying this config patch and following snippet (which doesn't
> terminate the program if mmap doesn't allocate exactly as the hint), I'm
> finding failed tests.
> 
> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>                    mmap_flags, -1, 0);
> -       assert(vrc == self->buffer);
> +       assert(vrc == self->buffer);// ???
> 
> On x86:
> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
> On ARM64:
> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
> 
> The log files are attached.

You probably don't have enough transparent huge pages available to the process

      echo 1024 > /proc/sys/vm/nr_hugepages

Jason
Muhammad Usama Anjum March 27, 2024, 10:14 a.m. UTC | #3
On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>> Even after applying this config patch and following snippet (which doesn't
>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>> finding failed tests.
>>
>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>                    mmap_flags, -1, 0);
>> -       assert(vrc == self->buffer);
>> +       assert(vrc == self->buffer);// ???
>>
>> On x86:
>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>> On ARM64:
>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>
>> The log files are attached.
> 
> You probably don't have enough transparent huge pages available to the process
> 
>       echo 1024 > /proc/sys/vm/nr_hugepages
After making huge pages available, the iommufd test always passed on x86.
But there are still failures on arm64. I'm looking into the failures.

cat /proc/sys/vm/nr_hugepages
1024
./iommufd
...
# Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0

> 
> Jason
>
Jason Gunthorpe March 27, 2024, 11:49 a.m. UTC | #4
On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
> > On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
> >> Even after applying this config patch and following snippet (which doesn't
> >> terminate the program if mmap doesn't allocate exactly as the hint), I'm
> >> finding failed tests.
> >>
> >> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
> >>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
> >>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
> >>                    mmap_flags, -1, 0);
> >> -       assert(vrc == self->buffer);
> >> +       assert(vrc == self->buffer);// ???
> >>
> >> On x86:
> >> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
> >> On ARM64:
> >> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
> >>
> >> The log files are attached.
> > 
> > You probably don't have enough transparent huge pages available to the process
> > 
> >       echo 1024 > /proc/sys/vm/nr_hugepages
> After making huge pages available, the iommufd test always passed on x86.
> But there are still failures on arm64. I'm looking into the failures.

Oh that is really strange. Joao? Nicolin?

> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap
> not ok 139 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear
> not ok 140 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear

> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap
> not ok 144 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear
> not ok 145 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear

> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap
> not ok 149 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear
> not ok 150 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear

> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
> not ok 159 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
> not ok 160 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear

> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap
> not ok 164 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear
> not ok 165 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear

> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap ...
> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap
> not ok 169 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap

> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear ...
> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
> # get_dirty_bitmap_no_clear: Test terminated by assertion
> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
> not ok 170 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
Joao Martins March 27, 2024, 2:59 p.m. UTC | #5
On 27/03/2024 11:49, Jason Gunthorpe wrote:
> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>> Even after applying this config patch and following snippet (which doesn't
>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>> finding failed tests.
>>>>
>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>                    mmap_flags, -1, 0);
>>>> -       assert(vrc == self->buffer);
>>>> +       assert(vrc == self->buffer);// ???
>>>>
>>>> On x86:
>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>> On ARM64:
>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>
>>>> The log files are attached.
>>>
>>> You probably don't have enough transparent huge pages available to the process
>>>
>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>> After making huge pages available, the iommufd test always passed on x86.
>> But there are still failures on arm64. I'm looking into the failures.
> 
> Oh that is really strange. Joao? Nicolin?
> 
Definitely strange, I'll have a look.

So it set the expected number of dirty bits as that assert doesn't fail, but it
is failing when we check that even bits are set but not odd ones. Like it's
hasn't set those bits.

For mock tests there should be no difference between x86 and ARM assuming the
typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
that I can think of that affected mock domain.

Muhammad, could you paste your kconfig?

>> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap
>> not ok 139 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear
>> not ok 140 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap
>> not ok 144 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear
>> not ok 145 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap
>> not ok 149 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear
>> not ok 150 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
>> not ok 159 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
>> not ok 160 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap
>> not ok 164 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear
>> not ok 165 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap ...
>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap
>> not ok 169 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap
> 
>> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear ...
>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
>> not ok 170 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
>
Muhammad Usama Anjum March 27, 2024, 5:49 p.m. UTC | #6
On 3/27/24 7:59 PM, Joao Martins wrote:
> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>> finding failed tests.
>>>>>
>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>                    mmap_flags, -1, 0);
>>>>> -       assert(vrc == self->buffer);
>>>>> +       assert(vrc == self->buffer);// ???
>>>>>
>>>>> On x86:
>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>> On ARM64:
>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>
>>>>> The log files are attached.
>>>>
>>>> You probably don't have enough transparent huge pages available to the process
>>>>
>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>> After making huge pages available, the iommufd test always passed on x86.
>>> But there are still failures on arm64. I'm looking into the failures.
>>
>> Oh that is really strange. Joao? Nicolin?
>>
> Definitely strange, I'll have a look.
> 
> So it set the expected number of dirty bits as that assert doesn't fail, but it
> is failing when we check that even bits are set but not odd ones. Like it's
> hasn't set those bits.
> 
> For mock tests there should be no difference between x86 and ARM assuming the
> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
> that I can think of that affected mock domain.
The config is attached. The defaults are being used i.e., 4k page.
> 
> Muhammad, could you paste your kconfig?
> 
>>> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap
>>> not ok 139 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear
>>> not ok 140 iommufd_dirty_tracking.domain_dirty128k.get_dirty_bitmap_no_clear
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap
>>> not ok 144 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear
>>> not ok 145 iommufd_dirty_tracking.domain_dirty256k.get_dirty_bitmap_no_clear
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap
>>> not ok 149 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear
>>> not ok 150 iommufd_dirty_tracking.domain_dirty640k.get_dirty_bitmap_no_clear
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
>>> not ok 159 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
>>> not ok 160 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap
>>> not ok 164 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear
>>> not ok 165 iommufd_dirty_tracking.domain_dirty256M.get_dirty_bitmap_no_clear
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap ...
>>> # iommufd_utils.h:374:get_dirty_bitmap:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap
>>> not ok 169 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap
>>
>>> #  RUN           iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear ...
>>> # iommufd_utils.h:374:get_dirty_bitmap_no_clear:Expected j < npte (1) == test_bit(i + j, (unsigned long *)bitmap) (0)
>>> # get_dirty_bitmap_no_clear: Test terminated by assertion
>>> #          FAIL  iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
>>> not ok 170 iommufd_dirty_tracking.domain_dirty256M_huge.get_dirty_bitmap_no_clear
>>
>
Joao Martins March 27, 2024, 6:09 p.m. UTC | #7
On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
> On 3/27/24 7:59 PM, Joao Martins wrote:
>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>> finding failed tests.
>>>>>>
>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>                    mmap_flags, -1, 0);
>>>>>> -       assert(vrc == self->buffer);
>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>
>>>>>> On x86:
>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>> On ARM64:
>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>
>>>>>> The log files are attached.
>>>>>
>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>
>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>> After making huge pages available, the iommufd test always passed on x86.
>>>> But there are still failures on arm64. I'm looking into the failures.
>>>
>>> Oh that is really strange. Joao? Nicolin?
>>>
>> Definitely strange, I'll have a look.
>>
>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>> is failing when we check that even bits are set but not odd ones. Like it's
>> hasn't set those bits.
>>
>> For mock tests there should be no difference between x86 and ARM assuming the
>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>> that I can think of that affected mock domain.
> The config is attached. The defaults are being used i.e., 4k page.

Looks like CONFIG_IOMMUFD_DRIVER is not defined :(

Thus no bits are being set.
Muhammad Usama Anjum March 27, 2024, 6:17 p.m. UTC | #8
On 3/27/24 11:09 PM, Joao Martins wrote:
> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
>> On 3/27/24 7:59 PM, Joao Martins wrote:
>>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>>> finding failed tests.
>>>>>>>
>>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>>                    mmap_flags, -1, 0);
>>>>>>> -       assert(vrc == self->buffer);
>>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>>
>>>>>>> On x86:
>>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>>> On ARM64:
>>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>>
>>>>>>> The log files are attached.
>>>>>>
>>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>>
>>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>>> After making huge pages available, the iommufd test always passed on x86.
>>>>> But there are still failures on arm64. I'm looking into the failures.
>>>>
>>>> Oh that is really strange. Joao? Nicolin?
>>>>
>>> Definitely strange, I'll have a look.
>>>
>>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>>> is failing when we check that even bits are set but not odd ones. Like it's
>>> hasn't set those bits.
>>>
>>> For mock tests there should be no difference between x86 and ARM assuming the
>>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>>> that I can think of that affected mock domain.
>> The config is attached. The defaults are being used i.e., 4k page.
> 
> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
I'll retest with this config and update the patch to include it in the
config fragment needed for this test. Once we add all required config
options in config fragment, the test should never fail. Somehow this gets
included in the x86, but not on ARM.

> 
> Thus no bits are being set.
>
Jason Gunthorpe March 27, 2024, 6:20 p.m. UTC | #9
On Wed, Mar 27, 2024 at 06:09:37PM +0000, Joao Martins wrote:
> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
> > On 3/27/24 7:59 PM, Joao Martins wrote:
> >> On 27/03/2024 11:49, Jason Gunthorpe wrote:
> >>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
> >>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
> >>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
> >>>>>> Even after applying this config patch and following snippet (which doesn't
> >>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
> >>>>>> finding failed tests.
> >>>>>>
> >>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
> >>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
> >>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
> >>>>>>                    mmap_flags, -1, 0);
> >>>>>> -       assert(vrc == self->buffer);
> >>>>>> +       assert(vrc == self->buffer);// ???
> >>>>>>
> >>>>>> On x86:
> >>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
> >>>>>> On ARM64:
> >>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
> >>>>>>
> >>>>>> The log files are attached.
> >>>>>
> >>>>> You probably don't have enough transparent huge pages available to the process
> >>>>>
> >>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
> >>>> After making huge pages available, the iommufd test always passed on x86.
> >>>> But there are still failures on arm64. I'm looking into the failures.
> >>>
> >>> Oh that is really strange. Joao? Nicolin?
> >>>
> >> Definitely strange, I'll have a look.
> >>
> >> So it set the expected number of dirty bits as that assert doesn't fail, but it
> >> is failing when we check that even bits are set but not odd ones. Like it's
> >> hasn't set those bits.
> >>
> >> For mock tests there should be no difference between x86 and ARM assuming the
> >> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
> >> that I can think of that affected mock domain.
> > The config is attached. The defaults are being used i.e., 4k page.
> 
> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
> 
> Thus no bits are being set.

Oh! 

--- a/drivers/iommu/iommufd/Kconfig
+++ b/drivers/iommu/iommufd/Kconfig
@@ -37,6 +37,7 @@ config IOMMUFD_TEST
        depends on DEBUG_KERNEL
        depends on FAULT_INJECTION
        depends on RUNTIME_TESTING_MENU
+       select IOMMUFD_DRIVER
        default n
        help
          This is dangerous, do not enable unless running


???

Jason
Joao Martins March 27, 2024, 6:33 p.m. UTC | #10
On 27/03/2024 18:17, Muhammad Usama Anjum wrote:
> On 3/27/24 11:09 PM, Joao Martins wrote:
>> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
>>> On 3/27/24 7:59 PM, Joao Martins wrote:
>>>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>>>> finding failed tests.
>>>>>>>>
>>>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>>>                    mmap_flags, -1, 0);
>>>>>>>> -       assert(vrc == self->buffer);
>>>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>>>
>>>>>>>> On x86:
>>>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>>>> On ARM64:
>>>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>>>
>>>>>>>> The log files are attached.
>>>>>>>
>>>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>>>
>>>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>>>> After making huge pages available, the iommufd test always passed on x86.
>>>>>> But there are still failures on arm64. I'm looking into the failures.
>>>>>
>>>>> Oh that is really strange. Joao? Nicolin?
>>>>>
>>>> Definitely strange, I'll have a look.
>>>>
>>>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>>>> is failing when we check that even bits are set but not odd ones. Like it's
>>>> hasn't set those bits.
>>>>
>>>> For mock tests there should be no difference between x86 and ARM assuming the
>>>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>>>> that I can think of that affected mock domain.
>>> The config is attached. The defaults are being used i.e., 4k page.
>>
>> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
> I'll retest with this config and update the patch to include it in the
> config fragment needed for this test. Once we add all required config
> options in config fragment, the test should never fail. Somehow this gets
> included in the x86, but not on ARM.

The option is automatically selected by an user of iova_bitmap_set(). x86 has
AMD and Intel IOMMUs which use it and auto selected (ARM64 doesn't yet, but soon
to be a reality). Some vfio drivers get it auto-selected it as well.

But I forgot to do the same thing for iommufd-test kconfig in commit a9af47e382a
("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP") where mock domain also
uses iova_bitmap_set(). So your patch is likely not the right place to set
CONFIG_IOMMUFD_DRIVER=y.

See Jason's snip on auto-selecting if IOMMUFD_TEST is set.
Joao Martins March 27, 2024, 6:34 p.m. UTC | #11
On 27/03/2024 18:20, Jason Gunthorpe wrote:
> On Wed, Mar 27, 2024 at 06:09:37PM +0000, Joao Martins wrote:
>> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
>>> On 3/27/24 7:59 PM, Joao Martins wrote:
>>>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>>>> finding failed tests.
>>>>>>>>
>>>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>>>                    mmap_flags, -1, 0);
>>>>>>>> -       assert(vrc == self->buffer);
>>>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>>>
>>>>>>>> On x86:
>>>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>>>> On ARM64:
>>>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>>>
>>>>>>>> The log files are attached.
>>>>>>>
>>>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>>>
>>>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>>>> After making huge pages available, the iommufd test always passed on x86.
>>>>>> But there are still failures on arm64. I'm looking into the failures.
>>>>>
>>>>> Oh that is really strange. Joao? Nicolin?
>>>>>
>>>> Definitely strange, I'll have a look.
>>>>
>>>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>>>> is failing when we check that even bits are set but not odd ones. Like it's
>>>> hasn't set those bits.
>>>>
>>>> For mock tests there should be no difference between x86 and ARM assuming the
>>>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>>>> that I can think of that affected mock domain.
>>> The config is attached. The defaults are being used i.e., 4k page.
>>
>> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
>>
>> Thus no bits are being set.
> 
> Oh! 
> 
> --- a/drivers/iommu/iommufd/Kconfig
> +++ b/drivers/iommu/iommufd/Kconfig
> @@ -37,6 +37,7 @@ config IOMMUFD_TEST
>         depends on DEBUG_KERNEL
>         depends on FAULT_INJECTION
>         depends on RUNTIME_TESTING_MENU
> +       select IOMMUFD_DRIVER
>         default n
>         help
>           This is dangerous, do not enable unless running
> 
> 
> ???

Yeap. It probably needs a:

Fixes: a9af47e382a ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP")
Muhammad Usama Anjum March 27, 2024, 8:13 p.m. UTC | #12
On 3/27/24 11:20 PM, Jason Gunthorpe wrote:
> On Wed, Mar 27, 2024 at 06:09:37PM +0000, Joao Martins wrote:
>> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
>>> On 3/27/24 7:59 PM, Joao Martins wrote:
>>>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>>>> finding failed tests.
>>>>>>>>
>>>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>>>                    mmap_flags, -1, 0);
>>>>>>>> -       assert(vrc == self->buffer);
>>>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>>>
>>>>>>>> On x86:
>>>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>>>> On ARM64:
>>>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>>>
>>>>>>>> The log files are attached.
>>>>>>>
>>>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>>>
>>>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>>>> After making huge pages available, the iommufd test always passed on x86.
>>>>>> But there are still failures on arm64. I'm looking into the failures.
>>>>>
>>>>> Oh that is really strange. Joao? Nicolin?
>>>>>
>>>> Definitely strange, I'll have a look.
>>>>
>>>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>>>> is failing when we check that even bits are set but not odd ones. Like it's
>>>> hasn't set those bits.
>>>>
>>>> For mock tests there should be no difference between x86 and ARM assuming the
>>>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>>>> that I can think of that affected mock domain.
>>> The config is attached. The defaults are being used i.e., 4k page.
>>
>> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
>>
>> Thus no bits are being set.
> 
> Oh! 
> 
> --- a/drivers/iommu/iommufd/Kconfig
> +++ b/drivers/iommu/iommufd/Kconfig
> @@ -37,6 +37,7 @@ config IOMMUFD_TEST
>         depends on DEBUG_KERNEL
>         depends on FAULT_INJECTION
>         depends on RUNTIME_TESTING_MENU
> +       select IOMMUFD_DRIVER
>         default n
>         help
>           This is dangerous, do not enable unless running
> 
Tested this patch on my system and it fixes all issues for ARM64. Please
add tag for this Kconfig patch:
Tested by: Muhammad Usama Anjum <usama.anjum@collabora.com>

Also please accept the patch in this current series.
> 
> ???
> 
> Jason
Muhammad Usama Anjum April 4, 2024, 11:48 a.m. UTC | #13
On 3/28/24 1:13 AM, Muhammad Usama Anjum wrote:
> On 3/27/24 11:20 PM, Jason Gunthorpe wrote:
>> On Wed, Mar 27, 2024 at 06:09:37PM +0000, Joao Martins wrote:
>>> On 27/03/2024 17:49, Muhammad Usama Anjum wrote:
>>>> On 3/27/24 7:59 PM, Joao Martins wrote:
>>>>> On 27/03/2024 11:49, Jason Gunthorpe wrote:
>>>>>> On Wed, Mar 27, 2024 at 03:14:25PM +0500, Muhammad Usama Anjum wrote:
>>>>>>> On 3/26/24 8:03 PM, Jason Gunthorpe wrote:
>>>>>>>> On Tue, Mar 26, 2024 at 06:09:34PM +0500, Muhammad Usama Anjum wrote:
>>>>>>>>> Even after applying this config patch and following snippet (which doesn't
>>>>>>>>> terminate the program if mmap doesn't allocate exactly as the hint), I'm
>>>>>>>>> finding failed tests.
>>>>>>>>>
>>>>>>>>> @@ -1746,7 +1748,7 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
>>>>>>>>>         assert((uintptr_t)self->buffer % HUGEPAGE_SIZE == 0);
>>>>>>>>>         vrc = mmap(self->buffer, variant->buffer_size, PROT_READ | PROT_WRITE,
>>>>>>>>>                    mmap_flags, -1, 0);
>>>>>>>>> -       assert(vrc == self->buffer);
>>>>>>>>> +       assert(vrc == self->buffer);// ???
>>>>>>>>>
>>>>>>>>> On x86:
>>>>>>>>> # Totals: pass:176 fail:4 xfail:0 xpass:0 skip:0 error:0
>>>>>>>>> On ARM64:
>>>>>>>>> # Totals: pass:166 fail:14 xfail:0 xpass:0 skip:0 error:0
>>>>>>>>>
>>>>>>>>> The log files are attached.
>>>>>>>>
>>>>>>>> You probably don't have enough transparent huge pages available to the process
>>>>>>>>
>>>>>>>>       echo 1024 > /proc/sys/vm/nr_hugepages
>>>>>>> After making huge pages available, the iommufd test always passed on x86.
>>>>>>> But there are still failures on arm64. I'm looking into the failures.
>>>>>>
>>>>>> Oh that is really strange. Joao? Nicolin?
>>>>>>
>>>>> Definitely strange, I'll have a look.
>>>>>
>>>>> So it set the expected number of dirty bits as that assert doesn't fail, but it
>>>>> is failing when we check that even bits are set but not odd ones. Like it's
>>>>> hasn't set those bits.
>>>>>
>>>>> For mock tests there should be no difference between x86 and ARM assuming the
>>>>> typical 4K page-size. Maybe this is 64k base pages in ARM? That's the only thing
>>>>> that I can think of that affected mock domain.
>>>> The config is attached. The defaults are being used i.e., 4k page.
>>>
>>> Looks like CONFIG_IOMMUFD_DRIVER is not defined :(
>>>
>>> Thus no bits are being set.
>>
>> Oh! 
>>
>> --- a/drivers/iommu/iommufd/Kconfig
>> +++ b/drivers/iommu/iommufd/Kconfig
>> @@ -37,6 +37,7 @@ config IOMMUFD_TEST
>>         depends on DEBUG_KERNEL
>>         depends on FAULT_INJECTION
>>         depends on RUNTIME_TESTING_MENU
>> +       select IOMMUFD_DRIVER
>>         default n
>>         help
>>           This is dangerous, do not enable unless running
>>
> Tested this patch on my system and it fixes all issues for ARM64. Please
> add tag for this Kconfig patch:
> Tested by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> 
> Also please accept the patch in this current series.
Please let me know if you need me to send the config patch. Please accept
the config patch as well.

>>
>> ???
>>
>> Jason
>
Muhammad Usama Anjum April 14, 2024, 2:39 p.m. UTC | #14
On 4/5/24 5:10 AM, Jason Gunthorpe wrote:
> On Mon, Mar 25, 2024 at 02:11:41PM +0500, Muhammad Usama Anjum wrote:
>> On 3/25/24 2:00 PM, Muhammad Usama Anjum wrote:
>>> Add FAULT_INJECTION_DEBUG_FS and FAILSLAB configurations which are
>>> needed by iommufd_fail_nth test.
>>>
>>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>>> ---
>>> While building and running these tests on x86, defconfig had these
>>> configs enabled. But ARM64's defconfig doesn't enable these configs.
>>> Hence the config options are being added explicitly in this patch.
>> Please disregard this extra comment. Overall this patch is needed to enable
>> these config options of x86 and ARM both.
> 
> I picked this and the other patch up, thanks
Not sure why but I'm unable to find this patch in next and in your tree:
https://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git/log/?h=for-next

Maybe this patch was missed?


> 
> Jason
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/iommu/config b/tools/testing/selftests/iommu/config
index 110d73917615d..02a2a1b267c1e 100644
--- a/tools/testing/selftests/iommu/config
+++ b/tools/testing/selftests/iommu/config
@@ -1,3 +1,5 @@ 
 CONFIG_IOMMUFD=y
+CONFIG_FAULT_INJECTION_DEBUG_FS=y
 CONFIG_FAULT_INJECTION=y
 CONFIG_IOMMUFD_TEST=y
+CONFIG_FAILSLAB=y