public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER
@ 2024-02-28  8:58 Dawei Li
  2024-02-28  9:11 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Dawei Li @ 2024-02-28  8:58 UTC (permalink / raw)
  To: geert; +Cc: gerg, linux-m68k, linux-kernel, set_pte_at, Dawei Li, stable

Current THREAD_SIZE_ORDER implementation for m68k is incorrect, fix it
by ilog2().

Fixes: cddafa3500fd ("m68k/m68knommu: merge MMU and non-MMU thread_info.h")
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
Cc: stable@vger.kernel.org
---
 arch/m68k/include/asm/thread_info.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h
index 31be2ad999ca..50faecd6fc5f 100644
--- a/arch/m68k/include/asm/thread_info.h
+++ b/arch/m68k/include/asm/thread_info.h
@@ -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__
 
-- 
2.27.0


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

* Re: [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER
  2024-02-28  8:58 [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER Dawei Li
@ 2024-02-28  9:11 ` Jiri Slaby
  2024-02-28  9:33   ` Dawei Li
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2024-02-28  9:11 UTC (permalink / raw)
  To: Dawei Li, geert; +Cc: gerg, linux-m68k, linux-kernel, set_pte_at, stable

On 28. 02. 24, 9:58, Dawei Li wrote:
> Current THREAD_SIZE_ORDER implementation for m68k is incorrect, fix it
> by ilog2().

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).

> Fixes: cddafa3500fd ("m68k/m68knommu: merge MMU and non-MMU thread_info.h")
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> Cc: stable@vger.kernel.org
> ---
>   arch/m68k/include/asm/thread_info.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h
> index 31be2ad999ca..50faecd6fc5f 100644
> --- a/arch/m68k/include/asm/thread_info.h
> +++ b/arch/m68k/include/asm/thread_info.h
> @@ -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__
>   

-- 
js
suse labs


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

* Re: [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER
  2024-02-28  9:11 ` Jiri Slaby
@ 2024-02-28  9:33   ` Dawei Li
  2024-02-28 10:09     ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Dawei Li @ 2024-02-28  9:33 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: geert, gerg, linux-m68k, linux-kernel, set_pte_at, stable

Hi Jiri,

Thanks for quick review.

On Wed, Feb 28, 2024 at 10:11:05AM +0100, Jiri Slaby wrote:
> On 28. 02. 24, 9:58, Dawei Li wrote:
> > Current THREAD_SIZE_ORDER implementation for m68k is incorrect, fix it
> > by ilog2().
> 
> This is not a good commit log. Incorrect in what way and why is the fixed

Agreed.

> 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

> 
> > Fixes: cddafa3500fd ("m68k/m68knommu: merge MMU and non-MMU thread_info.h")
> > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > Cc: stable@vger.kernel.org
> > ---
> >   arch/m68k/include/asm/thread_info.h | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h
> > index 31be2ad999ca..50faecd6fc5f 100644
> > --- a/arch/m68k/include/asm/thread_info.h
> > +++ b/arch/m68k/include/asm/thread_info.h
> > @@ -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__
> 
> -- 
> js
> suse labs
> 
> 

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

* Re: [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER
  2024-02-28  9:33   ` Dawei Li
@ 2024-02-28 10:09     ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2024-02-28 10:09 UTC (permalink / raw)
  To: Dawei Li; +Cc: Jiri Slaby, gerg, linux-m68k, linux-kernel, set_pte_at, stable

Hi Dawei,

On Wed, Feb 28, 2024 at 10:34 AM Dawei Li <dawei.li@shingroup.cn> wrote:
> On Wed, Feb 28, 2024 at 10:11:05AM +0100, Jiri Slaby wrote:
> > On 28. 02. 24, 9:58, Dawei Li wrote:
> > > Current THREAD_SIZE_ORDER implementation for m68k is incorrect, fix it
> > > by ilog2().
> >
> > This is not a good commit log. Incorrect in what way and why is the fixed
>
> Agreed.
>
> > 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)

Indeed.  The only supported values for THREAD_SIZE_ORDER on m68k are
0 and 1.

> 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

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

end of thread, other threads:[~2024-02-28 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28  8:58 [PATCH] mk68k: Fix broken THREAD_SIZE_ORDER Dawei Li
2024-02-28  9:11 ` Jiri Slaby
2024-02-28  9:33   ` Dawei Li
2024-02-28 10:09     ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox