Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796181370; b=IKN2hcp6Myei6PYsjbwJ7nghtsrpRx8woLs0Jjl+oZJ3J+/12P1mszTgRbhtECCTKy6c ERdLih+NKj2pMv69m98leDUCfVRC/eJW8TszyZ+YCtCCq4scaBkgPkrFUm1mQ8cz0i8WZ Tz9HqtkwtY6mCM++c9utYx0itwxYZkstO7l6wI8L/cqZLP6eyVxOrY9DCnmzFlU3DEKeh YubwecbbIzYhci5uAxVWcJCNEqn4DsHlWhFl0o0CcotggxPBD5iOnNyfRuKaF8uVZjsMR PzvH1NWSigQPa6YqYkuC0VN9j9kTvdCR80Bj9CWphj0W5rekbMbJcGRGrOjwkpzFm2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796181370; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=a+qGe6NTYDHYPs6PjIe0opbL9Oevs7x+4+3v/VB6LXE=; b=HC295Tl9KzcyDe7jscdbBXvdB7WsxackcwVxoV/3mFoON7BXIXatQXxrDSaBT9Kf5Xd1 ne1hsFwNrIrzdMA3Ppd+5986I26Lv5sYfDR5kG3YpfQ0WELvsLLjCsEYywofvbAzi8YlH LcqwqSZ+fEd/ckZ9YCHa6W8bxBC8lqQMdKks3l5+Ma/1C9DKfuNc0yV56W3lsV4ZSmFFU ZQId3CFFGAxbI/gQ/xDi0fuCvIISYo6pUyHruszE5mxPF97zZ7xxOjX7sjsX8lUhmlVtd CkShP0tIWtI4/Wqk4PENiLj78t3H8CNz2uLgsJiaOf3BBuENiJDyoiQkfZ98OvN6FmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Q7xz2flb; arc=none smtp.remote-ip=209.85.221.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A11606A691 for ; Wed, 2 Dec 2026 03:16:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13A11606A691 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Q7xz2flb Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4a358881793so6652426f8f.0 for ; Tue, 01 Dec 2026 19:16:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796181369; x=1796786169; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a+qGe6NTYDHYPs6PjIe0opbL9Oevs7x+4+3v/VB6LXE=; b=Q7xz2flb+Q6C8WCl3ReJKsBDFRNrR5y0lrSPe6Qagv1h+PMYxWGYmZTm6wlNX/qRJi dO99gUv6VIPOnkGgBZmlVWDlWfLg4wIiT2sZZ3+Jsz1AuNz+uOvTf3gxQ2GmqYxJ163+ Mx/CQksBvN1PB2IwSDAfL/jdcNi1iWoktJ1Qqf12IvoSssiENb4YimlzWBiSzDj1N4Ig RDGYZpb+6CeJkOxwh4G+73qg90m/JZiY2r/eENcDtKMhKo2OZAg3V3TRFA2C4F+gkpzl DaH1wlE6fJNBGSomF1RXL7UK6PuxQhWRxkrOxHDS4Z9ukGpRhMbx+SPsbeKSC4lVehJs Rlgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796181369; x=1796786169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=a+qGe6NTYDHYPs6PjIe0opbL9Oevs7x+4+3v/VB6LXE=; b=OL/1cmyW9igC3b0GJCdorxkpx1Rt0P2cceczSJSishcgaWACmrVIJIDTPeTvPTWNf/ mylmk8OXSIUh8gkjWXubTx6Iz/FU1rMoX85CRECGp9Zz6iJuZsJbvw634njjf/e06Qpv eYINAG9P8J5RQIbLSFjEj/61zKXGnaBSgnB/OAy7Y7AdtSDiSshsMYNgLKPNo9FmnD0l 3MSzVMh/uXqDIy935iStK1dvHuoZwxX8qtkpUoOL6i86BxMkHZHWmH2qsouYuCRjHo3X SnqAj3686+qcIYc8Xr7qyGTuksICchJGSTFFb1NFaPj7W0ICafhc589SwJ2WyfglMqqu eQkw== X-Gm-Message-State: APuU4Z8gwrKeoz0eSnLRm+OszkCvUhVq7oGgPit4nxGIl0RlDEZTz8a+ Ge82ErxtJo50XKrrzJnueMURHVijd5pMlFBHBP9HjsHGCVQcykn5TYpXbyfKXBP4NbOLHWXl X-Gm-Gg: AZFdTZeVaeEoDJK8z1UAYjP1rmkAT9dBtuffCnlhOHOMlxNErpMil/T4FMRo0j3EM/B nJO9cSNnKunPKhgNA6AZloVzQjM1uVFHINcryDSG/dxxfhu7qU1rTMvkRtOEpOhY0/SnmN3mbR+ uP05Pe9/+leZQi9sCmi482WSt/LEIqzWVrGqhBivcBTv1VzDnPIANMjx5noO+AqYr991BWn48Ec pS4wffw50wjzskMeHyRYDu0EOwS1Swv9g+3RA3d4hSi6K+Yo1lxbMiJfGWvRm4J8qQwkH0rg/6b U7wgAhK1eaF4CCJUmP4NZ7f+3boshAtrSX780txETm3U8qrboocJ9b80+xXff4dHH8d9gwKRtzQ tsdVWVBLsS87KT/dp5EKHY4Y4FjSI8SNit4xQj4yMxbbAZAfQzCiX8eTBHAmQ8yxNpjaqSw6n9h mtbSOmcMOEG42Gzm1G8iP2u2+HKhVow1TL1DReNeUIKCypB6RxehAD8tEGw+uj7ot94zRtB5Zh7 7ygfgSHaxUb9Mf913PVA+KcONH8Sagv+e8VSuGNjxhzqFDAk2cCTeOBix03XBAuCKzFqbwORG5W K/DsdJzUcQ7EmvTalUQj/8YBuP8JEJw7ixiQ8A== X-Received: by 2002:a05:6000:2997:10b0:4a8:12d3:c0b2 with SMTP id ffacd0b85a97d-4abb47b2244mr56856226f8f.23.1796181368571; Tue, 01 Dec 2026 19:16:08 -0800 (PST) Received: from NULL.Home.net ([2001:8a0:7280:4000:12d:c3b9:cecc:8966]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb4341sm73334766f8f.4.2026.12.01.19.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 19:16:08 -0800 (PST) From: Eric Curtin To: linux-kernel@vger.kernel.org Cc: Eric Curtin , Gao Xiang , Chao Yu , Yue Hu , Jingbo Xu , Sandeep Dhavale , Hongbo Li , Chunhai Guo , Nick Terrell , David Sterba , linux-erofs@lists.ozlabs.org Subject: [RFC PATCH v2 11/22] erofs: Make the decompressor bounce buffers flexible arrays Date: Wed, 2 Dec 2026 03:15:14 +0000 Message-ID: <20261202031533.1665444-12-ericcurtin17@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202031533.1665444-1-ericcurtin17@gmail.com> References: <20261202031533.1665444-1-ericcurtin17@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Eric Curtin With arm64 boot-time page size selection PAGE_SIZE is not a compile-time constant, so it cannot be used as the size of the bounce[] member in the deflate, lzma and zstd stream structures. Turn bounce[] into a flexible array member in struct z_erofs_deflate, z_erofs_lzma and z_erofs_zstd, move it to the end of struct z_erofs_zstd, and allocate the structures with kzalloc_flex(*strm, bounce, PAGE_SIZE) so that the run-time page size sets the buffer size. In zdata.c, compute Z_EROFS_PCLUSTER_MAX_PAGES with PAGE_SIZE_MIN. It is used as an upper bound and must be constant. No functional change for compile-time page sizes. Signed-off-by: Eric Curtin --- fs/erofs/decompressor_deflate.c | 4 ++-- fs/erofs/decompressor_lzma.c | 4 ++-- fs/erofs/decompressor_zstd.c | 4 ++-- fs/erofs/zdata.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/erofs/decompressor_deflate.c b/fs/erofs/decompressor_deflate.c index 6167af1ffeb9..4cd441cb9070 100644 --- a/fs/erofs/decompressor_deflate.c +++ b/fs/erofs/decompressor_deflate.c @@ -5,7 +5,7 @@ struct z_erofs_deflate { struct z_erofs_deflate *next; struct z_stream_s z; - u8 bounce[PAGE_SIZE]; + u8 bounce[]; }; static DEFINE_SPINLOCK(z_erofs_deflate_lock); @@ -71,7 +71,7 @@ static int z_erofs_load_deflate_config(struct super_block *sb, ++z_erofs_deflate_avail_strms) { struct z_erofs_deflate *strm; - strm = kzalloc_obj(*strm); + strm = kzalloc_flex(*strm, bounce, PAGE_SIZE); if (!strm) goto failed; /* XXX: in-kernel zlib cannot customize windowbits */ diff --git a/fs/erofs/decompressor_lzma.c b/fs/erofs/decompressor_lzma.c index 9d15f94cbee1..5a5897b12f83 100644 --- a/fs/erofs/decompressor_lzma.c +++ b/fs/erofs/decompressor_lzma.c @@ -6,7 +6,7 @@ struct z_erofs_lzma { struct z_erofs_lzma *next; struct xz_dec_microlzma *state; unsigned int dict_size; - u8 bounce[PAGE_SIZE]; + u8 bounce[]; }; /* considering the LZMA performance, no need to use a lockless list for now */ @@ -56,7 +56,7 @@ static int __init z_erofs_lzma_init(void) 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); + struct z_erofs_lzma *strm = kzalloc_flex(*strm, bounce, PAGE_SIZE); if (!strm) { z_erofs_lzma_exit(); diff --git a/fs/erofs/decompressor_zstd.c b/fs/erofs/decompressor_zstd.c index ab318a2400f9..e9dc6eb67561 100644 --- a/fs/erofs/decompressor_zstd.c +++ b/fs/erofs/decompressor_zstd.c @@ -4,9 +4,9 @@ struct z_erofs_zstd { struct z_erofs_zstd *next; - u8 bounce[PAGE_SIZE]; void *wksp; unsigned int wkspsz; + u8 bounce[]; }; static DEFINE_SPINLOCK(z_erofs_zstd_lock); @@ -59,7 +59,7 @@ static int __init z_erofs_zstd_init(void) ++z_erofs_zstd_avail_strms) { struct z_erofs_zstd *strm; - strm = kzalloc_obj(*strm); + strm = kzalloc_flex(*strm, bounce, PAGE_SIZE); if (!strm) { z_erofs_zstd_exit(); return -ENOMEM; diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index e981e371d6c2..bc4a7133a097 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -10,7 +10,7 @@ #include #define Z_EROFS_MAX_SYNC_DECOMPRESS_BYTES 12288 -#define Z_EROFS_PCLUSTER_MAX_PAGES (Z_EROFS_PCLUSTER_MAX_SIZE / PAGE_SIZE) +#define Z_EROFS_PCLUSTER_MAX_PAGES (Z_EROFS_PCLUSTER_MAX_SIZE / PAGE_SIZE_MIN) #define Z_EROFS_INLINE_BVECS 2 struct z_erofs_bvec {