Skip to contentSkip to conversation

erofs: cap LZMA stream pool size

PATCH In review Michael Bommarito 7 participants 36 messages Jul 14 – Aug 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: an attacker-supplied EROFS image mounted by the system can pin up to 8 MiB times the LZMA stream count of kernel vmalloc memory.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8

---
v3: rename the Kconfig option to EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
and only cap the default (num_possible_cpus); an explicit non-zero lzma_streams module parameter is now honoured unchanged. Simplified
the Kconfig help text and dropped the in-code comment, per Gao
Xiang's review.
v2: https://lore.kernel.org/linux-erofs/[email protected]/

Evidence: the stock code sets the stream count to num_possible_cpus() when lzma_streams is unset, and z_erofs_load_lzma_config() then preallocates one image-supplied dictionary (up to Z_EROFS_LZMA_MAX_DICT_SIZE, 8 MiB) per stream, so on a host with many CPUs a single small mounted image reserves num_possible_cpus() x up-to-8 MiB of vmalloc decoder state until the module is unloaded. With this patch an unset lzma_streams caps the default at CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS (16, i.e. 128 MiB worst case), while an explicit non-zero lzma_streams= is left unbounded. Built with W=1, no new warnings; boots and mounts an LZMA image with the capped default and with lzma_streams= overriding it.

 fs/erofs/Kconfig             | 14 ++++++++++++++
 fs/erofs/decompressor_lzma.c |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +14 -0
index 4789b1077d8ce..8948cb6314e07 100644
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
 	  Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+	int "EROFS LZMA default maximum decompression streams"
+	depends on EROFS_FS_ZIP_LZMA
+	range 1 1024
+	default 16
+	help
+	  By default EROFS allocates one LZMA decompression stream per CPU.
+	  Each stream can hold a dictionary of up to 8 MiB taken from the
+	  mounted image, so on systems with many CPUs this can reserve a lot
+	  of memory.  This caps the default; the lzma_streams module parameter
+	  still overrides it.
+
+	  If unsure, keep the default of 16.
+
 config EROFS_FS_ZIP_DEFLATE
 	bool "EROFS DEFLATE compressed data support"
 	depends on EROFS_FS_ZIP
fs/erofs/decompressor_lzma.c +2 -1
index f6692d0f2f04d..6b0cdb446c6ad 100644
@@ -51,7 +51,8 @@ static int __init z_erofs_lzma_init(void)
 
 	/* by default, use # of possible CPUs instead */
 	if (!z_erofs_lzma_nstrms)
-		z_erofs_lzma_nstrms = num_possible_cpus();
+		z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
+				CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
 
 	for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
 		struct z_erofs_lzma *strm = kzalloc_obj(*strm);
Signature · 1 line
2.53.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 17 lines · Michael Bommarito

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: an attacker-supplied EROFS image mounted by the system can pin up to 8 MiB times the LZMA stream count of kernel vmalloc memory.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Quoted 4 lines
Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8

Thanks,
Gao Xiang

Reviewed-by
#2 lore raw

Hi Machael,

Quoted 20 lines · Gao Xiang
Quoted 17 lines · Michael Bommarito

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB.  On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: an attacker-supplied EROFS image mounted by the system can pin up to 8 MiB times the LZMA stream count of kernel vmalloc memory.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB while preserving the existing per-image dictionary limit.  An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Quoted 5 lines
Quoted 4 lines
Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8

I submitted the following version to -next:

From 4ec57610a769cd93027d12134c75160390b23b08 Mon Sep 17 00:00:00 2001
From: Michael Bommarito <[email protected]>
Date: Tue, 14 Jul 2026 07:47:29 -0400
Subject: erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: An EROFS image mounted by the system can pin up to 8 MiB of vmalloc memory per LZMA stream, either as intended or unexpectedly.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB if the number of CPUs is no less than 16 while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8
---
 fs/erofs/Kconfig             | 14 ++++++++++++++
 fs/erofs/decompressor_lzma.c |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +14 -0
index 4789b1077d8ce..36f027c1c5ac5 100644
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
 	  Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+	int "EROFS LZMA default maximum decompression streams"
+	depends on EROFS_FS_ZIP_LZMA
+	range 1 NR_CPUS
+	default 16
+	help
+	  By default EROFS allocates one LZMA decompression stream per CPU.
+	  Each stream can hold a dictionary of up to 8 MiB taken from the
+	  mounted image, so on systems with many CPUs this can reserve a lot
+	  of memory.  This caps the default; the lzma_streams module parameter
+	  still overrides it.
+
+	  If unsure, keep the default of 16.
+
 config EROFS_FS_ZIP_DEFLATE
 	bool "EROFS DEFLATE compressed data support"
 	depends on EROFS_FS_ZIP
fs/erofs/decompressor_lzma.c +2 -1
index f6692d0f2f04d..6b0cdb446c6ad 100644
@@ -51,7 +51,8 @@ static int __init z_erofs_lzma_init(void)
 
 	/* by default, use # of possible CPUs instead */
 	if (!z_erofs_lzma_nstrms)
-		z_erofs_lzma_nstrms = num_possible_cpus();
+		z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
+				CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
 
 	for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
 		struct z_erofs_lzma *strm = kzalloc_obj(*strm);
#3 lore raw

Hello,

Quoted 68 lines · On Tue, 21 Jul 2026 11:44:04 +0800 Gao Xiang <[email protected]>…

Hi Machael,

Quoted 20 lines · Gao Xiang
Quoted 17 lines · Michael Bommarito

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB.  On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: an attacker-supplied EROFS image mounted by the system can pin up to 8 MiB times the LZMA stream count of kernel vmalloc memory.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB while preserving the existing per-image dictionary limit.  An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Quoted 5 lines
Quoted 4 lines
Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8

I submitted the following version to -next:

From 4ec57610a769cd93027d12134c75160390b23b08 Mon Sep 17 00:00:00 2001
From: Michael Bommarito <[email protected]>
Date: Tue, 14 Jul 2026 07:47:29 -0400
Subject: erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: An EROFS image mounted by the system can pin up to 8 MiB of vmalloc memory per LZMA stream, either as intended or unexpectedly.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB if the number of CPUs is no less than 16 while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8
---
  fs/erofs/Kconfig             | 14 ++++++++++++++
  fs/erofs/decompressor_lzma.c |  3 ++-
  2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +0 -0
index 4789b1077d8ce..36f027c1c5ac5 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 137

Quoted 7 lines
fs/erofs/Kconfig +4 -0
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
  	  Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+	int "EROFS LZMA default maximum decompression streams"
+	depends on EROFS_FS_ZIP_LZMA
+	range 1 NR_CPUS

Hello, I just found this breaks CONFIG_NR_CPUS undefined builds. For example, my m68k build test [1] shows problems like below:

    $ build_m68k_w1.sh
    [...]
    fs/erofs/Kconfig:137:warning: range is invalid
    .config:13480:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS

I confirmed using 1024 as the upperlimit of the range, like the original patch, fixes the problem. I'm not sure if that's the right and preferred fix, though. I'm just reporting my finding.

[1] https://github.com/damonitor/damon-tests/blob/master/corr/tests/build_m68k_w1.sh

Thanks,
SJ

[...]

maintainer
#4 lore raw

Hi SJ,

Quoted 10 lines · SJ Park

Hello,

Quoted 6 lines · On Tue, 21 Jul 2026 11:44:04 +0800 Gao Xiang <[email protected]>…

Hi Machael,

Quoted 3 lines · Gao Xiang

On 2026/7/14 19:47, Michael Bommarito wrote:

...

Quoted 57 lines
Quoted 41 lines
Quoted 1 line

I submitted the following version to -next:

