Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp13375pxb; Tue, 9 Mar 2021 14:18:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJytad6bmbpMlyWICCWC13klSDsm4nqDSrrHzNS1IkgCsznLGMXZVJKvcNisCprNPj5ihYNT X-Received: by 2002:a17:906:8147:: with SMTP id z7mr247701ejw.436.1615328314885; Tue, 09 Mar 2021 14:18:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615328314; cv=none; d=google.com; s=arc-20160816; b=BdDn2c2LkZhx/NTElDztoW8h2NtZwijOm+VXoalRNHDMI1bj3Adm96mYFHvlY2DSOi rqTLC2wBIXC6CahE5efJQjmQM2plxGQrryUUCMqtUf/CX8858L4cczeAqt3RS7cyYTnd Yju/wHt8b4WmvciZpPgzw/7RsRHQp+lGm58LZUT0d78+EDTkTJ8CkSmOe256cuu8Zwg6 jJocdOk+/dz8REHhLODTRcZQi41qBUhwTa8O4rXd87zjqq+kdpvwdsNZhVRjdSGP2grO CJngd0a5JdwI63qumiFf8b62MRb3rn3MuWXW9aDWOF2aMKpsudNqueJyJozFn9cz6j7X SOXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sTpm9iCrhHx5qhHqqdwnHB9UkiKkjNMhFzqoJDcE6mw=; b=qPZR8/RHxkbsOlE7g7BcPc+bvC+5zSMxDZZd/4RW9fAowgAsmqWeKx71mYeqfOjekv 0pKOMPf6AcGFkVbwuDFyMcBtse+XDmXLbf/UATxDGnzJGnIGaRUs3iJAHudnCJaw6m85 PodgII0DF1R7mqev1FGSALP2sqBbjmG1Wowq307B4oU6G+QbnSline72LBeci9SbMb0o t/s+/A/GorOfPfLUBgcJXtsD7t5/CpP5b2TkwqbuVtk/nTQXV5FApagiewc6BD8tIXI3 kMYIveZdCUZjxNhBMCfSAzZYJofP2rWn3Sk8vSLooapNYKOV3a8RWBGVRuAE3FxoNSUe vwTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="UuQvh/U/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si10600322edx.470.2021.03.09.14.18.11; Tue, 09 Mar 2021 14:18:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="UuQvh/U/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbhCIWRK (ORCPT + 99 others); Tue, 9 Mar 2021 17:17:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbhCIWQy (ORCPT ); Tue, 9 Mar 2021 17:16:54 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC012C06174A for ; Tue, 9 Mar 2021 14:16:53 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id e20so3818995ljn.6 for ; Tue, 09 Mar 2021 14:16:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sTpm9iCrhHx5qhHqqdwnHB9UkiKkjNMhFzqoJDcE6mw=; b=UuQvh/U/otoDbmtBPbgzKFcO/S87mNzvoBlapc6yS0OCfhumkCQm92511oZsriYF0O DBK/6dpSK3wVNLOZdHPuucypwYmOq7kahceyEJNCD9cIihTYIociel7zlwRFD6jFDXFP jWZ3YT+RgICuBw3LiaBZboHHqsFx+3Cisx13g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sTpm9iCrhHx5qhHqqdwnHB9UkiKkjNMhFzqoJDcE6mw=; b=KmBAGyaYkyZU6N4iqhANcffzm13rWeuMhUghwWh8S6c/E4u1z5tDZWn9sTYovKJfYo Cl4zUHgJSl+iPUZAOHf6C3HXe1qPG8ohJTpEizxHWxQAnqLwnAUGT34LwLIMVNa1W6gG 6dIqkXO8JAaPBDZNE1wcaDlEznckmsSxUsjzGDr+Wo8Pbm8o/5nonmzxx6t8Ek4I8GBF 5IPwVcZPhkZqTZah0sO93yE7oPYbF0uDng7c7zmSs5ApEodufGMk1WvMiHoSlrdZItqd l8yURfFjwk6Vl3yf9evMNtbBd1ZAf/dlOTrrw9rLI/uT2dB/jMa0fAnCiIwWduuQn3Kc hTuQ== X-Gm-Message-State: AOAM531JCUrr8023/kvZPlVMeZcd2e+WOI1T8z4ezltgXpWfV4yJd0Im V6ek04RatlAYkImVmKrAfkG9hrBOZ7Mtyg== X-Received: by 2002:a2e:968c:: with SMTP id q12mr17764932lji.317.1615328211942; Tue, 09 Mar 2021 14:16:51 -0800 (PST) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id m16sm2208293lfh.109.2021.03.09.14.16.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 14:16:51 -0800 (PST) Received: by mail-lf1-f51.google.com with SMTP id q25so29917708lfc.8 for ; Tue, 09 Mar 2021 14:16:51 -0800 (PST) X-Received: by 2002:a05:6512:33cc:: with SMTP id d12mr75176lfg.487.1615328210832; Tue, 09 Mar 2021 14:16:50 -0800 (PST) MIME-Version: 1.0 References: <20210224142909.2092914-1-linux@rasmusvillemoes.dk> <20210309211700.2011017-1-linux@rasmusvillemoes.dk> <20210309211700.2011017-2-linux@rasmusvillemoes.dk> In-Reply-To: <20210309211700.2011017-2-linux@rasmusvillemoes.dk> From: Linus Torvalds Date: Tue, 9 Mar 2021 14:16:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] init/initramfs.c: allow asynchronous unpacking To: Rasmus Villemoes Cc: Luis Chamberlain , Andrew Morton , Jessica Yu , Borislav Petkov , Jonathan Corbet , Greg Kroah-Hartman , Linux Kernel Mailing List , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 9, 2021 at 1:17 PM Rasmus Villemoes wrote: > > So add an initramfs_async= kernel parameter, allowing the main init > process to proceed to handling device_initcall()s without waiting for > populate_rootfs() to finish. Oh, and a completely unrelated second comment about this: some of the initramfs population code seems to be actively written to be slow. For example, I'm not sure why that write_buffer() function uses an array of indirect function pointer actions. Even ignoring the whole "speculation protections make that really slow" issue that came later, it seems to always have been actively (a) slower and (b) more complex. The normal way to do that is with a simple switch() statement, which makes the compiler able to do a much better job. Not just for the state selector - maybe it picks that function pointer approach, but probably these days just direct comparisons - but simply to do things like inline all those "it's used in one place" cases entirely. In fact, at that point, a lot of the state machine changes may end up turning into pure goto's - compilers are sometimes good at that (because state machines have often been very timing-critical). Is that likely to be a big part of the costs? No. I assume it's the decompression and the actual VFS operations. But when the series is about how this all takes a long time, and I go "that code really looks actively pessimally written", maybe it would be a good thing to look into it? Linus