linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] asm-generic: fix variable 'p4d' set but not used
@ 2019-08-02 19:41 Qian Cai
  2019-08-06 10:45 ` Kirill A. Shutemov
  2019-08-06 14:39 ` Jason Gunthorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Qian Cai @ 2019-08-02 19:41 UTC (permalink / raw)
  To: akpm
  Cc: arnd, kirill.shutemov, mhocko, linux-mm, linux-arch,
	linux-kernel, Qian Cai

GCC throws a warning on an arm64 system since the commit 9849a5697d3d
("arch, mm: convert all architectures to use 5level-fixup.h"),

mm/kasan/init.c: In function 'kasan_free_p4d':
mm/kasan/init.c:344:9: warning: variable 'p4d' set but not used
[-Wunused-but-set-variable]
  p4d_t *p4d;
         ^~~

because p4d_none() in "5level-fixup.h" is compiled away while it is a
static inline function in "pgtable-nopud.h". However, if converted
p4d_none() to a static inline there, powerpc would be unhappy as it
reads those in assembler language in
"arch/powerpc/include/asm/book3s/64/pgtable.h",

./include/asm-generic/5level-fixup.h: Assembler messages:
./include/asm-generic/5level-fixup.h:20: Error: unrecognized opcode:
`static'
./include/asm-generic/5level-fixup.h:21: Error: junk at end of line,
first unrecognized character is `{'
./include/asm-generic/5level-fixup.h:22: Error: unrecognized opcode:
`return'
./include/asm-generic/5level-fixup.h:23: Error: junk at end of line,
first unrecognized character is `}'
./include/asm-generic/5level-fixup.h:25: Error: unrecognized opcode:
`static'
./include/asm-generic/5level-fixup.h:26: Error: junk at end of line,
first unrecognized character is `{'
./include/asm-generic/5level-fixup.h:27: Error: unrecognized opcode:
`return'
./include/asm-generic/5level-fixup.h:28: Error: junk at end of line,
first unrecognized character is `}'
./include/asm-generic/5level-fixup.h:30: Error: unrecognized opcode:
`static'
./include/asm-generic/5level-fixup.h:31: Error: junk at end of line,
first unrecognized character is `{'
./include/asm-generic/5level-fixup.h:32: Error: unrecognized opcode:
`return'
./include/asm-generic/5level-fixup.h:33: Error: junk at end of line,
first unrecognized character is `}'
make[2]: *** [scripts/Makefile.build:375:
arch/powerpc/kvm/book3s_hv_rmhandlers.o] Error 1

Fix it by reference the variable in the macro instead.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 include/asm-generic/5level-fixup.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h
index bb6cb347018c..2c3e14c924b6 100644
--- a/include/asm-generic/5level-fixup.h
+++ b/include/asm-generic/5level-fixup.h
@@ -19,7 +19,7 @@
 
 #define p4d_alloc(mm, pgd, address)	(pgd)
 #define p4d_offset(pgd, start)		(pgd)
-#define p4d_none(p4d)			0
+#define p4d_none(p4d)			((void)p4d, 0)
 #define p4d_bad(p4d)			0
 #define p4d_present(p4d)		1
 #define p4d_ERROR(p4d)			do { } while (0)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] asm-generic: fix variable 'p4d' set but not used
  2019-08-02 19:41 [PATCH] asm-generic: fix variable 'p4d' set but not used Qian Cai
@ 2019-08-06 10:45 ` Kirill A. Shutemov
  2019-08-06 14:39 ` Jason Gunthorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2019-08-06 10:45 UTC (permalink / raw)
  To: Qian Cai
  Cc: akpm, arnd, kirill.shutemov, mhocko, linux-mm, linux-arch, linux-kernel

