Re: [PATCH 02/17] mm: stub out all of swapops.h for !CONFIG_MMU

From: Vladimir Murzin
Date: Tue Jun 11 2019 - 10:41:26 EST


On 6/11/19 3:18 PM, Christoph Hellwig wrote:
> On Tue, Jun 11, 2019 at 11:15:44AM +0100, Vladimir Murzin wrote:
>> On 6/10/19 11:16 PM, Christoph Hellwig wrote:
>>> The whole header file deals with swap entries and PTEs, none of which
>>> can exist for nommu builds.
>>
>> Although I agree with the patch, I'm wondering how you get into it?
>
> Without that the RISC-V nommu blows up like this:
>
>
> In file included from mm/vmscan.c:58:
> ./include/linux/swapops.h: In function âpte_to_swp_entryâ:
> ./include/linux/swapops.h:71:15: error: implicit declaration of function â__pte_to_swp_entryâ; did you mean âpte_to_swp_entryâ? [-Werror=implicit-function-declaration]
> arch_entry = __pte_to_swp_entry(pte);
> ^~~~~~~~~~~~~~~~~~
> pte_to_swp_entry
> ./include/linux/swapops.h:71:13: error: incompatible types when assigning to type âswp_entry_tâ {aka âstruct <anonymous>â} from type âintâ
> arch_entry = __pte_to_swp_entry(pte);
> ^
> ./include/linux/swapops.h:72:19: error: implicit declaration of function â__swp_typeâ; did you mean âswp_typeâ? [-Werror=implicit-function-declaration]
> return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
> ^~~~~~~~~~
> swp_type
> ./include/linux/swapops.h:72:43: error: implicit declaration of function â__swp_offsetâ; did you mean âswp_offsetâ? [-Werror=implicit-function-declaration]
> return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
> ^~~~~~~~~~~~
> swp_offset
> ./include/linux/swapops.h: In function âswp_entry_to_pteâ:
> ./include/linux/swapops.h:83:15: error: implicit declaration of function â__swp_entryâ; did you mean âswp_entryâ? [-Werror=implicit-function-declaration]
> arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
> ^~~~~~~~~~~
> swp_entry
> ./include/linux/swapops.h:83:13: error: incompatible types when assigning to type âswp_entry_tâ {aka âstruct <anonymous>â} from type âintâ
> arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
> ^
> ./include/linux/swapops.h:84:9: error: implicit declaration of function â__swp_entry_to_pteâ; did you mean âswp_entry_to_pteâ? [-Werror=implicit-function-declaration]
> return __swp_entry_to_pte(arch_entry);
> ^~~~~~~~~~~~~~~~~~
> swp_entry_to_pte
> ./include/linux/swapops.h:84:9: error: incompatible types when returning type âintâ but âpte_tâ {aka âstruct <anonymous>â} was expected
> return __swp_entry_to_pte(arch_entry);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: some warnings being treated as errors
> make[1]: *** [scripts/Makefile.build:278: mm/vmscan.o] Error 1
> make: *** [Makefile:1071: mm] Error 2
> make: *** Waiting for unfinished jobs....
>

It looks like NOMMU ports tend to define those. For ARM they are:

#define __swp_type(x) (0)
#define __swp_offset(x) (0)
#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })

Anyway, I have no strong opinion on which is better :)

Cheers
Vladimir