From 4ec57610a769cd93027d12134c75160390b23b08 Mon Sep 17 00:00:00 2001
From: Michael Bommarito <[email protected]>
Date: Tue, 14 Jul 2026 07:47:29 -0400
Subject: erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: An EROFS image mounted by the system can pin up to 8 MiB of vmalloc memory per LZMA stream, either as intended or unexpectedly.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB if the number of CPUs is no less than 16 while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8
---
  fs/erofs/Kconfig             | 14 ++++++++++++++
  fs/erofs/decompressor_lzma.c |  3 ++-
  2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +0 -0
index 4789b1077d8ce..36f027c1c5ac5 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 137

Quoted 7 lines
fs/erofs/Kconfig +4 -0
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
  	  Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+	int "EROFS LZMA default maximum decompression streams"
+	depends on EROFS_FS_ZIP_LZMA
+	range 1 NR_CPUS

Hello, I just found this breaks CONFIG_NR_CPUS undefined builds. For example, my m68k build test [1] shows problems like below:

    $ build_m68k_w1.sh
    [...]
    fs/erofs/Kconfig:137:warning: range is invalid
    .config:13480:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
Quoted 5 lines

I confirmed using 1024 as the upperlimit of the range, like the original patch, fixes the problem. I'm not sure if that's the right and preferred fix, though. I'm just reporting my finding.

[1] https://github.com/damonitor/damon-tests/blob/master/corr/tests/build_m68k_w1.sh

Thanks for the report, but may I ask if it was a warning instead of a configuration failure? (because I didn't see a report on -next also I don't have a m68k testfarm).

Personally I think NR_CPU is better than an arbitrary number (like 1024) for sysadmins (or vendors) to customize their kernels so I hope I could find a way to use NR_CPUS-like approach instead of a hardcoded number.

Also I've seen the previous discussion to define CONFIG_NR_CPUS on m68k but not sure what happened in the end:
https://lore.kernel.org/r/[email protected]

Thanks,
Gao Xiang

Quoted 6 lines

Thanks,
SJ

[...]

#5 lore raw
Quoted 73 lines · On Tue, 28 Jul 2026 14:31:14 +0800 Gao Xiang <[email protected]> wrote:

Hi SJ,

Quoted 10 lines · SJ Park

Hello,

Quoted 6 lines · On Tue, 21 Jul 2026 11:44:04 +0800 Gao Xiang <[email protected]>…

Hi Machael,

Quoted 3 lines · Gao Xiang

On 2026/7/14 19:47, Michael Bommarito wrote:

...

Quoted 57 lines
Quoted 41 lines
Quoted 1 line

I submitted the following version to -next:

From 4ec57610a769cd93027d12134c75160390b23b08 Mon Sep 17 00:00:00 2001
From: Michael Bommarito <[email protected]>
Date: Tue, 14 Jul 2026 07:47:29 -0400
Subject: erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: An EROFS image mounted by the system can pin up to 8 MiB of vmalloc memory per LZMA stream, either as intended or unexpectedly.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB if the number of CPUs is no less than 16 while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8
---
  fs/erofs/Kconfig             | 14 ++++++++++++++
  fs/erofs/decompressor_lzma.c |  3 ++-
  2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +0 -0
index 4789b1077d8ce..36f027c1c5ac5 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 137

Quoted 7 lines
fs/erofs/Kconfig +4 -0
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
  	  Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+	int "EROFS LZMA default maximum decompression streams"
+	depends on EROFS_FS_ZIP_LZMA
+	range 1 NR_CPUS

Hello, I just found this breaks CONFIG_NR_CPUS undefined builds. For example, my m68k build test [1] shows problems like below:

    $ build_m68k_w1.sh
    [...]
    fs/erofs/Kconfig:137:warning: range is invalid
    .config:13480:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
Quoted 8 lines
Quoted 5 lines

I confirmed using 1024 as the upperlimit of the range, like the original patch, fixes the problem. I'm not sure if that's the right and preferred fix, though. I'm just reporting my finding.

[1] https://github.com/damonitor/damon-tests/blob/master/corr/tests/build_m68k_w1.sh

Thanks for the report, but may I ask if it was a warning instead of a configuration failure?

Indeed it didn't directly fails. Instead, it was trying to do config again, like below.

[...]
fs/erofs/Kconfig:137:warning: range is invalid
.config:13479:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS *
* Restart config...
*
*
* Miscellaneous filesystems
*
Miscellaneous filesystems (MISC_FILESYSTEMS) [Y/n/?] y
ORANGEFS (Powered by PVFS) support (ORANGEFS_FS) [Y/n/m/?] y
ADFS file system support (ADFS_FS) [Y/n/m/?] y
ADFS write support (DANGEROUS) (ADFS_FS_RW) [Y/n/?] y
[...]
UFS file system support (read only) (UFS_FS) [Y/n/m/?] y
UFS file system write support (DANGEROUS) (UFS_FS_WRITE) [Y/n/?] y
UFS debugging (UFS_DEBUG) [Y/n/?] y
EROFS filesystem support (EROFS_FS) [Y/n/m/?] y
EROFS debugging feature (EROFS_FS_DEBUG) [Y/n/?] y
EROFS extended attributes (EROFS_FS_XATTR) [Y/n/?] y
EROFS Access Control Lists (EROFS_FS_POSIX_ACL) [Y/n/?] y
EROFS Security Labels (EROFS_FS_SECURITY) [Y/n/?] y
File-backed EROFS filesystem support (EROFS_FS_BACKED_BY_FILE) [Y/n/?] y
EROFS Data Compression Support (EROFS_FS_ZIP) [Y/n/?] y
EROFS LZMA compressed data support (EROFS_FS_ZIP_LZMA) [Y/n/?] y
EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [NR_CPUS] (NEW)

And, I find no way to go out of the prompt other than Ctrl-C.

Quoted 2 lines

