[v5,1/3] printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled

Message ID 20240207171020.41036-2-yoann.congal@smile.fr
State New
Headers
Series printk: CONFIG_BASE_SMALL fix for LOG_CPU_MAX_BUF_SHIFT and removal of CONFIG_BASE_FULL |

Commit Message

Yoann Congal Feb. 7, 2024, 5:10 p.m. UTC
  LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
  config LOG_CPU_MAX_BUF_SHIFT
  	default 12 if !BASE_SMALL
  	default 0 if BASE_SMALL
But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
evaluated to true whatever is the value of BASE_SMALL.

This patch fixes this by using the correct conditional operator for int
type : BASE_SMALL != 0.

Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
not be a big impact due to this code in kernel/printk/printk.c:
  /* by default this will only continue through for large > 64 CPUs */
  if (cpu_extra <= __LOG_BUF_LEN / 2)
          return;
Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
rare.

John Ogness <john.ogness@linutronix.de> (printk reviewer) wrote:
> For printk this will mean that BASE_SMALL systems were probably
> previously allocating/using the dynamic ringbuffer and now they will
> just continue to use the static ringbuffer. Which is fine and saves
> memory (as it should).

Petr Mladek <pmladek@suse.com> (printk maintainer) wrote:
> More precisely, it allocated the buffer dynamically when the sum
> of per-CPU-extra space exceeded half of the default static ring
> buffer. This happened for systems with more than 64 CPUs with
> the default config values.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Closes: https://lore.kernel.org/all/f6856be8-54b7-0fa0-1d17-39632bf29ada@oracle.com/
Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")

---
v3->v4:
* Fix BASE_SMALL usage instead of switching to BASE_FULL because
  BASE_FULL will be removed in the next patches of this series.
---
 init/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Masahiro Yamada Feb. 10, 2024, 11:41 p.m. UTC | #1
On Thu, Feb 8, 2024 at 2:10 AM Yoann Congal <yoann.congal@smile.fr> wrote:
>
> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
>   config LOG_CPU_MAX_BUF_SHIFT
>         default 12 if !BASE_SMALL
>         default 0 if BASE_SMALL
> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
> evaluated to true whatever is the value of BASE_SMALL.
>
> This patch fixes this by using the correct conditional operator for int
> type : BASE_SMALL != 0.
>
> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
> not be a big impact due to this code in kernel/printk/printk.c:
>   /* by default this will only continue through for large > 64 CPUs */
>   if (cpu_extra <= __LOG_BUF_LEN / 2)
>           return;
> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
> rare.
>
> John Ogness <john.ogness@linutronix.de> (printk reviewer) wrote:
> > For printk this will mean that BASE_SMALL systems were probably
> > previously allocating/using the dynamic ringbuffer and now they will
> > just continue to use the static ringbuffer. Which is fine and saves
> > memory (as it should).
>
> Petr Mladek <pmladek@suse.com> (printk maintainer) wrote:
> > More precisely, it allocated the buffer dynamically when the sum
> > of per-CPU-extra space exceeded half of the default static ring
> > buffer. This happened for systems with more than 64 CPUs with
> > the default config values.
>
> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
> Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
> Closes: https://lore.kernel.org/all/f6856be8-54b7-0fa0-1d17-39632bf29ada@oracle.com/
> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
>



All the Reviewed-by tags are dropped every time, annoyingly.




This is equivalent to v4, which had these tags:

Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>











> ---
> v3->v4:
> * Fix BASE_SMALL usage instead of switching to BASE_FULL because
>   BASE_FULL will be removed in the next patches of this series.
> ---
>  init/Kconfig | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index deda3d14135bb..d50ebd2a2ce42 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -734,8 +734,8 @@ config LOG_CPU_MAX_BUF_SHIFT
>         int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
>         depends on SMP
>         range 0 21
> -       default 12 if !BASE_SMALL
> -       default 0 if BASE_SMALL
> +       default 0 if BASE_SMALL != 0
> +       default 12
>         depends on PRINTK
>         help
>           This option allows to increase the default ring buffer size
> --
> 2.39.2
>
>


--
Best Regards
Masahiro Yamada
  
Yoann Congal Feb. 12, 2024, 7:01 p.m. UTC | #2
Le 11/02/2024 à 00:41, Masahiro Yamada a écrit :
> On Thu, Feb 8, 2024 at 2:10 AM Yoann Congal <yoann.congal@smile.fr> wrote:
>>
>> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
>>   config LOG_CPU_MAX_BUF_SHIFT
>>         default 12 if !BASE_SMALL
>>         default 0 if BASE_SMALL
>> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
>> evaluated to true whatever is the value of BASE_SMALL.
>>
>> This patch fixes this by using the correct conditional operator for int
>> type : BASE_SMALL != 0.
>>
>> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
>> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
>> not be a big impact due to this code in kernel/printk/printk.c:
>>   /* by default this will only continue through for large > 64 CPUs */
>>   if (cpu_extra <= __LOG_BUF_LEN / 2)
>>           return;
>> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
>> rare.
>>
>> John Ogness <john.ogness@linutronix.de> (printk reviewer) wrote:
>>> For printk this will mean that BASE_SMALL systems were probably
>>> previously allocating/using the dynamic ringbuffer and now they will
>>> just continue to use the static ringbuffer. Which is fine and saves
>>> memory (as it should).
>>
>> Petr Mladek <pmladek@suse.com> (printk maintainer) wrote:
>>> More precisely, it allocated the buffer dynamically when the sum
>>> of per-CPU-extra space exceeded half of the default static ring
>>> buffer. This happened for systems with more than 64 CPUs with
>>> the default config values.
>>
>> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
>> Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
>> Closes: https://lore.kernel.org/all/f6856be8-54b7-0fa0-1d17-39632bf29ada@oracle.com/
>> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
>>
> 
> 
> 
> All the Reviewed-by tags are dropped every time, annoyingly.

