Re: [PATCH] btrfs: disable large folios for systems with highmem

Jeff Layton <[email protected]> Wed, 22 Jul 2026 11:41:28 -0400
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
On Mon, 2026-07-20 at 19:19 +0930, Qu Wenruo wrote:
> [BUG]
> There is a bug report that on 32bit systems (i686), btrfs crashes when
> trying to do zstd compression:
> 
>  BUG: unable to handle page fault for address: fffbc000
>  #PF: supervisor read access in kernel mode
>  #PF: error_code(0x0000) - not-present page
>  CPU: 0 UID: 0 PID: 61 Comm: kworker/u8:5 Tainted: G                 N  7.2.0-rc3-P3 #2 PREEMPTLAZY
>  Hardware name: LENOVO 2007F2G/2007F2G, BIOS 79ETE7WW (2.27 ) 03/21/2011
>  Workqueue: btrfs-delalloc btrfs_work_helper
>  EIP: ZSTD_compressStream2+0x221/0x5fc
>  Call Trace:
>   ZSTD_compressStream+0xd/0x48
>   zstd_compress_stream+0x8/0x10
>   zstd_compress_bio+0x20a/0x564
>   btrfs_compress_bio+0x94/0xc0
>   compress_file_range+0x20a/0x380
>   btrfs_work_helper+0xc1/0x1b4
>   process_scheduled_works+0x15f/0x204
>   worker_thread+0x10c/0x178
>   kthread+0xe1/0xe8
>   ret_from_fork+0x1d/0x14c
>   ret_from_fork_asm+0x12/0x18
>   entry_INT80_32+0xf0/0xf0
>  CR2: 00000000fffbc000
>  ---[ end trace 0000000000000000 ]---
> 
> [CAUSE]
> Inside zstd_compress_bio(), we assume the whole page cache folio can be
> mapped in one go.
> 
> However that assumption is not true on systems with CONFIG_HIGHMEM, the
> pages of the large folio can be in HIGHMEM, which needs to be mapped
> before access.
> 
> Meanwhile zstd_compress_bio() only map the page of a large folio where
> the start filepos is, the remaining pages are not mapped, and accessing
> the remaining pages will trigger the above crash.
> 

Yechh. The fact that kmap_local_folio() only maps the page at the
particular offset in the highmem case seems like a landmine waiting for
someone to step on.

OTOH, who cares about highmem these days? I think there was some
discussion of getting rid of it at LSF this year?

In any case...

Reviewed-by: Jeff Layton <[email protected]>