(because I didn't see a report on -next also
I don't have a m68k testfarm).

I don't have a m68k testfarm, either. I'm doing crossbuild [1]. Hopefully you could also reproduce it.

Quoted 4 lines

Personally I think NR_CPU is better than an arbitrary number (like 1024) for sysadmins (or vendors) to customize their kernels so I hope I could find a way to use NR_CPUS-like approach instead of a hardcoded number.

I agree. I have no good idea for the right fix at the moment, though.

[1] https://github.com/damonitor/damon-tests/blob/master/corr/tests/build_m68k_w1.sh

Thanks,
SJ

[...]

#6 lore raw
Quoted 115 lines · SJ Park
Quoted 73 lines · On Tue, 28 Jul 2026 14:31:14 +0800 Gao Xiang <[email protected]> wrote:

Hi SJ,

Quoted 10 lines · SJ Park

Hello,

Quoted 6 lines · On Tue, 21 Jul 2026 11:44:04 +0800 Gao Xiang <[email protected]>…

Hi Machael,

Quoted 3 lines · Gao Xiang

On 2026/7/14 19:47, Michael Bommarito wrote:

...

Quoted 57 lines
Quoted 41 lines
Quoted 1 line

I submitted the following version to -next:

From 4ec57610a769cd93027d12134c75160390b23b08 Mon Sep 17 00:00:00 2001
From: Michael Bommarito <[email protected]>
Date: Tue, 14 Jul 2026 07:47:29 -0400
Subject: erofs: cap LZMA stream pool size

fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream pool from num_possible_cpus() when the lzma_streams module parameter is unset, then z_erofs_load_lzma_config() preallocates one image-supplied dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed decoder state until the erofs module is unloaded.

Impact: An EROFS image mounted by the system can pin up to 8 MiB of vmalloc memory per LZMA stream, either as intended or unexpectedly.

Bound the default stream count by a new CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the worst-case default preallocation is 128 MiB if the number of CPUs is no less than 16 while preserving the existing per-image dictionary limit. An explicit lzma_streams module parameter is still honoured as-is, so administrators who deliberately size the pool are not affected.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Assisted-by Claude:claude-opus-4-8
---
  fs/erofs/Kconfig             | 14 ++++++++++++++
  fs/erofs/decompressor_lzma.c |  3 ++-
  2 files changed, 16 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +0 -0
index 4789b1077d8ce..36f027c1c5ac5 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 137

Quoted 7 lines
fs/erofs/Kconfig +4 -0
@@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
 
            Say N if you want to disable LZMA compression support.
 
+config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
+ int "EROFS LZMA default maximum decompression streams"
+ depends on EROFS_FS_ZIP_LZMA
+ range 1 NR_CPUS

Hello, I just found this breaks CONFIG_NR_CPUS undefined builds. For example, my m68k build test [1] shows problems like below:

    $ build_m68k_w1.sh
    [...]
    fs/erofs/Kconfig:137:warning: range is invalid
    .config:13480:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
Quoted 8 lines
Quoted 5 lines

I confirmed using 1024 as the upperlimit of the range, like the original patch, fixes the problem. I'm not sure if that's the right and preferred fix, though. I'm just reporting my finding.

[1] https://github.com/damonitor/damon-tests/blob/master/corr/tests/build_m68k_w1.sh

Thanks for the report, but may I ask if it was a warning instead of a configuration failure?

Indeed it didn't directly fails. Instead, it was trying to do config again, like below.

[...]
fs/erofs/Kconfig:137:warning: range is invalid
.config:13479:warning: symbol value 'NR_CPUS' invalid for EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS *
* Restart config...
*
*
* Miscellaneous filesystems
*
Miscellaneous filesystems (MISC_FILESYSTEMS) [Y/n/?] y
ORANGEFS (Powered by PVFS) support (ORANGEFS_FS) [Y/n/m/?] y
ADFS file system support (ADFS_FS) [Y/n/m/?] y
ADFS write support (DANGEROUS) (ADFS_FS_RW) [Y/n/?] y
[...]
UFS file system support (read only) (UFS_FS) [Y/n/m/?] y
UFS file system write support (DANGEROUS) (UFS_FS_WRITE) [Y/n/?] y
UFS debugging (UFS_DEBUG) [Y/n/?] y
EROFS filesystem support (EROFS_FS) [Y/n/m/?] y
EROFS debugging feature (EROFS_FS_DEBUG) [Y/n/?] y
EROFS extended attributes (EROFS_FS_XATTR) [Y/n/?] y
EROFS Access Control Lists (EROFS_FS_POSIX_ACL) [Y/n/?] y
EROFS Security Labels (EROFS_FS_SECURITY) [Y/n/?] y
File-backed EROFS filesystem support (EROFS_FS_BACKED_BY_FILE) [Y/n/?] y
EROFS Data Compression Support (EROFS_FS_ZIP) [Y/n/?] y
EROFS LZMA compressed data support (EROFS_FS_ZIP_LZMA) [Y/n/?] y
EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [NR_CPUS] (NEW)

Quoted 7 lines

And, I find no way to go out of the prompt other than Ctrl-C.

Quoted 2 lines

(because I didn't see a report on -next also
I don't have a m68k testfarm).

I don't have a m68k testfarm, either. I'm doing crossbuild [1]. Hopefully you could also reproduce it.

I think you can reproduce some of the issues on most architectures with a non-SMP kernel, cfr. my reply[1] to Uwe's proposed fix. Unfortunately the Kconfig warning only shows up on architectures that don't define NR_CPUS (because they do not support SMP) at all, while ending up with zero streams is probably a runtime failure.

[1] https://lore.kernel.org/CAMuHMdVGKX=3cfOrLWp1uSHX76xf1-=C0+GVCXkA8JTqNPg-ew@mail.gmail.com

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
#7 lore raw

Hello,

Quoted 3 lines · Geert Uytterhoeven
Quoted 2 lines · SJ Park

I don't have a m68k testfarm, either. I'm doing crossbuild [1]. Hopefully you could also reproduce it.

FTR, I don't have m68k hardware either, but as this is a build time failure installing the Debian package gcc-m68k-linux-gnu and then doing builds using

make ARCH=m68k CROSS_COMPILE=m68k-linux-gnu-

is good enough to reproduce the failure.

Quoted 7 lines

I think you can reproduce some of the issues on most architectures with a non-SMP kernel, cfr. my reply[1] to Uwe's proposed fix. Unfortunately the Kconfig warning only shows up on architectures that don't define NR_CPUS (because they do not support SMP) at all, while ending up with zero streams is probably a runtime failure.

[1] https://lore.kernel.org/CAMuHMdVGKX=3cfOrLWp1uSHX76xf1-=C0+GVCXkA8JTqNPg-ew@mail.gmail.com

I guess EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS should depend on SMP and it's use should be conditionalized using something like

fs/erofs/decompressor_lzma.c +7 -3
index 6b0cdb446c6a..c00e94f8206f 100644
@@ -50,9 +50,13 @@ static int __init z_erofs_lzma_init(void)
 	unsigned int i;
 
 	/* by default, use # of possible CPUs instead */
-	if (!z_erofs_lzma_nstrms)
-		z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
-				CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
+	if (!z_erofs_lzma_nstrms) {
+		if (IS_ENABLED(CONFIG_SMP))
+			z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
+					CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
+		else
+			z_erofs_lzma_nstrms = 1;
+	}
 
 	for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
 		struct z_erofs_lzma *strm = kzalloc_obj(*strm);

I played a bit with the definition of EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS in fs/erofs/Kconfig, but didn't find a way to define it that both uses NR_CPUS and doesn't generate a warning with ARCH=m68k.

Best regards
Uwe

#8 lore raw
Quoted 35 lines · Uwe Kleine-König
Quoted 3 lines · Geert Uytterhoeven
Quoted 2 lines · SJ Park

I don't have a m68k testfarm, either. I'm doing crossbuild [1]. Hopefully you could also reproduce it.

FTR, I don't have m68k hardware either, but as this is a build time failure installing the Debian package gcc-m68k-linux-gnu and then doing builds using

make ARCH=m68k CROSS_COMPILE=m68k-linux-gnu-

is good enough to reproduce the failure.

Quoted 7 lines

I think you can reproduce some of the issues on most architectures with a non-SMP kernel, cfr. my reply[1] to Uwe's proposed fix. Unfortunately the Kconfig warning only shows up on architectures that don't define NR_CPUS (because they do not support SMP) at all, while ending up with zero streams is probably a runtime failure.

[1] https://lore.kernel.org/CAMuHMdVGKX=3cfOrLWp1uSHX76xf1-=C0+GVCXkA8JTqNPg-ew@mail.gmail.com

I guess EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS should depend on SMP and it's use should be conditionalized using something like

fs/erofs/decompressor_lzma.c +0 -3
index 6b0cdb446c6a..c00e94f8206f 100644
@@ -50,9 +50,13 @@ static int __init z_erofs_lzma_init(void)
        unsigned int i;
 
        /* by default, use # of possible CPUs instead */
-       if (!z_erofs_lzma_nstrms)
-               z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
-                               CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);

fs/erofs/decompressor_lzma.c static int __init z_erofs_lzma_init(void) · line 62

Quoted 10 lines
fs/erofs/decompressor_lzma.c +7 -0
+       if (!z_erofs_lzma_nstrms) {
+               if (IS_ENABLED(CONFIG_SMP))
+                       z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
+                                       CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
+               else
+                       z_erofs_lzma_nstrms = 1;
+       }
 
        for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
                struct z_erofs_lzma *strm = kzalloc_obj(*strm);

LGTM.

Quoted 5 lines

I played a bit with the definition of EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS in fs/erofs/Kconfig, but didn't find a way to define it that both uses NR_CPUS and doesn't generate a warning with ARCH=m68k.

Any progress with fixing this for v7.2?

NR_CPUS depends on SMP on most architectures, so you get e.g. with ARCH=arm allmodconfig + CONFIG_SMP=n:

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0

X86 defines NR_CPUS unconditionally, so there it works as expected. Thanks!

Gr{oetje,eeting}s,

Geert

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

#9 lore raw
Quoted 58 lines · Geert Uytterhoeven
Quoted 35 lines · Uwe Kleine-König
Quoted 3 lines · Geert Uytterhoeven
Quoted 2 lines · SJ Park

I don't have a m68k testfarm, either. I'm doing crossbuild [1]. Hopefully you could also reproduce it.

FTR, I don't have m68k hardware either, but as this is a build time failure installing the Debian package gcc-m68k-linux-gnu and then doing builds using

make ARCH=m68k CROSS_COMPILE=m68k-linux-gnu-

is good enough to reproduce the failure.

Quoted 7 lines

I think you can reproduce some of the issues on most architectures with a non-SMP kernel, cfr. my reply[1] to Uwe's proposed fix. Unfortunately the Kconfig warning only shows up on architectures that don't define NR_CPUS (because they do not support SMP) at all, while ending up with zero streams is probably a runtime failure.

[1] https://lore.kernel.org/CAMuHMdVGKX=3cfOrLWp1uSHX76xf1-=C0+GVCXkA8JTqNPg-ew@mail.gmail.com

I guess EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS should depend on SMP and it's use should be conditionalized using something like

fs/erofs/decompressor_lzma.c +0 -3
index 6b0cdb446c6a..c00e94f8206f 100644
@@ -50,9 +50,13 @@ static int __init z_erofs_lzma_init(void)
         unsigned int i;
 
         /* by default, use # of possible CPUs instead */
-       if (!z_erofs_lzma_nstrms)
-               z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
-                               CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);

