Re: [PATCH] Fix the problem that kunit cannot run

From: Andrew Morton

Date: Mon Oct 27 2025 - 19:35:44 EST


On Mon, 27 Oct 2025 17:12:30 +0800 bajing <bajing@xxxxxxxxxxxxxxxxxxxx> wrote:

> When running ./tools/testing/kunit/kunit.py run,the error for mm/swap.h
> is as follows:
> ERROR:root:In file included from ../mm/shmem.c:43:
> ../mm/swap.h: In function ‘non_swapcache_batch’:
> ../mm/swap.h:66:19: error: implicit declaration of function ‘swp_offset’;
> did you mean ‘pud_offset’? [-Werror=implicit-function-declaration]
> 66 | pgoff_t offset = swp_offset(entry);
> | ^~~~~~~~~~
> | pud_offset
> In file included from ../mm/shmem.c:68:
> ../include/linux/swapops.h: At top level:
> ../include/linux/swapops.h:107:23: error: conflicting types for ‘swp_offset’
> 107 | static inline pgoff_t swp_offset(swp_entry_t entry)
> | ^~~~~~~~~~
> In file included from ../mm/shmem.c:43:
> ../mm/swap.h:66:19: note: previous implicit declaration of ‘swp_offset’ was here
> 66 | pgoff_t offset = swp_offset(entry);
> | ^~~~~~~~~~
> cc1: some warnings being treated as errors
> make[4]: *** [../scripts/Makefile.build:243: mm/shmem.o] Error 1
> make[3]: *** [../scripts/Makefile.build:480: mm] Error 2
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [/home/openeuler/kernel/Makefile:1924: .] Error 2
> make[1]: *** [/home/openeuler/kernel/Makefile:234: __sub-make] Error 2
> make: *** [Makefile:234: __sub-make] Error 2
>
> ...
>
> --- a/mm/swap.h
> +++ b/mm/swap.h
> @@ -4,6 +4,7 @@
>
> #ifdef CONFIG_SWAP
> #include <linux/blk_types.h> /* for bio_end_io_t */
> +#include <linux/swapops.h>
>
> /* linux/mm/page_io.c */
> int sio_pool_init(void);

Thanks, but I suspect you're using an older kernel. 6.18-rc3 doesn't
look like the above and it already has


: #ifdef CONFIG_SWAP
: #include <linux/swapops.h> /* for swp_offset */
: #include <linux/blk_types.h> /* for bio_end_io_t */
:
: static inline unsigned int swp_cluster_offset(swp_entry_t entry)