diff mbox series

arm64: fix pte_unmap() -Wunused-but-set-variable

Message ID 20190427012842.93737-1-cai@lca.pw (mailing list archive)
State New, archived
Headers show
Series arm64: fix pte_unmap() -Wunused-but-set-variable | expand

Commit Message

Qian Cai April 27, 2019, 1:28 a.m. UTC
Many compilation warnings due to pte_unmap() compiles away. Fixed it by
making it an static inline function.

mm/gup.c: In function 'gup_pte_range':
mm/gup.c:1727:16: warning: variable 'ptem' set but not used
[-Wunused-but-set-variable]
mm/gup.c: At top level:
mm/memory.c: In function 'copy_pte_range':
mm/memory.c:821:24: warning: variable 'orig_dst_pte' set but not used
[-Wunused-but-set-variable]
mm/memory.c:821:9: warning: variable 'orig_src_pte' set but not used
[-Wunused-but-set-variable]
mm/swap_state.c: In function 'swap_ra_info':
mm/swap_state.c:641:15: warning: variable 'orig_pte' set but not used
[-Wunused-but-set-variable]
mm/madvise.c: In function 'madvise_free_pte_range':
mm/madvise.c:318:9: warning: variable 'orig_pte' set but not used
[-Wunused-but-set-variable]

Also, remove pte_unmap_nested() as nobody uses it anymore since the
commit ece0e2b6406a ("mm: remove pte_*map_nested()").

Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/arm64/include/asm/pgtable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Will Deacon April 29, 2019, 4:49 p.m. UTC | #1
On Fri, Apr 26, 2019 at 09:28:42PM -0400, Qian Cai wrote:
> Many compilation warnings due to pte_unmap() compiles away. Fixed it by
> making it an static inline function.
> 
> mm/gup.c: In function 'gup_pte_range':
> mm/gup.c:1727:16: warning: variable 'ptem' set but not used
> [-Wunused-but-set-variable]
> mm/gup.c: At top level:
> mm/memory.c: In function 'copy_pte_range':
> mm/memory.c:821:24: warning: variable 'orig_dst_pte' set but not used
> [-Wunused-but-set-variable]
> mm/memory.c:821:9: warning: variable 'orig_src_pte' set but not used
> [-Wunused-but-set-variable]
> mm/swap_state.c: In function 'swap_ra_info':
> mm/swap_state.c:641:15: warning: variable 'orig_pte' set but not used
> [-Wunused-but-set-variable]
> mm/madvise.c: In function 'madvise_free_pte_range':
> mm/madvise.c:318:9: warning: variable 'orig_pte' set but not used
> [-Wunused-but-set-variable]
> 
> Also, remove pte_unmap_nested() as nobody uses it anymore since the
> commit ece0e2b6406a ("mm: remove pte_*map_nested()").

Can you post that as a separate patch which also removes
pte_offset_map_nested(), please?

> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/arm64/include/asm/pgtable.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index de70c1eabf33..7543e345e078 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -478,6 +478,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
>  	return __pmd_to_phys(pmd);
>  }
>  
> +static inline void pte_unmap(pte_t *pte) { }

Hmm, is this guaranteed to stop the compiler from warning? Assuming the
pte_unmap() call is inlined, I'd expect it to keep complaining. What
compiler are you using?

Also, there are a bunch of other architectures that I would expect to have
this same issue because they defined pte_unmap() exactly the same way.

Will
Qian Cai April 29, 2019, 5:18 p.m. UTC | #2
On Mon, 2019-04-29 at 17:49 +0100, Will Deacon wrote:
> >  arch/arm64/include/asm/pgtable.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm64/include/asm/pgtable.h
> > b/arch/arm64/include/asm/pgtable.h
> > index de70c1eabf33..7543e345e078 100644
> > --- a/arch/arm64/include/asm/pgtable.h
> > +++ b/arch/arm64/include/asm/pgtable.h
> > @@ -478,6 +478,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
> >  	return __pmd_to_phys(pmd);
> >  }
> >  
> > +static inline void pte_unmap(pte_t *pte) { }
> 
> Hmm, is this guaranteed to stop the compiler from warning? Assuming the
> pte_unmap() call is inlined, I'd expect it to keep complaining. What
> compiler are you using?

Yes, it is guaranteed. Tested on both gcc and clang.

> 
> Also, there are a bunch of other architectures that I would expect to have
> this same issue because they defined pte_unmap() exactly the same way.

This has already fixed in powerpc that went in.

https://lore.kernel.org/lkml/20190307144031.52494-1-cai@lca.pw/

I am not sure if I care about any other arches nor I have real hardware to test
further.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index de70c1eabf33..7543e345e078 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -478,6 +478,8 @@  static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
 	return __pmd_to_phys(pmd);
 }
 
+static inline void pte_unmap(pte_t *pte) { }
+
 /* Find an entry in the third-level page table. */
 #define pte_index(addr)		(((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 
@@ -486,8 +488,6 @@  static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
 
 #define pte_offset_map(dir,addr)	pte_offset_kernel((dir), (addr))
 #define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir), (addr))
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
 
 #define pte_set_fixmap(addr)		((pte_t *)set_fixmap_offset(FIX_PTE, addr))
 #define pte_set_fixmap_offset(pmd, addr)	pte_set_fixmap(pte_offset_phys(pmd, addr))