fs/erofs/decompressor_lzma.c static int __init z_erofs_lzma_init(void) · line 62

Quoted 10 lines
fs/erofs/decompressor_lzma.c +7 -0
+       if (!z_erofs_lzma_nstrms) {
+               if (IS_ENABLED(CONFIG_SMP))
+                       z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
+                                       CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
+               else
+                       z_erofs_lzma_nstrms = 1;
+       }
 
         for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
                 struct z_erofs_lzma *strm = kzalloc_obj(*strm);

LGTM.

Quoted 5 lines

I played a bit with the definition of EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS in fs/erofs/Kconfig, but didn't find a way to define it that both uses NR_CPUS and doesn't generate a warning with ARCH=m68k.

Any progress with fixing this for v7.2?

Quoted 8 lines

NR_CPUS depends on SMP on most architectures, so you get e.g. with ARCH=arm allmodconfig + CONFIG_SMP=n:

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0

X86 defines NR_CPUS unconditionally, so there it works as expected. Thanks!

FWIW, m68k:allmodconfig now fails to build due to this problem all the way back to v6.6.y.

Guenter

#10 lore raw
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Thanks,
Mike

maintainer
#11 lore raw

Hi,

Quoted 9 lines · Michael Bommarito
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Sorry about the late reply.

As I said, I really dislike hardcoded range, but it is an issue that no NR_CPUS definition on CONFIG_SMP:

