Re: [PATCH v4 09/14] selftests: harness: Move teardown conditional into test metadata

From: Thomas Weißschuh
Date: Tue Jun 10 2025 - 07:38:45 EST


Hi Nicolin,

On Mon, Jun 09, 2025 at 11:49:05PM -0700, Nicolin Chen wrote:
> CC += Jason
>
> On Mon, May 05, 2025 at 05:15:27PM +0200, Thomas Weißschuh wrote:
> > To get rid of setjmp()/longjmp(), the teardown logic needs to be usable
> > from __bail(). To access the atomic teardown conditional from there,
> > move it into the test metadata.
> > This also allows the removal of "setup_completed".
> >
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
> > Acked-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
>
> Certain hugepage tests in iommufd selftest (CONFIG_IOMMUFD_TEST)
> start to fail since v6.16-rc1, though the test functions weren't
> changed during last cycle:

Thanks for the report.

> ------------------------------------------------------------------
> # RUN iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty ...
> # enforce_dirty: Test terminated unexpectedly by signal 11
> # FAIL iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty
> not ok 193 iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty
> # RUN iommufd_dirty_tracking.domain_dirty128M_huge.set_dirty_tracking ...
> # set_dirty_tracking: Test terminated unexpectedly by signal 11
> # FAIL iommufd_dirty_tracking.domain_dirty128M_huge.set_dirty_tracking
> not ok 194 iommufd_dirty_tracking.domain_dirty128M_huge.set_dirty_tracking
> # RUN iommufd_dirty_tracking.domain_dirty128M_huge.device_dirty_capability ...
> # device_dirty_capability: Test terminated unexpectedly by signal 11
> # FAIL iommufd_dirty_tracking.domain_dirty128M_huge.device_dirty_capability
> not ok 195 iommufd_dirty_tracking.domain_dirty128M_huge.device_dirty_capability
> # RUN iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap ...
> # get_dirty_bitmap: Test terminated unexpectedly by signal 11
> # FAIL iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
> not ok 196 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap
> # RUN iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear ...
> # get_dirty_bitmap_no_clear: Test terminated unexpectedly by signal 11
> # FAIL iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
> not ok 197 iommufd_dirty_tracking.domain_dirty128M_huge.get_dirty_bitmap_no_clear
> ------------------------------------------------------------------
>
> Git bisect points to this patch, and reverting it and its following
> patches fixes these.
>
> I haven't debugged it, hoping you might have a quick thought. Lemme
> know if you need some details to figure out what's going on.

I can't reproduce this report.
On my development machine or a virtme-ng VM I get the following failure:

# ./iommufd -r iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty
TAP version 13
1..1
# Starting 1 tests from 1 test cases.
# RUN iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty ...
iommufd: iommufd.c:2042: iommufd_dirty_tracking_setup: Assertion `vrc == self->buffer' failed.
# enforce_dirty: Test terminated by assertion
# FAIL iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty
not ok 1 iommufd_dirty_tracking.domain_dirty128M_huge.enforce_dirty
# FAILED: 0 / 1 tests passed.
# Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0

Specifically the mmap() fails with ENOMEM.

When booting the VM with "hugepages=100" the test succeeds.
The same result happens when running all the subtests.

Could you give more specific reproduction steps?

On another note, the selftest should use the kselftest_harness' ASSERT_*()
macros instead of plain assert().


Thomas