mk68k: Fix broken THREAD_SIZE_ORDER
Subsystems (2)
PATCH 1/1 mk68k: Fix broken THREAD_SIZE_ORDER
Current THREAD_SIZE_ORDER implementation for m68k is incorrect, fix it by ilog2().
--- arch/m68k/include/asm/thread_info.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/include/asm/thread_info.h +2 -1
@@ -19,7 +19,8 @@#else #define THREAD_SIZE PAGE_SIZE#endif -#define THREAD_SIZE_ORDER ((THREAD_SIZE / PAGE_SIZE) - 1) + +#define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)#ifndef __ASSEMBLY__
Signature · 1 line
2.27.0
Quoted 2 lines · Dawei Li
Current
THREAD_SIZE_ORDERimplementation for m68k is incorrect, fix it byilog2().
This is not a good commit log. Incorrect in what way and why is the fixed version correct? And what is affected? Note you're referring to a change which was done 14 years ago. It definitely must not be that incorrect (for everybody).
Quoted 21 lines
Fixes cddafa3500fd ("m68k/m68knommu: merge MMU and non-MMU thread_info.h")Signed-off-by Dawei Li <[email protected]>--- arch/m68k/include/asm/thread_info.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/m68k/include/asm/thread_info.h +2
-1@@ -19,7 +19,8 @@#else #define THREAD_SIZE PAGE_SIZE#endif -#define THREAD_SIZE_ORDER ((THREAD_SIZE / PAGE_SIZE) - 1) + +#define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)#ifndef __ASSEMBLY__
Signature · 2 lines
js suse labs
Hi Jiri,
Thanks for quick review.
Quoted 5 lines · Jiri Slaby
Quoted 2 lines · Dawei Li
Current
THREAD_SIZE_ORDERimplementation for m68k is incorrect, fix it byilog2().This is not a good commit log. Incorrect in what way and why is the fixed
Agreed.
Quoted 3 lines
version correct? And what is affected? Note you're referring to a change which was done 14 years ago. It definitely must not be that incorrect (for everybody).
It's 'right' just for current PAGE_SIZE & THREAD_SIZE configs:
// arch/m68k/include/asm/thread_info.h
#if PAGE_SHIFT < 13
#ifdef CONFIG_4KSTACKS
#define THREAD_SIZE 4096
#else
#define THREAD_SIZE 8192
#endif
#else
#define THREAD_SIZE PAGE_SIZE
#endif
#define THREAD_SIZE_ORDER ((THREAD_SIZE / PAGE_SIZE) - 1)
// arch/m68k/include/asm/page.h
#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
#define PAGE_SHIFT 13
#else
#define PAGE_SHIFT 12
#endif
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE-1)) #define PAGE_OFFSET (PAGE_OFFSET_RAW)
But it's incorrect in generic/mathematical way.
Thanks,
Dawei
Quoted 26 lines
Quoted 20 lines
Fixes cddafa3500fd ("m68k/m68knommu: merge MMU and non-MMU thread_info.h")Signed-off-by Dawei Li <[email protected]>--- arch/m68k/include/asm/thread_info.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/m68k/include/asm/thread_info.h +2
-1@@ -19,7 +19,8 @@#else #define THREAD_SIZE PAGE_SIZE#endif -#define THREAD_SIZE_ORDER ((THREAD_SIZE / PAGE_SIZE) - 1) + +#define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)#ifndef __ASSEMBLY__Signature · 2 lines
js suse labs
Geert Uytterhoeven
maintainerHi Dawei,
Quoted 15 lines · Dawei Li
Quoted 5 lines · Jiri Slaby
Quoted 2 lines · Dawei Li
Current
THREAD_SIZE_ORDERimplementation for m68k is incorrect, fix it byilog2().This is not a good commit log. Incorrect in what way and why is the fixed
Agreed.
Quoted 3 lines
version correct? And what is affected? Note you're referring to a change which was done 14 years ago. It definitely must not be that incorrect (for everybody).
It's 'right' just for current
PAGE_SIZE&THREAD_SIZEconfigs:
Quoted 11 lines
//
arch/m68k/include/asm/thread_info.h
#ifPAGE_SHIFT< 13
#ifdefCONFIG_4KSTACKS
#defineTHREAD_SIZE4096
#else
#defineTHREAD_SIZE8192
#endif
#else
#defineTHREAD_SIZEPAGE_SIZE
#endif
#defineTHREAD_SIZE_ORDER((THREAD_SIZE/PAGE_SIZE) - 1)
Indeed. The only supported values for THREAD_SIZE_ORDER on m68k are 0 and 1.
Quoted 1 line
But it's incorrect in generic/mathematical way.
True. But does it matter much?
I.e. do you plan to add support for larger values of THREAD_SIZE?
What about changing the #ifdeffery to set THREAD_SIZE_ORDER to an explicit value, and calculating THREAD_SIZE from THREAD_SIZE_ORDER instead?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds