#985254 openafs-modules-dkms: Fails to build on -rt / non-HIGHMEM kernels

#985254#5
Date:
2021-03-15 06:21:01 UTC
From:
To:
I am pretty sure this is know issue (I was expiriencing it for probably 2
years or more), but I didn't found any open issues to track this problem.


...
checking whether kmap_atomic takes no km_type argument... no
...
...
Building in directory: MODLOAD-5.10.0-4-rt-amd64-SP
make[2]: Entering directory '/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP'
...
...
  CC [M]  /var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.o
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c: In function ‘afs_bypass_copy_page’:
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:311:31: error: ‘KM_USER0’ undeclared (first use in this function)
  311 |     address = kmap_atomic(pp, KM_USER0);
      |                               ^~~~~~~~
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:311:31: note: each undeclared identifier is reported only once for each function it appears in
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:311:15: error: too many arguments to function ‘kmap_atomic’
  311 |     address = kmap_atomic(pp, KM_USER0);
      |               ^~~~~~~~~~~
In file included from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/highmem.h:14,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/pagemap.h:11,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/blkdev.h:14,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/backing-dev.h:15,
                 from /var/lib/dkms/openafs/1.8.6/build/src/afs/sysincludes.h:126,
                 from /var/lib/dkms/openafs/1.8.6/build/src/afs/afs_bypasscache.h:67,
                 from /var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:64:
/usr/src/linux-headers-5.10.0-4-common-rt/include/linux/highmem-internal.h:179:21: note: declared here
  179 | static inline void *kmap_atomic(struct page *page)
      |                     ^~~~~~~~~~~
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:321:36: error: macro "kunmap_atomic" passed 2 arguments, but takes just 1
  321 |     kunmap_atomic(address, KM_USER0);
      |                                    ^
In file included from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/highmem.h:14,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/pagemap.h:11,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/blkdev.h:14,
                 from /usr/src/linux-headers-5.10.0-4-common-rt/include/linux/backing-dev.h:15,
                 from /var/lib/dkms/openafs/1.8.6/build/src/afs/sysincludes.h:126,
                 from /var/lib/dkms/openafs/1.8.6/build/src/afs/afs_bypasscache.h:67,
                 from /var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:64:
/usr/src/linux-headers-5.10.0-4-common-rt/include/linux/highmem-internal.h:210: note: macro "kunmap_atomic" defined here
  210 | #define kunmap_atomic(__addr)     \
      |
/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.c:321:5: error: ‘kunmap_atomic’ undeclared (first use in this function); did you mean ‘kmap_atomic’?
  321 |     kunmap_atomic(address, KM_USER0);
      |     ^~~~~~~~~~~~~
      |     kmap_atomic
make[5]: *** [/usr/src/linux-headers-5.10.0-4-common-rt/scripts/Makefile.build:284: /var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP/afs_bypasscache.o] Error 1
make[4]: *** [/usr/src/linux-headers-5.10.0-4-common-rt/Makefile:1813: /var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP] Error 2
make[3]: *** [/usr/src/linux-headers-5.10.0-4-common-rt/Makefile:185: __sub-make] Error 2
make[3]: Leaving directory '/usr/src/linux-headers-5.10.0-4-rt-amd64'
FAILURE: make exit code 2
make[2]: *** [Makefile.afs:279: openafs.ko] Error 1
make[2]: Leaving directory '/var/lib/dkms/openafs/1.8.6/build/src/libafs/MODLOAD-5.10.0-4-rt-amd64-SP'
make[1]: *** [Makefile:186: linux_compdirs] Error 2
make[1]: Leaving directory '/var/lib/dkms/openafs/1.8.6/build/src/libafs'
make: *** [Makefile:15: all] Error 2


The upstream code, as well the one shipped in Debian -dkms package, does
have provisions to detect this issue, and work, but it doesn't. Here is a
relevant part:


#if !defined(UKERNEL)
# if defined(KMAP_ATOMIC_TAKES_NO_KM_TYPE)
    address = kmap_atomic(pp);
# else
    address = kmap_atomic(pp, KM_USER0);
# endif
#else
    address = pp;
#endif
    memcpy(address + pageoff, (char *)(rxiov[iovno].iov_base) + iovoff, dolen);
#if !defined(UKERNEL)
# if defined(KMAP_ATOMIC_TAKES_NO_KM_TYPE)
    kunmap_atomic(address);
# else
    kunmap_atomic(address, KM_USER0);
# endif
#endif


The kmap_atomic signature depends if the kernel is compiled with HIGHMEM
support AFAIK, which is commonly disabled on RT kernels for various
reasons.

No sure, why the KMAP_ATOMIC_TAKES_NO_KM_TYPE is defined, as the
configure should detect this problem.

Upstream m4 macros for this are here:

http://git.openafs.org/?p=openafs.git;a=blob;f=src/cf/linux-test4.m4;h=f7699cec31ce23399294adfde2c72f6196c6a105;hb=HEAD#l714

The generated configure distributed with openafs-modules-dkms does look
to have code related to this too, so I am not sure why it doesn't
compile, when it should.


It is easy to reproduce, just install the -rt kernel packages (and
headers), no need to boot it.

Regards,
Witold

#985254#10
Date:
2021-03-15 06:27:41 UTC
From:
To:
Actually after digging more, it is not due to HIGHMEM. In fact the
kmap_atomic takes single argument since about kernel 3.13 on all
configurations.


The issue actually is somewhere else.

In config.log I found this:

The module compiles, however it doesn't link into .ko file:

FATAL: modpost: GPL-incompatible module conftest.ko uses GPL-only symbol 'migrate_disable'

And that causes configure to think that the function is not one-argument.

#985254#15
Date:
2021-03-19 01:56:21 UTC
From:
To:
Thanks for taking the time to make the report and follow-up with the
additional information.

However, IIRC it is "well known" (though I did not find good documentation
in a very quick search) that the -rt kernel has many interfaces that are
GPL-only that are not GPL-only in a standard kernel, and as such incurs
license complaints against the openafs kernel module.  I don't expect to be
able to do anything about this (other, perhaps, that documenting it
better), unfortunately.