Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp105322rba; Wed, 20 Mar 2024 12:18:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2ipJ9c3bRfHMf3jXGqPKGHNptmjEKe+C9S2hbn8z/P4/40tgHeuY+zVoy6BfKE/gADjAgJ+jePEkWOyo3XZk8k6e/r03tu83jsev0Kg== X-Google-Smtp-Source: AGHT+IF9bA/G3lXo3vWo2IzvWEYWpqexwFodSmZr3ov8F7UY9Q6B88nfA1bMGzAUSNqoflEZ+n/G X-Received: by 2002:a17:90a:e288:b0:29c:7544:54df with SMTP id d8-20020a17090ae28800b0029c754454dfmr17163864pjz.23.1710962292053; Wed, 20 Mar 2024 12:18:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710962292; cv=pass; d=google.com; s=arc-20160816; b=mowMwzToBGtO8co8OpEUkGi027nR0BrpvfH3O3+Fx9kX2176H1tnCSKr6KVefE8ylC fx6TmLbTzMxgpaGIPaXEfLL6W35JpZ6CjVLZDuatAyxNCt01IYljjFej8463wInRxCZD ZWkz33BeosfKP13hZOcpF6P0DJf3VcDF4AXyGsArg1cfzxfiuFqYUrLACQz9oDvA5AyS YYjOAW1/CYNpCBY1zVCH24scMxho31bUscxJ9O85DzIhYr2zMMuv9uIV4Rzu55yC9Mzk xuIioj+aR09kaMRm3EXqOyoSXPAYC/L7ENymkL6X1ahraRZcI7uQmVnK+NpzUJ2PJdEn atMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=yBUEveZIyXdLJKrr8Zs+ZlOtx21h52Nfex3rcdZ3SZ8=; fh=cZ0pQj0gfnIzfSrD4acEszNw58lcj8DsI017uhDo/HI=; b=NAOIAoPnpMacCW0IXvA+u3/KITy0B6CZeh1VwXqf3gfD2Nvv3pb/PeOKy9rtZ2JCvf wRAtXyCOaiiTKGBrMcKiJilRLwzZbSAAC+SLBGVnFvWTQdqES+0pl4Waijjg5XF0PUaq 3vhY4yyTKVBKYFjj6SStYH4YrC9LGn3uu4RoZ4ymJEO2kcHBq62A8sTOMVxcpz/dyqpK auOjYvRZKlN6MBLeZ6A3yc7ZVohzcz6+w8rKTAAS0HosD81h2bZUNDj8OYnX+eq052Ab jxmS0jUHTSLjrFxqYs54MTJK4VsviZleSvqGFx4gNgq3Sw6pQp0ZLFMyrnLMACpeZkrs Gesg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=tukaani.org); spf=pass (google.com: domain of linux-kernel+bounces-109334-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109334-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id cl21-20020a17090af69500b0029fc13b5217si1979391pjb.96.2024.03.20.12.18.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 12:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109334-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=tukaani.org); spf=pass (google.com: domain of linux-kernel+bounces-109334-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109334-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 298ACB22260 for ; Wed, 20 Mar 2024 19:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6A5A85929; Wed, 20 Mar 2024 19:17:47 +0000 (UTC) Received: from mailscanner05.zoner.fi (mailscanner05.zoner.fi [5.44.246.14]) (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 8073B8562D for ; Wed, 20 Mar 2024 19:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.44.246.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710962267; cv=none; b=ZHFrDkKEhiIMqh6OXzMn3idIqOdUdb5nmKMIOD5H2lgU5Eb8x3zHA3h7UaN6Hl8rMerul4Mllhzuccz8sB/t80BKdSIvI0Z/45R+6Pcjsw27DoTs+ppAo3moPcwfYG7fuuuAoC3tBhuUvNh+m9+afTSxdkkd+GMGOcK+cXl1gUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710962267; c=relaxed/simple; bh=1STaSSKFT9aWSutIcaXf5t9tigM61VZiBi4b8crf1L0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZmN9DiQpAin3kMEyS0OMvSXEaf+hGjkdFf910gbk0snFPzm/2gVtu8dqDn12wZem5PRY89UgKlo750rNSoh72mzGbMbcU3dRoEoZHoWJlO6FRPAtUEFO4d1KpaAIWIZ6DR21kRUcLI0SHE81QY8VOt06gH+9Cn2NMi/Bghjfcb4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tukaani.org; spf=pass smtp.mailfrom=tukaani.org; arc=none smtp.client-ip=5.44.246.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tukaani.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tukaani.org Received: from www25.zoner.fi (www25.zoner.fi [84.34.147.45]) by mailscanner05.zoner.fi (Postfix) with ESMTPS id 4D5E3211A4; Wed, 20 Mar 2024 21:17:42 +0200 (EET) Received: from mail.zoner.fi ([84.34.147.244]) by www25.zoner.fi with esmtp (Exim 4.96.1-7-g79877b70e) (envelope-from ) id 1rn0qU-0001dW-2g; Wed, 20 Mar 2024 20:39:26 +0200 From: Lasse Collin To: Andrew Morton Cc: Lasse Collin , Jia Tan , linux-kernel@vger.kernel.org Subject: [PATCH 10/11] xz: Use 128 MiB dictionary and force single-threaded mode Date: Wed, 20 Mar 2024 20:38:43 +0200 Message-ID: <20240320183846.19475-11-lasse.collin@tukaani.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240320183846.19475-1-lasse.collin@tukaani.org> References: <20240320183846.19475-1-lasse.collin@tukaani.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This only affects kernel image compression, not any other xz usage. Desktop kernels on x86-64 are already around 60 MiB. Using a dictionary larger than 32 MiB should have no downsides nowadays as anyone building the kernel should have plenty of RAM. 128 MiB dictionary needs 1346 MiB of RAM with xz versions 5.0.x - 5.6.x in single-threaded mode. On archs that use xz_wrap.sh, kernel decompression is done in single-call mode so a larger dictionary doesn't affect boot-time memory requirements. xz >= 5.6.0 uses multithreaded mode by default which compresses slightly worse than single-threaded mode. Kernel compression rarely used more than one thread anyway because with 32 MiB dictionary size the default block size was 96 MiB in multithreaded mode. So only a single thread was used anyway unless the kernel was over 96 MiB. Comparison to CONFIG_KERNEL_LZMA: It uses "lzma -9" which mapped to 32 MiB dictionary in LZMA Utils 4.32.7 (the final release in 2008). Nowadays the lzma tool on most systems is from XZ Utils where -9 maps to 64 MiB dictionary. So using a 32 MiB dictionary with CONFIG_KERNEL_XZ may have compressed big kernels slightly worse than the old LZMA option. Comparison to CONFIG_KERNEL_ZSTD: zstd uses 128 MiB dictionary. Reviewed-by: Jia Tan Signed-off-by: Lasse Collin --- scripts/xz_wrap.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh index bb760b721b2c..c8c36441ab70 100755 --- a/scripts/xz_wrap.sh +++ b/scripts/xz_wrap.sh @@ -16,4 +16,15 @@ case $SRCARCH in sparc) BCJ=--sparc ;; esac -exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB +# Use single-threaded mode because it compresses a little better +# (and uses less RAM) than multithreaded mode. +# +# For the best compression, the dictionary size shouldn't be +# smaller than the uncompressed kernel. 128 MiB dictionary +# needs less than 1400 MiB of RAM in single-threaded mode. +# +# On the archs that use this script to compress the kernel, +# decompression in the preboot code is done in single-call mode. +# Thus the dictionary size doesn't affect the memory requirements +# of the preboot decompressor at all. +exec $XZ --check=crc32 --threads=1 $BCJ --lzma2=$LZMA2OPTS,dict=128MiB -- 2.44.0