On Fri, Aug 02, 2019 at 03:41:22PM -0400, Qian Cai wrote:
> GCC throws a warning on an arm64 system since the commit 9849a5697d3d
> ("arch, mm: convert all architectures to use 5level-fixup.h"),
> 
> mm/kasan/init.c: In function 'kasan_free_p4d':
> mm/kasan/init.c:344:9: warning: variable 'p4d' set but not used
> [-Wunused-but-set-variable]
>   p4d_t *p4d;
>          ^~~
> 
> because p4d_none() in "5level-fixup.h" is compiled away while it is a
> static inline function in "pgtable-nopud.h". However, if converted
> p4d_none() to a static inline there, powerpc would be unhappy as it
> reads those in assembler language in
> "arch/powerpc/include/asm/book3s/64/pgtable.h",
> 
> ./include/asm-generic/5level-fixup.h: Assembler messages:
> ./include/asm-generic/5level-fixup.h:20: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:21: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:22: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:23: Error: junk at end of line,
> first unrecognized character is `}'
> ./include/asm-generic/5level-fixup.h:25: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:26: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:27: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:28: Error: junk at end of line,
> first unrecognized character is `}'
> ./include/asm-generic/5level-fixup.h:30: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:31: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:32: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:33: Error: junk at end of line,
> first unrecognized character is `}'
> make[2]: *** [scripts/Makefile.build:375:
> arch/powerpc/kvm/book3s_hv_rmhandlers.o] Error 1
> 
> Fix it by reference the variable in the macro instead.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] asm-generic: fix variable 'p4d' set but not used
  2019-08-02 19:41 [PATCH] asm-generic: fix variable 'p4d' set but not used Qian Cai
  2019-08-06 10:45 ` Kirill A. Shutemov
@ 2019-08-06 14:39 ` Jason Gunthorpe
  2019-08-06 20:51   ` Andrew Morton
  1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2019-08-06 14:39 UTC (permalink / raw)
  To: Qian Cai
  Cc: akpm, arnd, kirill.shutemov, mhocko, linux-mm, linux-arch, linux-kernel

On Fri, Aug 02, 2019 at 03:41:22PM -0400, Qian Cai wrote:
> GCC throws a warning on an arm64 system since the commit 9849a5697d3d
> ("arch, mm: convert all architectures to use 5level-fixup.h"),
> 
> mm/kasan/init.c: In function 'kasan_free_p4d':
> mm/kasan/init.c:344:9: warning: variable 'p4d' set but not used
> [-Wunused-but-set-variable]
>   p4d_t *p4d;
>          ^~~
> 
> because p4d_none() in "5level-fixup.h" is compiled away while it is a
> static inline function in "pgtable-nopud.h". However, if converted
> p4d_none() to a static inline there, powerpc would be unhappy as it
> reads those in assembler language in
> "arch/powerpc/include/asm/book3s/64/pgtable.h",
> 
> ./include/asm-generic/5level-fixup.h: Assembler messages:
> ./include/asm-generic/5level-fixup.h:20: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:21: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:22: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:23: Error: junk at end of line,
> first unrecognized character is `}'
> ./include/asm-generic/5level-fixup.h:25: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:26: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:27: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:28: Error: junk at end of line,
> first unrecognized character is `}'
> ./include/asm-generic/5level-fixup.h:30: Error: unrecognized opcode:
> `static'
> ./include/asm-generic/5level-fixup.h:31: Error: junk at end of line,
> first unrecognized character is `{'
> ./include/asm-generic/5level-fixup.h:32: Error: unrecognized opcode:
> `return'
> ./include/asm-generic/5level-fixup.h:33: Error: junk at end of line,
> first unrecognized character is `}'
> make[2]: *** [scripts/Makefile.build:375:
> arch/powerpc/kvm/book3s_hv_rmhandlers.o] Error 1
> 
> Fix it by reference the variable in the macro instead.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>
>  include/asm-generic/5level-fixup.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h
> index bb6cb347018c..2c3e14c924b6 100644
> +++ b/include/asm-generic/5level-fixup.h
> @@ -19,7 +19,7 @@
>  
>  #define p4d_alloc(mm, pgd, address)	(pgd)
>  #define p4d_offset(pgd, start)		(pgd)
> -#define p4d_none(p4d)			0
> +#define p4d_none(p4d)			((void)p4d, 0)

