xtensa: remove redundant flush_dcache_page and ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE macros
PATCH v2 1/1 xtensa: remove redundant flush_dcache_page and ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE macros
From: Barry Song <[email protected]>
xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif
So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.
In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~ crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]
174 | struct page *dst_page = sg_page(req->dst);
|The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.
---
-v2: include asm-generic/cacheflush.h and remove lots of redundant macros
arch/xtensa/include/asm/cacheflush.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
arch/xtensa/include/asm/cacheflush.h +8 -16
@@ -100,6 +100,10 @@ void flush_cache_range(struct vm_area_struct*, ulong, ulong);void flush_icache_range (unsigned long start,unsigned long end);void flush_cache_page (struct vm_area_struct *,unsigned long ,unsigned long ); +#define flush_cache_all flush_cache_all +#define flush_cache_range flush_cache_range +#define flush_icache_range flush_icache_range +#define flush_cache_page flush_cache_page#else #define flush_cache_all local_flush_cache_all#define flush_cache_range local_flush_cache_range
@@ -136,20 +140,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,#else -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) - -#define flush_cache_vmap (start,end) do { } while (0) -#define flush_cache_vmap_early (start,end) do { } while (0) -#define flush_cache_vunmap (start,end) do { } while (0) - -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) -#define flush_icache_range local_flush_icache_range -#define flush_cache_page (vma, addr, pfn) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0)#endif
@@ -162,15 +153,14 @@ void local_flush_cache_page(struct vm_area_struct *vma,__invalidate_icache_range (start,(end) - (start)); \ } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#if defined(CONFIG_MMU ) && (DCACHE_WAY_SIZE >PAGE_SIZE )extern void copy_to_user_page (struct vm_area_struct *,struct page *,unsigned long ,void *,const void *,unsigned long );extern void copy_from_user_page (struct vm_area_struct *,struct page *,unsigned long ,void *,const void *,unsigned long ); +#define copy_to_user_page copy_to_user_page +#define copy_from_user_page copy_from_user_page#else
@@ -186,4 +176,6 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,#endif +#include <asm-generic/cacheflush.h> +#endif /* _XTENSA_CACHEFLUSH_H */
Signature · 1 line
2.34.1
Quoted 35 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.
Quoted 7 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>
Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:
(quoted diff) +0 -0
b/arch/xtensa/include/asm/cacheflush.h
index 38bcecb0e457..fdc692cf2b78 100644
arch/xtensa/include/asm/cacheflush.h +1 -1
@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,#define flush_cache_vunmap (start,end) do { } while (0)#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) +#define flush_dcache_page (page) do {
(void)(page); } while (0)
#define flush_icache_range local_flush_icache_range
#define flush_cache_page(vma, addr, pfn) do { } while (0)
Quoted 71 lines
Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>---
-v2: includeasm-generic/cacheflush.hand remove lots of redundant macrosarch/xtensa/include/asm/cacheflush.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)arch/xtensa/include/asm/cacheflush.h +8
-17@@ -100,6 +100,10 @@ void flush_cache_range(struct vm_area_struct*, ulong, ulong);void flush_icache_range (unsigned long start,unsigned long end);void flush_cache_page (struct vm_area_struct *,unsigned long ,unsigned long ); +#define flush_cache_all flush_cache_all +#define flush_cache_range flush_cache_range +#define flush_icache_range flush_icache_range +#define flush_cache_page flush_cache_page#else #define flush_cache_all local_flush_cache_all#define flush_cache_range local_flush_cache_range@@ -136,20 +140,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,#else -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) - -#define flush_cache_vmap (start,end) do { } while (0) -#define flush_cache_vmap_early (start,end) do { } while (0) -#define flush_cache_vunmap (start,end) do { } while (0) - -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) -#define flush_icache_range local_flush_icache_range -#define flush_cache_page (vma, addr, pfn) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0)#endif @@ -162,15 +153,14 @@ void local_flush_cache_page(struct vm_area_struct *vma,__invalidate_icache_range (start,(end) - (start)); \ } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#if defined(CONFIG_MMU ) && (DCACHE_WAY_SIZE >PAGE_SIZE )extern void copy_to_user_page (struct vm_area_struct *,struct page *,unsigned long ,void *,const void *,unsigned long );extern void copy_from_user_page (struct vm_area_struct *,struct page *,unsigned long ,void *,const void *,unsigned long ); +#define copy_to_user_page copy_to_user_page +#define copy_from_user_page copy_from_user_page#else @@ -186,4 +176,6 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,#endif +#include <asm-generic/cacheflush.h> +#endif /* _XTENSA_CACHEFLUSH_H */ --
Quoted 2 lines
2.34.1
Thanks
Barry
Max Filippov
maintainerQuoted 24 lines · Barry Song
Quoted 23 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
I wonder why this warning is considered useful in the first place? If I'm missing something and it's indeed useful, should there be a rule in the Documentation/process/coding-style.rst saying that function-like macros should evaluate all their arguments?
Quoted 22 lines
Quoted 10 lines
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:arch/xtensa/include/asm/cacheflush.h +0
-0
arch/xtensa/include/asm/cacheflush.h void local_flush_cache_page(struct vm_area_struct *vma, · line 149
Quoted 6 lines
arch/xtensa/include/asm/cacheflush.h +1
-1@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,#define flush_cache_vunmap (start,end) do { } while (0)#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) +#define flush_dcache_page (page) do { (void )(page); }while (0 )
This looks like a good fix, IMO better than adding __maybe_unused to the variables reported in the warnings.
Signature · 2 lines
Thanks. -- Max
Quoted 27 lines · Max Filippov
Quoted 25 lines · Barry Song
Quoted 24 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
I wonder why this warning is considered useful in the first place?
Guenter reported it as an error not a warning
"
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page'"
is it because xtensa's toolchain is different with others?
Quoted 28 lines
If I'm missing something and it's indeed useful, should there be a rule in the
Documentation/process/coding-style.rstsaying that function-like macros should evaluate all their arguments?Quoted 24 lines
Quoted 10 lines
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:arch/xtensa/include/asm/cacheflush.h +0
-0@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,#define flush_cache_vunmap (start,end) do { } while (0)
Quoted 7 lines
arch/xtensa/include/asm/cacheflush.h void local_flush_cache_page(struct vm_area_struct *vma,
Quoted 4 lines
arch/xtensa/include/asm/cacheflush.h +1
-1#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) +#define flush_dcache_page (page) do { (void )(page); }while (0 )This looks like a good fix, IMO better than adding
__maybe_unusedto the variables reported in the warnings.
i don't like adding __maybe_unused either as it is not the fault of the drivers calling flush_dcache_page().
Quoted 4 lines
--
Thanks.
-- Max
Quoted 37 lines · Barry Song
Quoted 27 lines · Max Filippov
Quoted 25 lines · Barry Song
Quoted 24 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 #endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
I wonder why this warning is considered useful in the first place?
Quoted 9 lines
Guenter reported it as an error not a warning
"Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page'"is it because xtensa's toolchain is different with others?
It is because -Werror is now default in allmodconfig builds. Other test build systems may manually override that.
Guenter
Quoted 44 lines · Barry Song
Quoted 35 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 #endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Quoted 7 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>
Quoted 3 lines
Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
I sent a Tested-by: tag to your patch. As far as my testing goes, it works fine, and I added your patch to my "testing" branch (which tries to be buildable and testable for all architectures).
Quoted 2 lines
fix, a minimal fix might be:
FWIW, I think a minimal fix would have been to mark the variable as __maybe_unused, but as others have pointed out it would be nice if there would be a guidance about optional API functions like this one that specifies if it may be implemented as macro and, if so, how it has to handle unused variables.
Thanks,
Guenter
Quoted 46 lines · Guenter Roeck
Quoted 44 lines · Barry Song
Quoted 42 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 #endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>
Quoted 7 lines
Quoted 3 lines
Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)I sent a Tested-by: tag to your patch. As far as my testing goes, it works fine, and I added your patch to my "testing" branch (which tries to be buildable and testable for all architectures).
Thank you very much, Guenter. It would be nice if xtensa can leverage the common cacheflush.h just like other architectures.
Quoted 5 lines
Quoted 3 lines
fix, a minimal fix might be:
FWIW, I think a minimal fix would have been to mark the variable as
__maybe_unused,
I am not quite sure we want this as the point is that drivers should be independent of
architectural differences.
The driver code, for itself, seems quite innocent,
struct page *dst_page = sg_page(req->dst);
for (i = 0; i < nr_pages; i++)
flush_dcache_page(dst_page + i);
The only problem is that xtensa's flush_dcache_page is a macro and doesn't use the "page"
parameter.
if we re-use the inline function in common cacheflush.h, it won't be a problem.
Quoted 3 lines
but as others have pointed out it would be nice if there would be a guidance about optional API functions like this one that specifies if it may be implemented as macro and, if so, how it has to handle unused variables.
I agree. personally I like this and will have a go in Documentation/process/coding-style.rst
and see others' opinions.
Quoted 3 lines
Thanks,
Guenter
Thanks
Barry
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.
Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>
Guenter
Hi,
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.
Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>
The mainline kernel still fails to build xtensa:allmodconfig.
Building xtensa:allmodconfig ... failed
--------------
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);
This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?
Thanks,
Guenter
Quoted 58 lines · Guenter Roeck
Hi,
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>The mainline kernel still fails to build xtensa:allmodconfig.
Building xtensa:allmodconfig ... failed
--------------
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page*dst_page=sg_page(req->dst);
Quoted 2 lines
This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?
I'd prefer this can be applied upstream.
Hi Andrew, would you like to pull it?
Quoted 3 lines
Thanks,
Guenter
Thanks
Barry
Quoted 58 lines · Guenter Roeck
Hi,
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>The mainline kernel still fails to build xtensa:allmodconfig.
Building xtensa:allmodconfig ... failed
--------------
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page*dst_page=sg_page(req->dst);
Quoted 2 lines
This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?
Applied to my xtensa tree.
I was still hoping to see rationale for why this is a useful warning.
Signature · 2 lines
Thanks. -- Max
Quoted 60 lines · Max Filippov
Quoted 58 lines · Guenter Roeck
Hi,
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE0
#endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]76 | struct page *page; | ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>The mainline kernel still fails to build xtensa:allmodconfig.
Building xtensa:allmodconfig ... failed
--------------
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page*dst_page=sg_page(req->dst);
Quoted 4 lines
Quoted 2 lines
This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?
Applied to my xtensa tree.
Thanks for taking care of this, Max!
Quoted 1 line
I was still hoping to see rationale for why this is a useful warning.
Personally, I think the reason is quite obvious.
This warning serves as a valuable alert, highlighting an issue where Xtensa fails to properly implement flush_dcache_page(). The problem lies in a macro definition that neglects to evaluate its argument. Such discrepancies can impact driver functionality across various architectures, rendering them independent of specific architectural considerations.
Quoted 4 lines
--
Thanks.
-- Max
Thanks
Barry
Quoted 59 lines · Max Filippov
Quoted 58 lines · Guenter Roeck
Hi,
Quoted 34 lines · Barry Song
From: Barry Song <[email protected]>
xtensa's
flush_dcache_page()can be a no-op sometimes. There is a generic implementation for this case ininclude/asm-generic/cacheflush.h.
#ifndefARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline voidflush_dcache_page(struct page *page){
}#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 #endifSo remove the superfluous
flush_dcache_page()definition, which also helps silence potential build warnings complaining the page variable passed toflush_dcache_page()is not used.In file included from
crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':Quoted 1 line
Quoted 1 line
crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]174 | struct page *dst_page = sg_page(req->dst); |The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.
This patch also removes lots of redundant macros which have been defined by
asm-generic/cacheflush.h.Quoted 10 lines
Cc Huacai Chen <[email protected]>Cc Herbert Xu <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Barry Song <[email protected]>Closes https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/ open hereReported-by Guenter Roeck <[email protected]>Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")Signed-off-by Barry Song <[email protected]>The mainline kernel still fails to build xtensa:allmodconfig.
Building xtensa:allmodconfig ... failed
--------------
Error log:crypto/scompress.c: In function 'scomp_acomp_comp_decomp':crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page*dst_page=sg_page(req->dst);
Quoted 6 lines
Quoted 2 lines
This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?
Applied to my xtensa tree.
I was still hoping to see rationale for why this is a useful warning.
Useful in general or here ? In general it helps a lot to identify unnecessary or buggy code, and I think it is very useful. In this case, the other option would have been to declare the variable as __maybe_unused. I think that has been discussed. Personally I preferred the more comprehensive patch because it makes the code more generic, but at this point in the release cycle I really only want to know what to do with xtensa:allmodconfig test builds.
Thanks,
Guenter