On 23/10/2023 02:36, Nicolin Chen wrote: > On Sat, Oct 21, 2023 at 01:23:21PM -0300, Jason Gunthorpe wrote: >> On Fri, Oct 20, 2023 at 11:27:46PM +0100, Joao Martins wrote: >>> Changes since v4[8]: >>> * Rename HWPT_SET_DIRTY to HWPT_SET_DIRTY_TRACKING >>> * Rename IOMMU_CAP_DIRTY to IOMMU_CAP_DIRTY_TRACKING >>> * Rename HWPT_GET_DIRTY_IOVA to HWPT_GET_DIRTY_BITMAP >>> * Rename IOMMU_HWPT_ALLOC_ENFORCE_DIRTY to IOMMU_HWPT_ALLOC_DIRTY_TRACKING >>> including commit messages, code comments. Additionally change the >>> variable in drivers from enforce_dirty to dirty_tracking. >>> * Reflect all the mass renaming in commit messages/structs/docs. >>> * Fix the enums prefix to be IOMMU_HWPT like everyone else >>> * UAPI docs fixes/spelling and minor consistency issues/adjustments >>> * Change function exit style in __iommu_read_and_clear_dirty to return >>> right away instead of storing ret and returning at the end. >>> * Check 0 page_size and replace find-first-bit + left-shift with a >>> simple divide in iommufd_check_iova_range() >>> * Handle empty iommu domains when setting dirty tracking in intel-iommu; >>> Verified and amd-iommu was already the case. >>> * Remove unnecessary extra check for PGTT type >>> * Fix comment on function clearing the SLADE bit >>> * Fix wrong check that validates domain_alloc_user() >>> accepted flags in amd-iommu driver >>> * Skip IOTLB domain flush if no devices exist on the iommu domain, >>> while setting dirty tracking in amd-iommu driver. >>> * Collect Reviewed-by tags by Jason, Lu Baolu, Brett, Kevin, Alex >> >> I put this toward linux-next, let's see if we need a v6 next week with >> any remaining items. > > The selftest seems to be broken with this series: > > In file included from iommufd.c:10:0: > iommufd_utils.h:12:10: fatal error: linux/bitmap.h: No such file or directory > #include <linux/bitmap.h> > ^~~~~~~~~~~~~~~~ > In file included from iommufd.c:10:0: > iommufd_utils.h:12:10: fatal error: linux/bitops.h: No such file or directory > #include <linux/bitops.h> > ^~~~~~~~~~~~~~~~ > compilation terminated. > > Some of the tests are using kernel functions from these two headers > so I am not sure how to do any quick fix... Sorry for the oversight. It comes from the GET_DIRTY_BITMAP selftest ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP") because I use test_bit/set_bit/BITS_PER_BYTE in bitmap validation to make sure all the bits are set/unset as expected. I think some time ago I had an issue on my environment that the selftests didn't build in-tree with the kernel unless it has the kernel headers installed in the system/path (between before/after commit 0d7a91678aaa ("selftests: iommu: Use installed kernel headers search path")) so I was mistakenly using: CFLAGS="-I../../../../tools/include/ -I../../../../include/uapi/ -I../../../../include/" Just for the iommufd selftests, to replace what was prior to the commit plus `tools/include`: diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile index 7cb74d26f141..32c5fdfd0eef 100644 --- a/tools/testing/selftests/iommu/Makefile +++ b/tools/testing/selftests/iommu/Makefile @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only CFLAGS += -Wall -O2 -Wno-unused-function -CFLAGS += -I../../../../include/uapi/ -CFLAGS += -I../../../../include/ +CFLAGS += $(KHDR_INCLUDES) ... Which is what is masking your reported build problem for me. [The tests will build and run fine though once having the above] The usage of non UAPI kernel headers in selftests isn't unprecedented as I understand (if you grep for 'linux/bitmap.h') you will see a whole bunch. But maybe it isn't supposed to be used. Nonetheless the brokeness assumption was on my environment, and I have fixed up the environment now. Except for the above that you are reporting Perhaps the simpler change is to just import those two functions into the iommufd_util.h, since the selftest doesn't require any other non-UAPI headers. I have also had a couple more warnings/issues (in other patches), so I will need a v6 address to address everything. Joao