Yuk, how about a static inline instead?

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] asm-generic: fix variable 'p4d' set but not used
  2019-08-06 14:39 ` Jason Gunthorpe
@ 2019-08-06 20:51   ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2019-08-06 20:51 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Qian Cai, arnd, kirill.shutemov, mhocko, linux-mm, linux-arch,
	linux-kernel

On Tue, 6 Aug 2019 11:39:04 -0300 Jason Gunthorpe <jgg@ziepe.ca> wrote:

> On Fri, Aug 02, 2019 at 03:41:22PM -0400, Qian Cai wrote:
> > GCC throws a warning on an arm64 system since the commit 9849a5697d3d
> > ("arch, mm: convert all architectures to use 5level-fixup.h"),
> > 
> > mm/kasan/init.c: In function 'kasan_free_p4d':
> > mm/kasan/init.c:344:9: warning: variable 'p4d' set but not used
> > [-Wunused-but-set-variable]
> >   p4d_t *p4d;
> >          ^~~
> > 
> > because p4d_none() in "5level-fixup.h" is compiled away while it is a
> > static inline function in "pgtable-nopud.h". However, if converted
> > p4d_none() to a static inline there, powerpc would be unhappy as it
> > reads those in assembler language in
> > "arch/powerpc/include/asm/book3s/64/pgtable.h",
> > 
> > ./include/asm-generic/5level-fixup.h: Assembler messages:
> > ./include/asm-generic/5level-fixup.h:20: Error: unrecognized opcode:
> > `static'
> > ./include/asm-generic/5level-fixup.h:21: Error: junk at end of line,
> > first unrecognized character is `{'
> > ./include/asm-generic/5level-fixup.h:22: Error: unrecognized opcode:
> > `return'
> > ./include/asm-generic/5level-fixup.h:23: Error: junk at end of line,
> > first unrecognized character is `}'
> > ./include/asm-generic/5level-fixup.h:25: Error: unrecognized opcode:
> > `static'
> > ./include/asm-generic/5level-fixup.h:26: Error: junk at end of line,
> > first unrecognized character is `{'
> > ./include/asm-generic/5level-fixup.h:27: Error: unrecognized opcode:
> > `return'
> > ./include/asm-generic/5level-fixup.h:28: Error: junk at end of line,
> > first unrecognized character is `}'
> > ./include/asm-generic/5level-fixup.h:30: Error: unrecognized opcode:
> > `static'
> > ./include/asm-generic/5level-fixup.h:31: Error: junk at end of line,
> > first unrecognized character is `{'
> > ./include/asm-generic/5level-fixup.h:32: Error: unrecognized opcode:
> > `return'
> > ./include/asm-generic/5level-fixup.h:33: Error: junk at end of line,
> > first unrecognized character is `}'
> > make[2]: *** [scripts/Makefile.build:375:
> > arch/powerpc/kvm/book3s_hv_rmhandlers.o] Error 1
> > 
> > Fix it by reference the variable in the macro instead.
> > 
> > Signed-off-by: Qian Cai <cai@lca.pw>
> >  include/asm-generic/5level-fixup.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h
> > index bb6cb347018c..2c3e14c924b6 100644
> > +++ b/include/asm-generic/5level-fixup.h
> > @@ -19,7 +19,7 @@
> >  
> >  #define p4d_alloc(mm, pgd, address)	(pgd)
> >  #define p4d_offset(pgd, start)		(pgd)
> > -#define p4d_none(p4d)			0
> > +#define p4d_none(p4d)			((void)p4d, 0)
> 
> Yuk, how about a static inline instead?

Yes.  With the appropriate `#ifndef __ASSEMBLY__' to avoid powerpc
build errors?


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-06 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02 19:41 [PATCH] asm-generic: fix variable 'p4d' set but not used Qian Cai
2019-08-06 10:45 ` Kirill A. Shutemov
2019-08-06 14:39 ` Jason Gunthorpe
2019-08-06 20:51   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).