I wonder if the following diff resolves the m68k issue (I'm not an Kconfig expert but it seems to work on x86_64 !CONFIG_SMP):

fs/erofs/Kconfig +2 -1
index 8ca1767dafb6..2dfc313588d2 100644
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
 	int "EROFS LZMA default maximum decompression streams"
 	depends on EROFS_FS_ZIP_LZMA
-	range 1 NR_CPUS
+	range 1 NR_CPUS if SMP
+	range 1 1 if !SMP
 	default 16
 	help
 	  By default EROFS allocates one LZMA decompression stream per CPU.

Thanks,
Gao Xiang

#12 lore raw

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 8 lines · Michael Bommarito
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Sorry about the late reply.

As I said, I really dislike hardcoded range, but it is an issue that no NR_CPUS definition on CONFIG_SMP:

I wonder if the following diff resolves the m68k issue (I'm not an Kconfig expert but it seems to work on x86_64 !CONFIG_SMP):

fs/erofs/Kconfig +0 -0
index 8ca1767dafb6..2dfc313588d2 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 9 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

Test runs on ARM (NR_CPUS depends on SMP, like most architectures), m68k (no CONFIG_NR_CPUS), and x86 (NR_CPUS is always defined) before/after:

     $ make ARCH=arm allmodconfig
     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
     CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=4

SMP is OK.

     $ sed -i "/CONFIG_SMP=y/d" .config
     $ yes "" | make ARCH=arm oldconfig
-
-No warning...
-
     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
-    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
+    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

-... but automatic configuration is silently broken on UP. +UP is OK with automatic configuration.

     $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config
     $ yes "" | make ARCH=arm oldconfig
-            EROFS LZMA default maximum decompression streams
(EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
-    [infinite loop]
+    $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
+    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

-Manual configuration is broken.
+UP is OK with manual configuration.

--------------------------------------------------------------------------------

      $ make ARCH=m68k allmodconfig
     fs/erofs/Kconfig:137:warning: range is invalid

Warning...

     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
-    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=NR_CPUS
-
-... but this will actually build and work, as <linux/threads.h> has:
-
-    #ifndef CONFIG_NR_CPUS
-    /* FIXME: This should be fixed in the arch's Kconfig */
-    #define CONFIG_NR_CPUS  1
-    #endif
-
-    /* Places which use this should consider cpumask_var_t. */
-    #define NR_CPUS         CONFIG_NR_CPUS
+    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1
+
+... but UP is OK with automatic configuration.
     $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config
     $ yes "" | make ARCH=m68k oldconfig
-            EROFS LZMA default maximum decompression streams
(EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [NR_CPUS] (NEW)
-    [infinite loop]
+    fs/erofs/Kconfig:137:warning: range is invalid
+
+Warning...
+
+    $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
+    CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

-Manual configuration is broken.
+... but UP is OK with manual configuration.

--------------------------------------------------------------------------------

     $ make ARCH=x86 allmodconfig
     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
     CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=16

SMP is OK.

     $ sed -i "/CONFIG_SMP=y/d" .config
     $ yes "" | make ARCH=x86 oldconfig
     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
     CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

UP is OK with automatic configuration.

     $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config
     $ yes "" | make ARCH=x86 oldconfig
     $ grep CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS .config
     CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

UP is OK with manual configuration.

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
maintainer
#13 lore raw

Hi Geert,

Quoted 39 lines · Geert Uytterhoeven

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 8 lines · Michael Bommarito
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Sorry about the late reply.

As I said, I really dislike hardcoded range, but it is an issue that no NR_CPUS definition on CONFIG_SMP:

I wonder if the following diff resolves the m68k issue (I'm not an Kconfig expert but it seems to work on x86_64 !CONFIG_SMP):

fs/erofs/Kconfig +0 -0
index 8ca1767dafb6..2dfc313588d2 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 9 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
      $ make ARCH=m68k allmodconfig
     fs/erofs/Kconfig:137:warning: range is invalid

Warning...

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

The following diff can eliminate the m68k warning above, I think m68k folks could consider this way if you really don't want to define an explicit NR_CPUS. Anyway, I think it should go with another patch:

```
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 11835eb59d94..90499f126c73 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -44,6 +44,9 @@ config M68K
 	select UACCESS_MEMCPY if !MMU
 	select ZONE_DMA
 
+config NR_CPUS
+	int
+
 config CPU_BIG_ENDIAN
 	def_bool y
```

I will try to form a formal patch (with the diff in the previous reply) directly to Linus (since I don't have other urgent patches for Linux 7.2.)

Thanks,
Gao Xiang

#14 lore raw

Hi Gao,

Quoted 66 lines · Gao Xiang

Hi Geert,

Quoted 39 lines · Geert Uytterhoeven

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 8 lines · Michael Bommarito
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Sorry about the late reply.

As I said, I really dislike hardcoded range, but it is an issue that no NR_CPUS definition on CONFIG_SMP:

I wonder if the following diff resolves the m68k issue (I'm not an Kconfig expert but it seems to work on x86_64 !CONFIG_SMP):

fs/erofs/Kconfig +0 -0
index 8ca1767dafb6..2dfc313588d2 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 9 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
      $ make ARCH=m68k allmodconfig
     fs/erofs/Kconfig:137:warning: range is invalid

Warning...

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

The following diff can eliminate the m68k warning above, I think m68k folks could consider this way if you really don't want to define an explicit NR_CPUS. Anyway, I think it should go with another patch:

```

arch/m68k/Kconfig +0 -0
index 11835eb59d94..90499f126c73 100644

arch/m68k/Kconfig config M68K · line 49

Quoted 6 lines
arch/m68k/Kconfig +3 -0
@@ -44,6 +44,9 @@ config M68K
        select UACCESS_MEMCPY if !MMU
        select ZONE_DMA
 
+config NR_CPUS
+       int
+

Let's bite the issue on m68k for good, I'll take Uwe's patch for v7.2
https://lore.kernel.org/all/[email protected]

Quoted 7 lines
arch/m68k/Kconfig +0 -0
 config CPU_BIG_ENDIAN
        def_bool y

```

I will try to form a formal patch (with the diff in the previous reply) directly to Linus (since I don't have other urgent patches for Linux 7.2.)

Thanks!

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
maintainer
#15 lore raw

PATCH 1/1 erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

CONFIG_NR_CPUS doesn't define on some UP platforms (e.g. arm), so this can cause make oldconfig to loop indefinitely when CONFIG_SMP=n:

 $ make ARCH=arm allmodconfig
 $ sed -i "/CONFIG_SMP=y/d" .config
 $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config

EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW) EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
...

Let's guard NR_CPUS with SMP instead of using a hardcoded arbitrary CPU uplimit here, similar to commit a3344078101c ("mm: make SPLIT_PTE_PTLOCKS depend on SMP").

The initial report from SJ Park was for m68k [1] (m68k is the only arch without NR_CPUS in Kconfig), and it will be changed in another patch [2].

[1] https://lore.kernel.org/all/[email protected]/T/#u
[2] https://lore.kernel.org/r/[email protected]

---
Hi Linus,

Could you apply this Kconfig fix directly since I don't have other urgent patch for 7.2 (so maybe it's unnecessary to have a pull request just for this..)

Many thank,
Gao Xiang

 fs/erofs/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/Kconfig +2 -1
index 8ca1767dafb6..2dfc313588d2 100644
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
 	int "EROFS LZMA default maximum decompression streams"
 	depends on EROFS_FS_ZIP_LZMA
-	range 1 NR_CPUS
+	range 1 NR_CPUS if SMP
+	range 1 1 if !SMP
 	default 16
 	help
 	  By default EROFS allocates one LZMA decompression stream per CPU.
Signature · 1 line
2.47.3
Tested-by on v1 1/1
#16 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Gao,

Thanks for your patch!

Quoted 10 lines · Gao Xiang

CONFIG_NR_CPUS doesn't define on some UP platforms (e.g. arm), so this can cause make oldconfig to loop indefinitely when CONFIG_SMP=n:

 $ make ARCH=arm allmodconfig
 $ sed -i "/CONFIG_SMP=y/d" .config
 $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config

EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW) EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
...

This also fixes EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS silently becoming zero (and thus breaking decompression completely?) for "automatic" configs like "make allmodconfig" or "make olddefconfig" on architectures where NR_CPUS depends on SMP (which is most of them).

Quoted 11 lines

Let's guard NR_CPUS with SMP instead of using a hardcoded arbitrary CPU uplimit here, similar to commit a3344078101c ("mm: make SPLIT_PTE_PTLOCKS depend on SMP").

The initial report from SJ Park was for m68k [1] (m68k is the only arch without NR_CPUS in Kconfig), and it will be changed in another patch [2].

[1] https://lore.kernel.org/all/[email protected]/T/#u
[2] https://lore.kernel.org/r/[email protected]

Quoted 7 lines

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 12 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

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
maintainer
#17 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Geert,

Quoted 12 lines · Geert Uytterhoeven

Hi Gao,

Thanks for your patch!

Quoted 7 lines · Gao Xiang

CONFIG_NR_CPUS doesn't define on some UP platforms (e.g. arm), so this can cause make oldconfig to loop indefinitely when CONFIG_SMP=n:

 $ make ARCH=arm allmodconfig
 $ sed -i "/CONFIG_SMP=y/d" .config
 $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config
Quoted 8 lines
Quoted 3 lines

EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW) EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
...

This also fixes EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS silently becoming zero (and thus breaking decompression completely?) for "automatic" configs like "make allmodconfig" or "make olddefconfig" on architectures where NR_CPUS depends on SMP (which is most of them).

Yeah, unfortunately..

Quoted 2 lines
Quoted 2 lines

...

Quoted 10 lines
Quoted 8 lines

Thanks!

Thanks,
Gao Xiang

Quoted 25 lines

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 13 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

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
Tested-by on v1 1/1
#18 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

In reply to Gao Xiang
Quoted 11 lines · On Wed, 12 Aug 2026 21:11:43 +0800 Gao Xiang <[email protected]> wrote:

CONFIG_NR_CPUS doesn't define on some UP platforms (e.g. arm), so this can cause make oldconfig to loop indefinitely when CONFIG_SMP=n:

 $ make ARCH=arm allmodconfig
 $ sed -i "/CONFIG_SMP=y/d" .config
 $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config

EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW) EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
...

Quoted 6 lines

Let's guard NR_CPUS with SMP instead of using a hardcoded arbitrary CPU uplimit here, similar to commit a3344078101c ("mm: make SPLIT_PTE_PTLOCKS depend on SMP").

The initial report from SJ Park was for m68k [1] (m68k is the only arch without NR_CPUS in Kconfig), and it will be changed in another patch [2].

Thank you for this patch. I confirmed this fixes the issue on my setup.

Quoted 11 lines

[1] https://lore.kernel.org/all/[email protected]/T/#u
[2] https://lore.kernel.org/r/[email protected]

Thanks,
SJ

[...]

#19 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

In reply to Gao Xiang

Hi Gao,

Quoted 21 lines · Gao Xiang

CONFIG_NR_CPUS doesn't define on some UP platforms (e.g. arm), so this can cause make oldconfig to loop indefinitely when CONFIG_SMP=n:

 $ make ARCH=arm allmodconfig
 $ sed -i "/CONFIG_SMP=y/d" .config
 $ sed -i "/CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS.*/d" .config

EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW) EROFS LZMA default maximum decompression streams (EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS) [0] (NEW)
...

Let's guard NR_CPUS with SMP instead of using a hardcoded arbitrary CPU uplimit here, similar to commit a3344078101c ("mm: make SPLIT_PTE_PTLOCKS depend on SMP").

The initial report from SJ Park was for m68k [1] (m68k is the only arch without NR_CPUS in Kconfig), and it will be changed in another patch [2].

[1] https://lore.kernel.org/all/[email protected]/T/#u
[2] https://lore.kernel.org/r/[email protected]

Quoted 7 lines

Thanks for your patch, which is now commit a64d500b0078e16e ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") in v7.2.

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 139

Quoted 10 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16

I have just discovered another oddity: when you have less than 16 CPUS (including SMP=n), this default value is invalid, and "make savedefconfig" will always write a line like

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

to the defconfig file, even if that is the default suggested value.

Needlessly polluting the defconfig files could be fixed using:

    -       default 16
    +       default 16 if SMP && NR_CPUS >= 16
    +       default NR_CPUS if SMP
    +       default 1 if !SMP

Thoughts?

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 2 lines
fs/erofs/Kconfig +0 -0
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

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
maintainer
#20 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Geert,

Quoted 2 lines · Geert Uytterhoeven

Hi Gao,

..

Quoted 21 lines

Thanks for your patch, which is now commit a64d500b0078e16e ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") in v7.2.

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 139

Quoted 10 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16

I have just discovered another oddity: when you have less than 16 CPUS (including SMP=n), this default value is invalid, and "make savedefconfig" will always write a line like

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

Quoted 7 lines

to the defconfig file, even if that is the default suggested value.

Needlessly polluting the defconfig files could be fixed using:

    -       default 16
    +       default 16 if SMP && NR_CPUS >= 16
    +       default NR_CPUS if SMP

I guess default NR_CPUS if SMP && NR_CPUS < 16 would be better, I'm not sure since I'm not handy in Kconfig stuffs.

Quoted 3 lines

+ default 1 if !SMP

Thoughts?

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

Thanks,
Gao Xiang

Quoted 15 lines

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 3 lines
fs/erofs/Kconfig +0 -0
        help
          By default EROFS allocates one LZMA decompression stream per CPU.

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
#21 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 22 lines · Geert Uytterhoeven

Thanks for your patch, which is now commit a64d500b0078e16e ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") in v7.2.

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 139

Quoted 10 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16

I have just discovered another oddity: when you have less than 16 CPUS (including SMP=n), this default value is invalid, and "make savedefconfig" will always write a line like

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

to the defconfig file, even if that is the default suggested value.

Quoted 8 lines
Quoted 5 lines

Needlessly polluting the defconfig files could be fixed using:

    -       default 16
    +       default 16 if SMP && NR_CPUS >= 16
    +       default NR_CPUS if SMP

I guess default NR_CPUS if SMP && NR_CPUS < 16 would be better, I'm not sure since I'm not handy in Kconfig stuffs.

Kconfig always picks the first matching default value, so you don't have to exclude the "SMP && NR_CPUS >= 16" case here.

Quoted 1 line
Quoted 1 line

+ default 1 if !SMP

If all architectures would always define NR_CPUS, one could replace the last two lines by

default NR_CPUS

Quoted 9 lines
Quoted 2 lines

Thoughts?

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

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
maintainer
#22 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Quoted 52 lines · Geert Uytterhoeven

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 22 lines · Geert Uytterhoeven

Thanks for your patch, which is now commit a64d500b0078e16e ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") in v7.2.

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 139

Quoted 10 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16

I have just discovered another oddity: when you have less than 16 CPUS (including SMP=n), this default value is invalid, and "make savedefconfig" will always write a line like

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

to the defconfig file, even if that is the default suggested value.

Quoted 8 lines
Quoted 5 lines

Needlessly polluting the defconfig files could be fixed using:

    -       default 16
    +       default 16 if SMP && NR_CPUS >= 16
    +       default NR_CPUS if SMP

I guess default NR_CPUS if SMP && NR_CPUS < 16 would be better, I'm not sure since I'm not handy in Kconfig stuffs.

Kconfig always picks the first matching default value, so you don't have to exclude the "SMP && NR_CPUS >= 16" case here.

Quoted 1 line
Quoted 1 line

+ default 1 if !SMP

If all architectures would always define NR_CPUS, one could replace the last two lines by

default NR_CPUS

Quoted 7 lines
Quoted 2 lines

Thoughts?

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Quoted 5 lines
Quoted 2 lines

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Thanks,
Gao Xiang

Quoted 12 lines

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
#23 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Gao,

Quoted 54 lines · Gao Xiang
Quoted 53 lines · Geert Uytterhoeven
Quoted 23 lines · Gao Xiang
Quoted 22 lines · Geert Uytterhoeven

Thanks for your patch, which is now commit a64d500b0078e16e ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") in v7.2.

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 139

Quoted 10 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
 config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
        int "EROFS LZMA default maximum decompression streams"
        depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
        default 16

I have just discovered another oddity: when you have less than 16 CPUS (including SMP=n), this default value is invalid, and "make savedefconfig" will always write a line like

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1

to the defconfig file, even if that is the default suggested value.

Quoted 8 lines
Quoted 5 lines

Needlessly polluting the defconfig files could be fixed using:

    -       default 16
    +       default 16 if SMP && NR_CPUS >= 16
    +       default NR_CPUS if SMP

I guess default NR_CPUS if SMP && NR_CPUS < 16 would be better, I'm not sure since I'm not handy in Kconfig stuffs.

Kconfig always picks the first matching default value, so you don't have to exclude the "SMP && NR_CPUS >= 16" case here.

Quoted 1 line
Quoted 1 line

+ default 1 if !SMP

If all architectures would always define NR_CPUS, one could replace the last two lines by

default NR_CPUS

Quoted 9 lines
Quoted 2 lines

Thoughts?

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

Quoted 7 lines
Quoted 2 lines

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...
In addition, usability can be improved by hiding the prompt on UP systems:

- int "EROFS LZMA default maximum decompression streams"
+ int "EROFS LZMA default maximum decompression streams" if SMP

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
maintainer
#24 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Geert,

Quoted 2 lines · Geert Uytterhoeven

Hi Gao,

...

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Quoted 6 lines
Quoted 4 lines

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...

Ok, anyway, I will try to submit a PR hours later. if there is a patch, the worst case is that it's included in the follow-up pull request.

Review

Quoted 6 lines

In addition, usability can be improved by hiding the prompt on UP systems:

(quoted diff) +1 -1
-       int "EROFS LZMA default maximum decompression streams"
+       int "EROFS LZMA default maximum decompression streams" if SMP

I hope CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS is a user-visible configuration (and the Kconfig text helps too) no matter the platform is UP or not (but it can be omitted in .config) even there is the only one choice in menuconfig for example on UP platforms.

Thanks,
Gao Xiang

Quoted 11 lines

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
#25 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Hi Gao,

Quoted 25 lines · Gao Xiang
Quoted 10 lines · Geert Uytterhoeven
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Quoted 6 lines
Quoted 4 lines

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...

Ok, anyway, I will try to submit a PR hours later. if there is a patch, the worst case is that it's included in the follow-up pull request.

Quoted 3 lines

In addition, usability can be improved by hiding the prompt on UP systems:

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +1 -1
-       int "EROFS LZMA default maximum decompression streams"
+       int "EROFS LZMA default maximum decompression streams" if SMP

I hope CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS is a user-visible configuration (and the Kconfig text helps too) no matter the platform is UP or not (but it can be omitted in .config) even there is the only one choice in menuconfig for example on UP platforms.

Why do you prefer it to be a user-visible option on UP? In general, we try not to bother the user with questions about configuration options that do not matter for him, or that offer only a single valid answer.

IMHO even "if SMP && EXPERT" would make sense...

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
maintainer
#26 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Quoted 37 lines · Geert Uytterhoeven

Hi Gao,

Quoted 25 lines · Gao Xiang
Quoted 10 lines · Geert Uytterhoeven
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Quoted 6 lines
Quoted 4 lines

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...

Ok, anyway, I will try to submit a PR hours later. if there is a patch, the worst case is that it's included in the follow-up pull request.

Quoted 3 lines

In addition, usability can be improved by hiding the prompt on UP systems:

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +1 -1
-       int "EROFS LZMA default maximum decompression streams"
+       int "EROFS LZMA default maximum decompression streams" if SMP

I hope CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS is a user-visible configuration (and the Kconfig text helps too) no matter the platform is UP or not (but it can be omitted in .config) even there is the only one choice in menuconfig for example on UP platforms.

Quoted 6 lines

Why do you prefer it to be a user-visible option on UP? In general, we try not to bother the user with questions about configuration options that do not matter for him, or that offer only a single valid answer.

IMHO even "if SMP && EXPERT" would make sense...

I think users should not be bothered with !SMP in the beginning.

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS impacts the default LZMA maximum memory usage, I hope it shows the same for both SMP or !SMP (even it cannot be configured on !SMP, since it clearly shows to users the number and indicates how the default LZMA stream derives in general.)

I think it's unlike something that is totally disabled in !SMP (or does't have such functionality in SMP), I think that is more sense to hide it in the configuration but here the DEFAULT_MAX_STREAM is still meaningful and is 1.

Thanks,
Gao Xiang

Quoted 12 lines

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
maintainer
#27 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

Quoted 47 lines · Gao Xiang
Quoted 37 lines · Geert Uytterhoeven

Hi Gao,

Quoted 25 lines · Gao Xiang
Quoted 10 lines · Geert Uytterhoeven
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Quoted 6 lines
Quoted 4 lines

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...

Ok, anyway, I will try to submit a PR hours later. if there is a patch, the worst case is that it's included in the follow-up pull request.

Quoted 3 lines

In addition, usability can be improved by hiding the prompt on UP systems:

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +1 -1
-       int "EROFS LZMA default maximum decompression streams"
+       int "EROFS LZMA default maximum decompression streams" if SMP

I hope CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS is a user-visible configuration (and the Kconfig text helps too) no matter the platform is UP or not (but it can be omitted in .config) even there is the only one choice in menuconfig for example on UP platforms.

Quoted 6 lines

Why do you prefer it to be a user-visible option on UP? In general, we try not to bother the user with questions about configuration options that do not matter for him, or that offer only a single valid answer.

IMHO even "if SMP && EXPERT" would make sense...

I think users should not be bothered with !SMP in the beginning.

Quoted 8 lines

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS impacts the default LZMA maximum memory usage, I hope it shows the same for both SMP or !SMP (even it cannot be configured on !SMP, since it clearly shows to users the number and indicates how the default LZMA stream derives in general.)

I think it's unlike something that is totally disabled in !SMP (or does't have such functionality in SMP), I think that is more sense

                                    ^ !SMP