Hi!

Was I supposed to gather these tags from patch version N to patch version N+1?
In that case, I'm sorry, I did not know that :-/
Patch 1/3 is exactly the same but patch 2/3 is equivalent but different. Is there a rule written somewhere about when carrying the tags across revision and when not? (I could not find it)


> This is equivalent to v4, which had these tags:
> 
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>

Thanks a lot!






> 
>> ---
>> v3->v4:
>> * Fix BASE_SMALL usage instead of switching to BASE_FULL because
>>   BASE_FULL will be removed in the next patches of this series.
>> ---
>>  init/Kconfig | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/init/Kconfig b/init/Kconfig
>> index deda3d14135bb..d50ebd2a2ce42 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -734,8 +734,8 @@ config LOG_CPU_MAX_BUF_SHIFT
>>         int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
>>         depends on SMP
>>         range 0 21
>> -       default 12 if !BASE_SMALL
>> -       default 0 if BASE_SMALL
>> +       default 0 if BASE_SMALL != 0
>> +       default 12
>>         depends on PRINTK
>>         help
>>           This option allows to increase the default ring buffer size
>> --
>> 2.39.2
>>
>>
> 
> 
> --
> Best Regards
> Masahiro Yamada
  
Masahiro Yamada Feb. 14, 2024, 9:36 p.m. UTC | #3
On Tue, Feb 13, 2024 at 4:01 AM Yoann Congal <yoann.congal@smile.fr> wrote:
>
>
>
> Le 11/02/2024 à 00:41, Masahiro Yamada a écrit :
> > On Thu, Feb 8, 2024 at 2:10 AM Yoann Congal <yoann.congal@smilefr> wrote:
> >>
> >> LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
> >>   config LOG_CPU_MAX_BUF_SHIFT
> >>         default 12 if !BASE_SMALL
> >>         default 0 if BASE_SMALL
> >> But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always
> >> evaluated to true whatever is the value of BASE_SMALL.
> >>
> >> This patch fixes this by using the correct conditional operator for int
> >> type : BASE_SMALL != 0.
> >>
> >> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
> >> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will
> >> not be a big impact due to this code in kernel/printk/printk.c:
> >>   /* by default this will only continue through for large > 64 CPUs */
> >>   if (cpu_extra <= __LOG_BUF_LEN / 2)
> >>           return;
> >> Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite
> >> rare.
> >>
> >> John Ogness <john.ogness@linutronix.de> (printk reviewer) wrote:
> >>> For printk this will mean that BASE_SMALL systems were probably
> >>> previously allocating/using the dynamic ringbuffer and now they will
> >>> just continue to use the static ringbuffer. Which is fine and saves
> >>> memory (as it should).
> >>
> >> Petr Mladek <pmladek@suse.com> (printk maintainer) wrote:
> >>> More precisely, it allocated the buffer dynamically when the sum
> >>> of per-CPU-extra space exceeded half of the default static ring
> >>> buffer. This happened for systems with more than 64 CPUs with
> >>> the default config values.
> >>
> >> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> >> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> >> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
> >> Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
> >> Closes: https://lore.kernel.org/all/f6856be8-54b7-0fa0-1d17-39632bf29ada@oracle.com/
> >> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
> >>
> >
> >
> >
> > All the Reviewed-by tags are dropped every time, annoyingly.
>
> Hi!
>
> Was I supposed to gather these tags from patch version N to patch version N+1?
> In that case, I'm sorry, I did not know that :-/
> Patch 1/3 is exactly the same but patch 2/3 is equivalent but different. Is there a rule written somewhere about when carrying the tags across revision and when not? (I could not find it)


I do not know any written rules either.


In my experience, people carry tags
when changes since the previous version are small.
  

Patch

diff --git a/init/Kconfig b/init/Kconfig
index deda3d14135bb..d50ebd2a2ce42 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -734,8 +734,8 @@  config LOG_CPU_MAX_BUF_SHIFT
 	int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
 	depends on SMP
 	range 0 21
-	default 12 if !BASE_SMALL
-	default 0 if BASE_SMALL
+	default 0 if BASE_SMALL != 0
+	default 12
 	depends on PRINTK
 	help
 	  This option allows to increase the default ring buffer size