Re: [PATCH v3] erofs: cap LZMA stream pool size

From: Geert Uytterhoeven

Date: Wed Aug 12 2026 - 05:40:24 EST


Hi Gao,

On Wed, 12 Aug 2026 at 01:37, Gao Xiang <xiang@xxxxxxxxxx> wrote:
> On Tue, Aug 11, 2026 at 03:37:38PM -0400, Michael Bommarito wrote:
> > On Tue, Aug 11, 2026 at 3:35 PM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
> > > > 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):
>
> diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
> index 8ca1767dafb6..2dfc313588d2 100644
> --- a/fs/erofs/Kconfig
> +++ b/fs/erofs/Kconfig
> @@ -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

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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