Quoted 2 lines

to hide it in the configuration but here the DEFAULT_MAX_STREAM is still meaningful and is 1.

In other words, if NR_CPUS is defined unconditionally (regardless of SMP or not like the current status), from the user perspective, I think SMP inclusion here has no real gain, and it should be just range 1 NR_CPUS simply as a unique per-fs configuration.

Thanks,
Gao Xiang

Quoted 17 lines

Thanks,
Gao Xiang

Quoted 12 lines

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
#28 lore raw

Re: [PATCH] erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms

In reply to Gao Xiang

Hi Gao,

Quoted 36 lines · Gao Xiang
Quoted 35 lines · Geert Uytterhoeven
Quoted 33 lines · Gao Xiang
Quoted 10 lines · Geert Uytterhoeven
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

In principle, that would be better, but may I ask if there is some severe consequences out of one extra line of CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1?

Since it has been fixed for many times, I hope if it could be improved later if no severe impacts, sigh..

It causes more churn (defconfig updates), and makes the defconfig files larger than needed.

Quoted 6 lines
Quoted 4 lines

Could you submit a formal patch directly (since you found it and suggested a version)?

so I could submit it along with the pull request if you're fine with it.

Will do, I want to do a bit more testing first...

Ok, anyway, I will try to submit a PR hours later. if there is a patch, the worst case is that it's included in the follow-up pull request.

