Re: [PATCH v5 00/18] IOMMUFD Dirty Tracking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 23, 2023 at 12:49:55PM +0100, Joao Martins wrote:
> Here's an example down that avoids the kernel header dependency; imported from
> the arch-independent non-atomic bitops
> (include/asm-generic/bitops/generic-non-atomic.h)
> 
> diff --git a/tools/testing/selftests/iommu/iommufd.c
> b/tools/testing/selftests/iommu/iommufd.c
> index 96837369a0aa..026ff9f5c1f3 100644
> --- a/tools/testing/selftests/iommu/iommufd.c
> +++ b/tools/testing/selftests/iommu/iommufd.c
> @@ -12,7 +12,6 @@
>  static unsigned long HUGEPAGE_SIZE;
> 
>  #define MOCK_PAGE_SIZE (PAGE_SIZE / 2)
> -#define BITS_PER_BYTE 8
> 
>  static unsigned long get_huge_page_size(void)
>  {
> diff --git a/tools/testing/selftests/iommu/iommufd_utils.h
> b/tools/testing/selftests/iommu/iommufd_utils.h
> index 390563ff7935..6bbcab7fd6ab 100644
> --- a/tools/testing/selftests/iommu/iommufd_utils.h
> +++ b/tools/testing/selftests/iommu/iommufd_utils.h
> @@ -9,8 +9,6 @@
>  #include <sys/ioctl.h>
>  #include <stdint.h>
>  #include <assert.h>
> -#include <linux/bitmap.h>
> -#include <linux/bitops.h>
> 
>  #include "../kselftest_harness.h"
>  #include "../../../../drivers/iommu/iommufd/iommufd_test.h"
> @@ -18,6 +16,24 @@
>  /* Hack to make assertions more readable */
>  #define _IOMMU_TEST_CMD(x) IOMMU_TEST_CMD
> 
> +/* Imported from include/asm-generic/bitops/generic-non-atomic.h */
> +#define BITS_PER_BYTE 8
> +#define BITS_PER_LONG __BITS_PER_LONG
> +#define BIT_MASK(nr) (1UL << ((nr) % __BITS_PER_LONG))
> +#define BIT_WORD(nr) ((nr) / __BITS_PER_LONG)
> +
> +static inline void set_bit(unsigned int nr, unsigned long *addr)

The whole piece could fix the break, except this one. We'd need
__set_bit instead of set_bit.

Thanks
Nic

> +{
> +       unsigned long mask = BIT_MASK(nr);
> +       unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
> +
> +       *p  |= mask;
> +}
> +
> +static inline bool test_bit(unsigned int nr, unsigned long *addr)
> +{
> +       return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
> +}
> +
>  static void *buffer;
>  static unsigned long BUFFER_SIZE;
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux