From nobody Thu Dec 18 01:54:51 2025 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC201C3BE1 for ; Tue, 14 Jan 2025 08:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736843300; cv=none; b=o7NOg5d3Rzvy3c0ukK8+TrFAUUG8J0N5J/ydmzH0VWkwlK7yh1SvmoJzbdzxvirPiNjrPn+h3XsHajOAIrudLzns3cyntGoS50I5rvPea2gzXuVfNOgP3geePt6xpe1vzO5ZxsczyP685nffkguGPzSIAkLPkPVthe53xTlewpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736843300; c=relaxed/simple; bh=Hl/tfKqsn7N94XXwMO0gpyzSSljwXJyQUpiTF/gpQLQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ciq/pshBFDZhcYeTnwmF17kMziaARLq/W0Q5YU598mTxC3cJn+Bd/AnmGJy8EpmqNhzlFkKI6N6LtCEZEdbDW1Yjq6wM6CCii2yvQTLNY/T8Ls3Fv7E7XiSgs2AZPlmkr0r5C9y0hFDgb3AxuyLR5uwS38wrvd79qslrhWZpjno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=K6JMhyVh; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="K6JMhyVh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1736843295; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=7XPgDDQ1CgGDc3sN4zJ8GISJcatuj4inkfzaFVSgP5s=; b=K6JMhyVhHlCI/LmBmUxY/hDR45FrW6v4yQKJPNbRh4BLOld8aR4o5MpbFVwImjRUpimb/AhURrKxD+cXLe8rjnzuR2Uov9L3q1oDQPfmldjRSiSC92+X3pUFGlzEgCRfSAph50Qkjp4RwrAX6lsK5q/RcinBt5coFiGmw60x2Xs= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WNehOg-_1736843288 cluster:ay36) by smtp.aliyun-inc.com; Tue, 14 Jan 2025 16:28:14 +0800 From: Gao Xiang To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-erofs@lists.ozlabs.org, Gao Xiang , Yann Collet , Nick Terrell Subject: [PATCH] include/linux/lz4.h: add some missing macros Date: Tue, 14 Jan 2025 16:28:07 +0800 Message-ID: <20250114082807.827690-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, LZ4_DISTANCE_MAX and LZ4_DECOMPRESS_INPLACE_MARGIN are defined in the erofs subsystem for LZ4 in-place decompression, which is somewhat unsuitable since they should belong to the LZ4 itself and may change with future LZ4 codebase updates. Move them to include/linux/lz4.h to match the upstream LZ4 library [1]. No logic changes. [1] https://github.com/lz4/lz4/blob/v1.10.0/lib/lz4.h#L670 Cc: Yann Collet Cc: Nick Terrell Signed-off-by: Gao Xiang --- Hi, It doesn't change any logic, but it'd be helpful to be moved for the next 6.14 cycle if it looks good. I keep the internal "MAX_DISTANCE" as-is since no need to touch the real implementation for now. fs/erofs/decompressor.c | 7 ------- include/linux/lz4.h | 6 ++++++ lib/lz4/lz4_compress.c | 1 - lib/lz4/lz4_decompress.c | 1 - lib/lz4/lz4defs.h | 4 ++-- lib/lz4/lz4hc_compress.c | 1 - 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index eb318c7ddd80..2b123b070a42 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -7,14 +7,7 @@ #include "compress.h" #include =20 -#ifndef LZ4_DISTANCE_MAX /* history window size */ -#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ -#endif - #define LZ4_MAX_DISTANCE_PAGES (DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) = + 1) -#ifndef LZ4_DECOMPRESS_INPLACE_MARGIN -#define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize) (((srcsize) >> 8) + 32) -#endif =20 struct z_erofs_lz4_decompress_ctx { struct z_erofs_decompress_req *rq; diff --git a/include/linux/lz4.h b/include/linux/lz4.h index b16e15b9587a..ad6042a718b5 100644 --- a/include/linux/lz4.h +++ b/include/linux/lz4.h @@ -645,4 +645,10 @@ int LZ4_decompress_safe_usingDict(const char *source, = char *dest, int LZ4_decompress_fast_usingDict(const char *source, char *dest, int originalSize, const char *dictStart, int dictSize); =20 +#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compress= edSize) >> 8) + 32) + +#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at co= mpile time */ +#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ +#endif + #endif diff --git a/lib/lz4/lz4_compress.c b/lib/lz4/lz4_compress.c index b0bbeeb74b9e..2a397bb2c661 100644 --- a/lib/lz4/lz4_compress.c +++ b/lib/lz4/lz4_compress.c @@ -33,7 +33,6 @@ /*-************************************ * Dependencies **************************************/ -#include #include "lz4defs.h" #include #include diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index 0e31e6da5ce7..3a2cd9acada4 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -33,7 +33,6 @@ /*-************************************ * Dependencies **************************************/ -#include #include "lz4defs.h" #include #include diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h index cb358d6bde5a..76d187d225cd 100644 --- a/lib/lz4/lz4defs.h +++ b/lib/lz4/lz4defs.h @@ -39,6 +39,7 @@ =20 #include #include /* memset, memcpy */ +#include =20 #define FORCE_INLINE __always_inline =20 @@ -92,8 +93,7 @@ typedef uintptr_t uptrval; #define MB (1 << 20) #define GB (1U << 30) =20 -#define MAXD_LOG 16 -#define MAX_DISTANCE ((1 << MAXD_LOG) - 1) +#define MAX_DISTANCE LZ4_MAX_DISTANCE #define STEPSIZE sizeof(size_t) =20 #define ML_BITS 4 diff --git a/lib/lz4/lz4hc_compress.c b/lib/lz4/lz4hc_compress.c index bc45594ad2a8..91936dc3d14b 100644 --- a/lib/lz4/lz4hc_compress.c +++ b/lib/lz4/lz4hc_compress.c @@ -34,7 +34,6 @@ /*-************************************ * Dependencies **************************************/ -#include #include "lz4defs.h" #include #include --=20 2.43.5