Review

Quoted 6 lines

In addition, usability can be improved by hiding the prompt on UP systems:

(quoted diff) +1 -1
-       int "EROFS LZMA default maximum decompression streams"
+       int "EROFS LZMA default maximum decompression streams" if SMP

I hope CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS is a user-visible configuration (and the Kconfig text helps too) no matter the platform is UP or not (but it can be omitted in .config) even there is the only one choice in menuconfig for example on UP platforms.

Quoted 8 lines
Quoted 6 lines

Why do you prefer it to be a user-visible option on UP? In general, we try not to bother the user with questions about configuration options that do not matter for him, or that offer only a single valid answer.

IMHO even "if SMP && EXPERT" would make sense...

I think users should not be bothered with !SMP in the beginning.

Because all systems are SMP? That is not true.

Quoted 5 lines

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS impacts the default LZMA maximum memory usage, I hope it shows the same for both SMP or !SMP (even it cannot be configured on !SMP, since it clearly shows to users the number and indicates how the default LZMA stream derives in general.)

I disagree: Kconfig is not meant to document underlying mechanisms that are not relevant for the current configuration.

Anyway, I have now submitted "[PATCH] erofs: Fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS default logic"
https://lore.kernel.org/c480ed6b8bf38822263e2c5b7cf32b28600f212d.1787219898.git.geert+renesas@glider.be/

Thanks!

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
#29 lore raw
In reply to Gao Xiang
Quoted 46 lines · Gao Xiang

Hi Geert,

Quoted 39 lines · Geert Uytterhoeven

Hi Gao,

Quoted 23 lines · Gao Xiang
Quoted 8 lines · Michael Bommarito
Quoted 1 line · Guenter Roeck
Quoted 1 line

Any progress with fixing this for v7.2?

I would like to fix this since I started the problem with the original patch, but I feel a bit stuck. My v1 and v2 patches would not have triggered the build failure, but Gao made valid points about the trade-offs that led us to this v3. Maybe it would be worth your opinion on the config approach in those earlier patches?

Sorry about the late reply.

As I said, I really dislike hardcoded range, but it is an issue that no NR_CPUS definition on CONFIG_SMP:

