Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp965296ybb; Wed, 25 Mar 2020 12:59:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv8FJKmcFeSpi+V5KISU+OYVTTdsQ4jVZ0izeWMLNl9+65glPopbyu2LWZrQuAPVDtwRhh2 X-Received: by 2002:aca:5652:: with SMTP id k79mr3741163oib.15.1585166397892; Wed, 25 Mar 2020 12:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585166397; cv=none; d=google.com; s=arc-20160816; b=WgM+vesL+/1cOhpTaEL6SmxADrUnepoLVHxhS+wF7r1cSk7C70hhXw3pjQ9XI0oglL LU0FI6rQCIJhuf2FFK9hHfwcan9Ol/vLHaTLI+sYpGbHU24DHPZkffRynkgb+M9tv45z nezenmbXVLrFu9AbNtAnA0Pf2v/Z4ZCCKpSb1fUeH0mPY/iIW42Ef8O7vAGbjSSkkITV 0VlzhxOYPvZpfI2M0nF557OnwmqvDjkZjneMc/0IwOCjxY4HI20rV253tXbmNDfNyA8S sCcxVTkSORB9nmUahpxvYZX9K3DcfzUMI9s/0YRny4M8OsNNa/ZXvZix+p7lw7gJdW5j IoSw== 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=qpxlNK60H7+56apDr31XbwcBVUW8ZgAgiNsYAJEsVhQ=; b=Cu6P1NciaFbPlSZFSBqTaZigZzl8uypSJZwvP44OylsV+tjXt1Sx9Fjw8YwvD9kR5D FU0Bw+ISuS7pdlT6aFVBpuzFk180YnWvhiJ2YrMkMzP+a1bHH7rMPO/o4HbwqxccVYYL 7eZs2jvml/iWeDd8NxIz+eNV7wRreipg8WyaSjt91pFJsOg3eYDZf9RvcTb0YADhRqYU /CfTavVAE8AcRqyFKMba5ynN8afVh+CtEA+HY1U6fbEEYKX0Kqfc/VBIlGtApSwfl1G7 TmmPpEzIUa30VyHsDDs4dh44VV4QlF4Ha67Dj0Rd7+vaQ2toaCkeDlrrZxqtJrQaCx1u gO9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S+UZv5qj; 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 s70si1939064oos.6.2020.03.25.12.59.44; Wed, 25 Mar 2020 12:59:57 -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=S+UZv5qj; 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 S1727634AbgCYT7F (ORCPT + 99 others); Wed, 25 Mar 2020 15:59:05 -0400 Received: from mail-pl1-f178.google.com ([209.85.214.178]:33276 "EHLO mail-pl1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727328AbgCYT7E (ORCPT ); Wed, 25 Mar 2020 15:59:04 -0400 Received: by mail-pl1-f178.google.com with SMTP id g18so1241243plq.0; Wed, 25 Mar 2020 12:59:03 -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=qpxlNK60H7+56apDr31XbwcBVUW8ZgAgiNsYAJEsVhQ=; b=S+UZv5qj2eQ7MnsV++kaiJRR2Vsaioq4+KIPpCccXyn4gAsgXXgqR0egaYuN+MRNEs +ml/o1hQt7GHJnAVhJQgrFMxz/pYonH9L3KUj/PbPnGX9iebuB4Ppe/GsQghrX8x7kXc FvNUbdY+DPpJOSigATiZoHnbQiObMOvVrOV3aZEK8fp1TJqdzTqkWRMtUH0czvv6PyvR e1CE0SWGjIwkQJ2fdjoHco8sbREdsKLhTF5qWUzRLJbMv1dmJOvvcqkLa7LtO7qGM3Ej mqKg9JE8fPfzEgbfkQ9Cl+2xrsZzVjCgLaoRGhezir80oPWeRlEGZCEQQ9yA1HHqsBFr ZKYw== 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=qpxlNK60H7+56apDr31XbwcBVUW8ZgAgiNsYAJEsVhQ=; b=Vz3iEbzURE+4W/m9Jglyp1HjwbuULrdeZtj1jNU2AI6yNuaKfinsG/X9/NyRinjcTO v9JrUeXJff9iPbY7qgRA6z2azARuvKQcL+Virba/BCHRWRKVvAznIxXVyNOTbM2y6CdP hco6L6CIU+W0V1vThvyxq2MJ0XM+3G5dt+fB+ytTv0en2GlduZTp/z7iIbYiVHohXC+j VzOY+BGT8Q4vbPNqcOAiW1UOuBuBoEn5a/FrzZvZHUkTZD6d5h/v3D06d7O5R+A+Eyhl d3+3530JvPGSdrXLgsNTkqoif3dEqcWswwmSUptLDvZ2au7OqmUW4FyM7PXgQHp1YLZ+ 0lbA== X-Gm-Message-State: ANhLgQ1Fm0XL1+USL+rmbDOkpJpnMPPK1SPOIPdTScwSEjYlI6midITX E+nXxpkHdZsU3PCHl9s8RaE= X-Received: by 2002:a17:902:8542:: with SMTP id d2mr4879808plo.200.1585166343101; Wed, 25 Mar 2020 12:59:03 -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 d7sm19341374pfr.17.2020.03.25.12.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 12:59:02 -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 Subject: [PATCH v3 5/8] usr: add support for zstd compressed initramfs Date: Wed, 25 Mar 2020 12:58:46 -0700 Message-Id: <20200325195849.407900-6-nickrterrell@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200325195849.407900-1-nickrterrell@gmail.com> References: <20200325195849.407900-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. 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.25.1