Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3643950pxf; Mon, 15 Mar 2021 14:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1WyHIHqZjcMJiyZzMYPj4oldYz3u4E4ftv004udXjgxtj5RsFjQ5bIuuwmvXj9f77q7UH X-Received: by 2002:aa7:c709:: with SMTP id i9mr32472241edq.319.1615844930405; Mon, 15 Mar 2021 14:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615844930; cv=none; d=google.com; s=arc-20160816; b=i4Wtm1KfzLcY5I4rO8S4V/1F7wiE8c/FAeAC1pXgqPCTULP9ixdgaO4VZmATVZszRd aYyEt74csxygIhPL/bfLrUKsoEScYBXUFaPf5pyJqFBecIWdD3Obr1NvH+m8TBZJIfTo IDA3o78whYwZszt/R2z0meVFz5aZtacS6fy02Ajw6zEiDPi8q9adGNoN01fyIvo75CNg V04WrTxtqadyNGIJjoD46VQ3S4tfF+3ydbfVauGpaYflrapad7QA/oJ464OJnAcOsR1Z wPbE8GVlZL9Look8K01i0wgMo6QgiKDZEPzN7D37kE6VtKD9tKztI5hzlTYtQd/WUcL/ DopA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=tE3KW+4aBQn+aDjatnRbs367+dzc11McNltTJfv0RjI=; b=osoLm/k7q5sx4fr+QiaGxRJj5uu9AQX9wzg94zOEDYxmSr41/+COVDQF8dD8/EXp2G fye1CdjI4CV3trYLcSEkh4Juo5hI4cP6tc+sMTQecc8nq5rdAyngNmmH5ckefi710NQO 9ILbcogDOVUB9oDShSmBU3lHd4GwGM8/3AX5Erl4d7n2+zDcKF3opuVsS5nmDXJL+gRn gkfUCaghoa4KtTgH2+E+f8YBj+1c2AeAspWfdmtcrrLmG1mhiqxXFMSEgrlNQ5yMhdxG yPObpvAp0VLbbAeaULPijVtULcsVkt4Clfi2aJfA4YhE2FNnFHL890oDE9gqUlWqcNt9 MMeA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si11488012edc.377.2021.03.15.14.48.27; Mon, 15 Mar 2021 14:48:50 -0700 (PDT) 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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233186AbhCOUVS (ORCPT + 99 others); Mon, 15 Mar 2021 16:21:18 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:38423 "EHLO mail-pj1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232128AbhCOUVL (ORCPT ); Mon, 15 Mar 2021 16:21:11 -0400 Received: by mail-pj1-f41.google.com with SMTP id k23-20020a17090a5917b02901043e35ad4aso108287pji.3 for ; Mon, 15 Mar 2021 13:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tE3KW+4aBQn+aDjatnRbs367+dzc11McNltTJfv0RjI=; b=dNrnIybLaP8lmWpfHI7Loci7ZIXZ9/waCiqlmCpYg7laxy6dJeAZ2ME7uZfJ+dH8Ah cyFss98Y57Gabjebn/nW4bsTtS/Gr7YXWTTKBhGp3tyWHCwZmam6ykfvLt0OmNVYAIny N8DWUPdSOCQB6qrTUS1mPOQ+p9BfMHPe1nHHB2KDIQ6RnJHLX8oWKX1xhWXFZBgHyNnA nol7Nmf922Gf13pvqJyZ56cmQIlCAqIULTr4ZV/mG8FPRuGLx/8RQZVh/FLvzZDFoj6a pbpm93WLwTaGMxiLisvf1lsKWcnRs6vYa0G4hA2sW0AXo+4OpmrzDAMuihjmJoGPFL64 SwPw== X-Gm-Message-State: AOAM533pyPffzMU+xhfJRhyMi0ZKbikuKRxJKP24oi+JxBNUzW0G3OXS GUhkdSDIvMNWjeBaggGn57A= X-Received: by 2002:a17:902:da91:b029:e5:e7cf:d737 with SMTP id j17-20020a170902da91b02900e5e7cfd737mr13065274plx.24.1615839671382; Mon, 15 Mar 2021 13:21:11 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id h14sm472557pjc.37.2021.03.15.13.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 13:21:10 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 558FA40106; Mon, 15 Mar 2021 20:21:09 +0000 (UTC) Date: Mon, 15 Mar 2021 20:21:09 +0000 From: Luis Chamberlain To: Rasmus Villemoes Cc: Linus Torvalds , Andrew Morton , Jessica Yu , Borislav Petkov , Jonathan Corbet , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Nick Desaulniers , Takashi Iwai Subject: Re: [PATCH v3 1/2] init/initramfs.c: do unpacking asynchronously Message-ID: <20210315202109.GY4332@42.do-not-panic.com> References: <20210313212528.2956377-1-linux@rasmusvillemoes.dk> <20210313212528.2956377-2-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210313212528.2956377-2-linux@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 13, 2021 at 10:25:27PM +0100, Rasmus Villemoes wrote: > Most of the boot process doesn't actually need anything from the > initramfs, until of course PID1 is to be executed. So instead of doing > the decompressing and populating of the initramfs synchronously in > populate_rootfs() itself, push that off to a worker thread. > > This is primarily motivated by an embedded ppc target, where unpacking > even the rather modest sized initramfs takes 0.6 seconds, which is > long enough that the external watchdog becomes unhappy that it doesn't > get attention soon enough. By doing the initramfs decompression in a > worker thread, we get to do the device_initcalls and hence start > petting the watchdog much sooner. > > Normal desktops might benefit as well. On my mostly stock Ubuntu > kernel, my initramfs is a 26M xz-compressed blob, decompressing to > around 126M. That takes almost two seconds: > > [ 0.201454] Trying to unpack rootfs image as initramfs... > [ 1.976633] Freeing initrd memory: 29416K > > Before this patch, these lines occur consecutively in dmesg. With this > patch, the timestamps on these two lines is roughly the same as above, > but with 172 lines inbetween - so more than one cpu has been kept busy > doing work that would otherwise only happen after the > populate_rootfs() finished. > > Should one of the initcalls done after rootfs_initcall time (i.e., > device_ and late_ initcalls) need something from the initramfs (say, a > kernel module or a firmware blob), it will simply wait for the > initramfs unpacking to be done before proceeding, which should in > theory make this completely safe. > > But if some driver pokes around in the filesystem directly and not via > one of the official kernel interfaces (i.e. request_firmware*(), > call_usermodehelper*) that theory may not hold - also, I certainly > might have missed a spot when sprinkling wait_for_initramfs(). So > there is an escape hatch in the form of an initramfs_async= command > line parameter. > > Signed-off-by: Rasmus Villemoes Reviewed-by: Luis Chamberlain Luis