Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp255371ybb; Tue, 31 Mar 2020 22:40:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLm6sQjggW43A3au/xndonYossmePWvQIaAEnTBLXZjKE4B2pZSprn4/JmEkZluNhTJ6/L/ X-Received: by 2002:aca:fd48:: with SMTP id b69mr1628338oii.126.1585719629600; Tue, 31 Mar 2020 22:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585719629; cv=none; d=google.com; s=arc-20160816; b=d8BNJQX/DNF38P8T93s1cHYfEFipgNCrVDFCH7VdxYaU6fwsMH35e7kKdPRN0Z/cNm 3OyNEmHDPrzAnwF6uVfTnMhZkcfdtnDL+MWpLuVKWCC5bN60cKsSvygHoqM+WJRDEHOE Ztd8fBtRBSRQ9nBLiZoOFWlNAER/gYNeXwNU5C9tfKh32OItzJ5UKkj1yYjN06mG8xGd fCUuyeXDq5XMARjMH+YdpSjdnM9+VIhe3dhxnX8+9di6+KiYCWHMhVfwxtOC9P/vrv/s T2Hq1EakuolsaT1wHD7R3hZYPJpY8vq1Cyvgyit/CPsm/aBdADp9UCSXKPyqfMTEDNs0 qRNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R8dtQDKnSUbRACoeMRjT9BYjvuaePdj6FyBdWjfSkco=; b=t2rzfNX366Ir/cBz/c+5JTAR3ct4+GmGaFDBIZ4lHt8eXWFrJKOwenSCgU7Y1KphNo 9EG90JjUK/JPvq8SedlhIn4rQcNu6Gl6Bt7YflmXCAk3mKjvfxb4XwQKo+C66EORnbOw 3q9Zl0HcJDUqh0M62bhrprWezeLrGHyXnNOqm7U7c2HXjU9forW31Hgyuev1XXZm0RN+ 6AQVhmIGcnCrU8IvAt2yLfk7iAdTScFasNR5iFKXwFERKjRGl1fvx1hyYhhEATRtzA1p STld9s2TJ7XlCy86xc6YjJ5N5bH7jbyb3rUdtWTR1/xAWNMLL0qZ6nf8oG5vPino6I24 hjBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NsZBZLEG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si481523oix.67.2020.03.31.22.40.09; Tue, 31 Mar 2020 22:40:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NsZBZLEG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731848AbgDAFiy (ORCPT + 99 others); Wed, 1 Apr 2020 01:38:54 -0400 Received: from mail-pg1-f173.google.com ([209.85.215.173]:44731 "EHLO mail-pg1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbgDAFiy (ORCPT ); Wed, 1 Apr 2020 01:38:54 -0400 Received: by mail-pg1-f173.google.com with SMTP id 142so11571319pgf.11; Tue, 31 Mar 2020 22:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R8dtQDKnSUbRACoeMRjT9BYjvuaePdj6FyBdWjfSkco=; b=NsZBZLEGwzS7qm19uGzYVjwy6ePnxDrzfYi3Z27sXhOpQS8CfMha93hKRsJKPUxOXK PTbkYMwmRBLWoT6dNccdQNlkvcmfT0510byNaLNIXPDlpOtgLa48GgPFB9TGNZwhyZO7 5I+K8Jx9UE7ZLHGFC/KBpL7/wmklpCAP0XJ2pmyORb3MJhLERR0NFOA00Fzq+mHjILQC 0D+0osexrQnw1JrG1qs8U37DptlHfS1qi/gU47pI1MYdrsDCamF41230HK/zHGoCWeFa d0RTYkTcN6fWy8OfqGmDvQGWLVk5/LS2zTRdXqEmSzFUxzdyv0bkS3K1LkOJu785N1bE EdIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R8dtQDKnSUbRACoeMRjT9BYjvuaePdj6FyBdWjfSkco=; b=eIH3KH2YNhHVDnL7UDeadrw8xxlLcDfB4eDgLFh5eaEdzTPBR27h7xkxSFEJ4QdnFG hoB/9JiwLjE/blXVS5jo79ns27a4CpCFzCSJvkKwXYORWBmPtApBrqJCmd5bUf2wMfJZ IU3ZV5YNZGflvKLMVJy8bfkIBSqNvcyuCddD+n4xYSRnjetVZLOsGPtM7fuFxq8jsrpC V8iGuBMKjAy87Uhy9G3njgIhpmEPl+mPQwWEu55OZO8pys04uUcJFmijTanzrND00I6g sLE2Kk+TsW7gCLXvplXTBKQqHjiw0iyQLdl3p1pdaX7ES02o1OAnnJepK5saFVwvNSdI 09zg== X-Gm-Message-State: ANhLgQ12uoNkUO3hb4J41ud7a9BWoz4NtsI0AHlSgsyqJRjyuAMkdLmd XyNjcSTLLocU9aMxdn5qw1E= X-Received: by 2002:aa7:95a1:: with SMTP id a1mr22337115pfk.279.1585719532537; Tue, 31 Mar 2020 22:38:52 -0700 (PDT) Received: from nickserv.localdomain (c-67-188-225-242.hsd1.ca.comcast.net. [67.188.225.242]) by smtp.gmail.com with ESMTPSA id w69sm683077pfc.52.2020.03.31.22.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 22:38:52 -0700 (PDT) From: Nick Terrell To: Nick Terrell Cc: linux-kernel@vger.kernel.org, Chris Mason , linux-kbuild@vger.kernel.org, x86@kernel.org, gregkh@linuxfoundation.org, Petr Malat , Kees Cook , Kernel Team , Nick Terrell , Adam Borowski , Patrick Williams , rmikey@fb.com, mingo@kernel.org, Patrick Williams , Sedat Dilek Subject: [PATCH v4 5/8] usr: add support for zstd compressed initramfs Date: Tue, 31 Mar 2020 22:39:10 -0700 Message-Id: <20200401053913.216783-6-nickrterrell@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401053913.216783-1-nickrterrell@gmail.com> References: <20200401053913.216783-1-nickrterrell@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Terrell * Add support for a zstd compressed initramfs. * Add compression for compressing built-in initramfs with zstd. I have tested this patch by boot testing with buildroot and QEMU. Specifically, I booted the kernel with both a zstd and gzip compressed initramfs, both built into the kernel and separate. I ensured that the correct compression algorithm was used. I tested on arm, aarch64, i386, and x86_64. This patch has been tested in production on aarch64 and x86_64 devices. Additionally, I have performance measurements from internal use in production. On an aarch64 device we saw 19 second boot time improvement from switching from lzma to zstd (27 seconds to 8 seconds). On an x86_64 device we saw a 9 second boot time reduction from switching from xz to zstd. Reviewed-by: Kees Cook Tested-by: Sedat Dilek Signed-off-by: Nick Terrell --- usr/Kconfig | 20 ++++++++++++++++++++ usr/Makefile | 1 + 2 files changed, 21 insertions(+) diff --git a/usr/Kconfig b/usr/Kconfig index bdf5bbd40727..43aca37d09b5 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -100,6 +100,15 @@ config RD_LZ4 Support loading of a LZ4 encoded initial ramdisk or cpio buffer If unsure, say N. +config RD_ZSTD + bool "Support initial ramdisk/ramfs compressed using ZSTD" + default y + depends on BLK_DEV_INITRD + select DECOMPRESS_ZSTD + help + Support loading of a ZSTD encoded initial ramdisk or cpio buffer. + If unsure, say N. + choice prompt "Built-in initramfs compression mode" depends on INITRAMFS_SOURCE != "" @@ -207,4 +216,15 @@ config INITRAMFS_COMPRESSION_LZ4 If you choose this, keep in mind that most distros don't provide lz4 by default which could cause a build failure. +config INITRAMFS_COMPRESSION_ZSTD + bool "ZSTD" + depends on RD_ZSTD + help + ZSTD is a compression algorithm targeting intermediate compression + with fast decompression speed. It will compress better than GZIP and + decompress around the same speed as LZO, but slower than LZ4. + + If you choose this, keep in mind that you may need to install the zstd + tool to be able to compress the initram. + endchoice diff --git a/usr/Makefile b/usr/Makefile index c12e6b15ce72..b1a81a40eab1 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -15,6 +15,7 @@ compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma compress-$(CONFIG_INITRAMFS_COMPRESSION_XZ) := xzmisc compress-$(CONFIG_INITRAMFS_COMPRESSION_LZO) := lzo compress-$(CONFIG_INITRAMFS_COMPRESSION_LZ4) := lz4 +compress-$(CONFIG_INITRAMFS_COMPRESSION_ZSTD) := zstd obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o -- 2.26.0