diff mbox series

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

Message ID 20190610221621.10938-3-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/17] mm: provide a print_vma_addr stub for !CONFIG_MMU | expand

Commit Message

Christoph Hellwig June 10, 2019, 10:16 p.m. UTC
The whole header file deals with swap entries and PTEs, none of which
can exist for nommu builds.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/swapops.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Vladimir Murzin June 11, 2019, 10:15 a.m. UTC | #1
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?

Cheers
Vladimir

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/swapops.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/swapops.h b/include/linux/swapops.h
> index 4d961668e5fc..b02922556846 100644
> --- a/include/linux/swapops.h
> +++ b/include/linux/swapops.h
> @@ -6,6 +6,8 @@
>  #include <linux/bug.h>
>  #include <linux/mm_types.h>
>  
> +#ifdef CONFIG_MMU
> +
>  /*
>   * swapcache pages are stored in the swapper_space radix tree.  We want to
>   * get good packing density in that tree, so the index should be dense in
> @@ -50,13 +52,11 @@ static inline pgoff_t swp_offset(swp_entry_t entry)
>  	return entry.val & SWP_OFFSET_MASK;
>  }
>  
> -#ifdef CONFIG_MMU
>  /* check whether a pte points to a swap entry */
>  static inline int is_swap_pte(pte_t pte)
>  {
>  	return !pte_none(pte) && !pte_present(pte);
>  }
> -#endif
>  
>  /*
>   * Convert the arch-dependent pte representation of a swp_entry_t into an
> @@ -375,4 +375,5 @@ static inline int non_swap_entry(swp_entry_t entry)
>  }
>  #endif
>  
> +#endif /* CONFIG_MMU */
>  #endif /* _LINUX_SWAPOPS_H */
>
Christoph Hellwig June 11, 2019, 2:18 p.m. UTC | #2
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....
Vladimir Murzin June 11, 2019, 2:36 p.m. UTC | #3
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
Christoph Hellwig June 14, 2019, 9:48 a.m. UTC | #4
On Tue, Jun 11, 2019 at 03:36:53PM +0100, Vladimir Murzin wrote:
> 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 :)

It just seems a lot easier to stub out swapops.h rather than providing
stubs in each arch so that inlines which we are never going to use can
build.  I can look into dropping this from the other nommu ports for
the next merge window, though.
diff mbox series

Patch

diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 4d961668e5fc..b02922556846 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -6,6 +6,8 @@ 
 #include <linux/bug.h>
 #include <linux/mm_types.h>
 
+#ifdef CONFIG_MMU
+
 /*
  * swapcache pages are stored in the swapper_space radix tree.  We want to
  * get good packing density in that tree, so the index should be dense in
@@ -50,13 +52,11 @@  static inline pgoff_t swp_offset(swp_entry_t entry)
 	return entry.val & SWP_OFFSET_MASK;
 }
 
-#ifdef CONFIG_MMU
 /* check whether a pte points to a swap entry */
 static inline int is_swap_pte(pte_t pte)
 {
 	return !pte_none(pte) && !pte_present(pte);
 }
-#endif
 
 /*
  * Convert the arch-dependent pte representation of a swp_entry_t into an
@@ -375,4 +375,5 @@  static inline int non_swap_entry(swp_entry_t entry)
 }
 #endif
 
+#endif /* CONFIG_MMU */
 #endif /* _LINUX_SWAPOPS_H */