I wonder if the following diff resolves the m68k issue (I'm not an Kconfig expert but it seems to work on x86_64 !CONFIG_SMP):

fs/erofs/Kconfig +0 -0
index 8ca1767dafb6..2dfc313588d2 100644

fs/erofs/Kconfig config EROFS_FS_ZIP_LZMA · line 141

Quoted 9 lines
fs/erofs/Kconfig +2 -1
@@ -134,7 +134,8 @@ config EROFS_FS_ZIP_LZMA
  config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
         int "EROFS LZMA default maximum decompression streams"
         depends on EROFS_FS_ZIP_LZMA
-       range 1 NR_CPUS
+       range 1 NR_CPUS if SMP
+       range 1 1 if !SMP
         default 16
         help
           By default EROFS allocates one LZMA decompression stream per CPU.

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 1 line
Quoted 9 lines
Quoted 5 lines
       $ make ARCH=m68k allmodconfig
      fs/erofs/Kconfig:137:warning: range is invalid

Warning...

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

Quoted 10 lines

The following diff can eliminate the m68k warning above, I think m68k folks could consider this way if you really don't want to define an explicit NR_CPUS. Anyway, I think it should go with another patch:

```

arch/m68k/Kconfig +0 -0
index 11835eb59d94..90499f126c73 100644

arch/m68k/Kconfig config M68K · line 48

Quoted 5 lines
arch/m68k/Kconfig +2 -0
@@ -44,6 +44,9 @@ config M68K
  	select UACCESS_MEMCPY if !MMU
  	select ZONE_DMA
 
+config NR_CPUS
+	int

I would suggest to add

default 1

Guenter

Quoted 11 lines
arch/m68k/Kconfig +1 -0
+
  config CPU_BIG_ENDIAN
  	def_bool y

```

I will try to form a formal patch (with the diff in the previous reply) directly to Linus (since I don't have other urgent patches for Linux 7.2.)

Thanks,
Gao Xiang

maintainer
#30 lore raw

Hi Guenter,

On Wed, Aug 12, 2026 at 07:25:50AM -0700, Guenter Roeck wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
       $ make ARCH=m68k allmodconfig
      fs/erofs/Kconfig:137:warning: range is invalid

Warning...

Quoted 7 lines
Quoted 3 lines

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

Thanks,
Gao Xiang

#31 lore raw
Quoted 65 lines · Gao Xiang

Hi Guenter,

On Wed, Aug 12, 2026 at 07:25:50AM -0700, Guenter Roeck wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
        $ make ARCH=m68k allmodconfig
       fs/erofs/Kconfig:137:warning: range is invalid
   Warning...
Quoted 7 lines
Quoted 3 lines

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

Quoted 7 lines

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

$ grep NR_CPUS .config
CONFIG_FORCE_NR_CPUS=y
$ grep EROFS .config
CONFIG_EROFS_FS=y
# CONFIG_EROFS_FS_DEBUG is not set
CONFIG_EROFS_FS_XATTR=y
CONFIG_EROFS_FS_POSIX_ACL=y
CONFIG_EROFS_FS_SECURITY=y
CONFIG_EROFS_FS_BACKED_BY_FILE=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZMA=y
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
# CONFIG_EROFS_FS_ZIP_ACCEL is not set
# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set

The symbol may be there internally, but it does not show up in .config.

Guenter

maintainer
#32 lore raw
Quoted 91 lines · Guenter Roeck
Quoted 65 lines · Gao Xiang

Hi Guenter,

On Wed, Aug 12, 2026 at 07:25:50AM -0700, Guenter Roeck wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
        $ make ARCH=m68k allmodconfig
       fs/erofs/Kconfig:137:warning: range is invalid
   Warning...
Quoted 7 lines
Quoted 3 lines

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

Quoted 7 lines

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

$ grep NR_CPUS .config
CONFIG_FORCE_NR_CPUS=y
$ grep EROFS .config
CONFIG_EROFS_FS=y
# CONFIG_EROFS_FS_DEBUG is not set
CONFIG_EROFS_FS_XATTR=y
CONFIG_EROFS_FS_POSIX_ACL=y
CONFIG_EROFS_FS_SECURITY=y
CONFIG_EROFS_FS_BACKED_BY_FILE=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZMA=y
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
# CONFIG_EROFS_FS_ZIP_ACCEL is not set
# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set
Quoted 1 line

The symbol may be there internally, but it does not show up in .config.

As I said, the documentation:

If a prompt is not present, the config option is a non-visible symbol, meaning its value cannot be directly changed by the user (such as altering the value in .config) and the option will not appear in any config menus.

So It think it's expected, and any config X like this won't be shown in .config:

config X
int

Thanks,
Gao Xiang

Quoted 4 lines

Guenter

#33 lore raw
Quoted 102 lines · Gao Xiang
Quoted 91 lines · Guenter Roeck
Quoted 65 lines · Gao Xiang

Hi Guenter,

On Wed, Aug 12, 2026 at 07:25:50AM -0700, Guenter Roeck wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

...

Quoted 6 lines
         $ make ARCH=m68k allmodconfig
        fs/erofs/Kconfig:137:warning: range is invalid
    Warning...
Quoted 7 lines
Quoted 3 lines

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

Quoted 7 lines

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

$ grep NR_CPUS .config
CONFIG_FORCE_NR_CPUS=y
$ grep EROFS .config
CONFIG_EROFS_FS=y
# CONFIG_EROFS_FS_DEBUG is not set
CONFIG_EROFS_FS_XATTR=y
CONFIG_EROFS_FS_POSIX_ACL=y
CONFIG_EROFS_FS_SECURITY=y
CONFIG_EROFS_FS_BACKED_BY_FILE=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZMA=y
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
# CONFIG_EROFS_FS_ZIP_ACCEL is not set
# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set
Quoted 1 line

The symbol may be there internally, but it does not show up in .config.

As I said, the documentation:

If a prompt is not present, the config option is a non-visible symbol, meaning its value cannot be directly changed by the user (such as altering the value in .config) and the option will not appear in any config menus.

Quoted 6 lines

So It think it's expected, and any config X like this won't be shown in .config:

config X
int

Ah, yes, that makes sense.

Thanks,
Guenter

#34 lore raw
In reply to Guenter Roeck

Hi Günter,

Quoted 78 lines · Guenter Roeck
Quoted 52 lines · Gao Xiang
Quoted 6 lines · Guenter Roeck
Quoted 6 lines
Quoted 6 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

        $ make ARCH=m68k allmodconfig
       fs/erofs/Kconfig:137:warning: range is invalid
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
   Warning...

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

Quoted 7 lines

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

$ grep NR_CPUS .config
CONFIG_FORCE_NR_CPUS=y
$ grep EROFS .config
CONFIG_EROFS_FS=y
# CONFIG_EROFS_FS_DEBUG is not set
CONFIG_EROFS_FS_XATTR=y
CONFIG_EROFS_FS_POSIX_ACL=y
CONFIG_EROFS_FS_SECURITY=y
CONFIG_EROFS_FS_BACKED_BY_FILE=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZMA=y
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
# CONFIG_EROFS_FS_ZIP_ACCEL is not set
# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set
Quoted 1 line

The symbol may be there internally, but it does not show up in .config.

config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
...
range 1 NR_CPUS

Apparently the default value picked by "automatic" configs like allmodconfig and defconfig is the last item from the range. If NR_CPUS exists internally (e.g. openrisc and arm), you end up with the "undefined value", aka zero:

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0

As NR_CPUS did not exist on m68k at all, you ended up with the NR_CPUS literal:

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=NR_CPUS

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
#35 lore raw
Quoted 92 lines · Geert Uytterhoeven

Hi Günter,

Quoted 78 lines · Guenter Roeck
Quoted 52 lines · Gao Xiang
Quoted 6 lines · Guenter Roeck
Quoted 6 lines
Quoted 6 lines

Thank you, that seems to work (despite still seeing the warning on m68k, as NR_CPUS does not exist).

         $ make ARCH=m68k allmodconfig
        fs/erofs/Kconfig:137:warning: range is invalid
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
    Warning...

Yes, other arches shouldn't have the warning because I think other arches (including microblaze) defines NR_CPUS in Kconfig, except m68k.

That is not entirely true. openrisc only has it if SMP=y. But it still does not generate the warning for some reason.

I looked into the documentation a bit
(https://docs.kernel.org/kbuild/kconfig-language.html), especially the following parts:

- type definition: “bool”/”tristate”/”string”/”hex”/”int” ...
- input prompt: “prompt” <prompt> [“if” <expr>] ... and "If a prompt is not present, the config option is a non-visible symbol, ..."

- dependencies: “depends on” <expr> [“if” <expr>] ...
- Menu dependencies ..

and I think that is true, taking openrisc for example:

config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP
default "2"

which can be then transformed into

config NR_CPUS
int
prompt "Maximum number of CPUs (2-32)" if SMP range 2 32 if SMP
default "2" if SMP

Quoted 7 lines

so if SMP=n, it's equivalent to

config NR_CPUS
int

so NR_CPUS symbol is still there I think (and its value is 0.)

$ grep NR_CPUS .config
CONFIG_FORCE_NR_CPUS=y
$ grep EROFS .config
CONFIG_EROFS_FS=y
# CONFIG_EROFS_FS_DEBUG is not set
CONFIG_EROFS_FS_XATTR=y
CONFIG_EROFS_FS_POSIX_ACL=y
CONFIG_EROFS_FS_SECURITY=y
CONFIG_EROFS_FS_BACKED_BY_FILE=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZMA=y
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
# CONFIG_EROFS_FS_ZIP_ACCEL is not set
# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set
Quoted 1 line

The symbol may be there internally, but it does not show up in .config.

config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
...
range 1 NR_CPUS

Apparently the default value picked by "automatic" configs like allmodconfig and defconfig is the last item from the range. If NR_CPUS exists internally (e.g. openrisc and arm), you end up with the "undefined value", aka zero:

Quoted 7 lines

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=0

As NR_CPUS did not exist on m68k at all, you ended up with the NR_CPUS literal:

CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=NR_CPUS

Upstream commit a64d500b0078 ("erofs: fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS on some UP platforms") should fix that problem. Apparently it did not only affect openrisc.

Thanks,
Guenter