Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp527299rdg; Thu, 12 Oct 2023 12:33:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgrNx2U9Y+80wvrUmEfOekWlAHD3P6XWA+BnFZEyAuT1DlQh72wpgTTCxZhtfXZU6CHIN3 X-Received: by 2002:a05:6358:5910:b0:143:8020:b09a with SMTP id g16-20020a056358591000b001438020b09amr28936329rwf.3.1697139209495; Thu, 12 Oct 2023 12:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139209; cv=none; d=google.com; s=arc-20160816; b=v2ZFJ3iAg2d4uxfavRgP1yRJhrxo0N81u50ypquhQO55tshv0U8y7khOSsSFSxH28z eMew+QGCxF2Jzo6HYaFrh+5NnzhuuruPhi6//rt/BlZymls7Bcuiy0T6EvbF5m0afrHB xKtggrjDSpaNPeQGkUxSHnXYu74TYHoLoIoVdjBAmBYDZtXR5H/BBtEMUgv5GP+fGp1d b2uqXCruoFvQRyFHhc+hxzx3ZVQ2jhH+RCxOjHHM45ay12svEiXsRLSX7Mm3ac6cUx94 jUZgMmLHyXHE3TcYdDbt7qcHLjN9n7Qrt/Xhkk3hpS2KbUBDCrK5KE9LlEDXemdex5xP J6gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3hZLTWKMgSY+Aef2IIyKmAN2EXP4Mq1oaUviZB3Ayw0=; fh=uTC3Tr1qgIvDEbO1Ug2Y2SBEbzCdyyyxTcDtA/fX764=; b=iXx4HnNdShk9GcWPrD/cJNS5PRN1Qn1p3o1whyhJDJZraMEss29fXSpKiuVZm3ZuWX N3kvw8GpXmeOrO8mwbX3h1yxyHEpa5A0MVZm+aHqAAC7s6z2DV4Yx8EAEZtaxadCzFsd XBPbW1SAFdFt5UabgZGcJfr9iDEWwwNnIu1dV7C88ViaH2YbbyjIK9OyOc6Bxrt2PJvn mPPFPVHxadvYn9sTCgCCtANV2tKB4SWiWRVBBZO3EFLY235+XvJzakc3A0/WeityUg4x cd9hjV1owbcu7r07P4uxFKxdoqxgqGm3lNX0X9Oj2YPxK0RjOaSnFNUr1ou+PxU2SIWf FoVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cipYbJQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cw27-20020a056a00451b00b0068e47f1fc7esi14881687pfb.159.2023.10.12.12.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:33:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cipYbJQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 56EFC828818F; Thu, 12 Oct 2023 12:33:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442700AbjJLTdV (ORCPT + 99 others); Thu, 12 Oct 2023 15:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442337AbjJLTcl (ORCPT ); Thu, 12 Oct 2023 15:32:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D2AE8 for ; Thu, 12 Oct 2023 12:32:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24327C43397; Thu, 12 Oct 2023 19:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697139156; bh=KULVDp/cUEx8aH2osEFULKgecu24MXP+d5KfOrr3QgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cipYbJQaj3jI1DJLuZVcGo1v4YYpnPYIBiBmsKP8DyylySViJ3hvfzUTgCfmTZNEe f5A1fnFeSzRbU01kZp5n4bgp/2zsro6ZZVbVPNBk7H6l83S9279KTBjLhcb6aP2u0E NmC3ciRcvALV+bYfWEMa2qQiaTRfHKsHy4uR/Fn8TS1axZhdVv4ybIvzjLrtFt1lQI iBunSGuJighPdbj/6ZGlAtMRng1iQKUw5OozDef5RCOPnWsfi3XyZDJF4jDylj9bMA IGzUWxPNvm/jgrlv4xT6U3YZwj44n9UmACvDf4K5T0ijSVAY7qpmp4FKUl0IY3OO9p 7vz7OdgX58ZJA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 57069CE0CB3; Thu, 12 Oct 2023 12:32:35 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Nicolas Schier Subject: [PATCH nolibc 11/19] selftests/nolibc: don't embed initramfs into kernel image Date: Thu, 12 Oct 2023 12:32:25 -0700 Message-Id: <20231012193233.207857-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 12:33:28 -0700 (PDT) From: Thomas Weißschuh When the initramfs is embedded into the kernel each rebuild of it will trigger a full kernel relink and all the expensive postprocessing steps. Currently nolibc-test and therefore the initramfs are always rebuild, even without source changes, leading to lots of slow kernel relinks. Instead of linking the initramfs into the kernel assemble it manually and pass it explicitly to qemu. This avoids all of the kernel relinks. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20230917-nolibc-initramfs-v2-1-f0f293a8b198@weissschuh.net --- tools/testing/selftests/nolibc/.gitignore | 1 + tools/testing/selftests/nolibc/Makefile | 42 ++++++++++++++--------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/nolibc/.gitignore b/tools/testing/selftests/nolibc/.gitignore index 52f613cdad54..5119f9f7afd2 100644 --- a/tools/testing/selftests/nolibc/.gitignore +++ b/tools/testing/selftests/nolibc/.gitignore @@ -1,4 +1,5 @@ /initramfs/ +/initramfs.cpio /libc-test /nolibc-test /run.out diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 689658f81a19..ee6a9ad28cfd 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -131,18 +131,20 @@ REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++ help: @echo "Supported targets under selftests/nolibc:" - @echo " all call the \"run\" target below" - @echo " help this help" - @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" - @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPILE)" - @echo " libc-test build an executable using the compiler's default libc instead" - @echo " run-user runs the executable under QEMU (uses \$$XARCH, \$$TEST)" - @echo " initramfs prepare the initramfs with nolibc-test" - @echo " defconfig create a fresh new default config (uses \$$XARCH)" - @echo " kernel (re)build the kernel with the initramfs (uses \$$XARCH)" - @echo " run runs the kernel in QEMU after building it (uses \$$XARCH, \$$TEST)" - @echo " rerun runs a previously prebuilt kernel in QEMU (uses \$$XARCH, \$$TEST)" - @echo " clean clean the sysroot, initramfs, build and output files" + @echo " all call the \"run\" target below" + @echo " help this help" + @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" + @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPILE)" + @echo " libc-test build an executable using the compiler's default libc instead" + @echo " run-user runs the executable under QEMU (uses \$$XARCH, \$$TEST)" + @echo " initramfs.cpio prepare the initramfs archive with nolibc-test" + @echo " initramfs prepare the initramfs tree with nolibc-test" + @echo " defconfig create a fresh new default config (uses \$$XARCH)" + @echo " kernel (re)build the kernel (uses \$$XARCH)" + @echo " kernel-standalone (re)build the kernel with the initramfs (uses \$$XARCH)" + @echo " run runs the kernel in QEMU after building it (uses \$$XARCH, \$$TEST)" + @echo " rerun runs a previously prebuilt kernel in QEMU (uses \$$XARCH, \$$TEST)" + @echo " clean clean the sysroot, initramfs, build and output files" @echo "" @echo "The output file is \"run.out\". Test ranges may be passed using \$$TEST." @echo "" @@ -195,6 +197,9 @@ run-user: nolibc-test $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : $(Q)$(REPORT) $(CURDIR)/run.out +initramfs.cpio: kernel nolibc-test + $(QUIET_GEN)echo 'file /init nolibc-test 755 0 0' | $(srctree)/usr/gen_init_cpio - > initramfs.cpio + initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs $(call QUIET_INSTALL, initramfs/init) @@ -203,17 +208,20 @@ initramfs: nolibc-test defconfig: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare -kernel: initramfs +kernel: + $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) + +kernel-standalone: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs # run the tests after building the kernel -run: kernel - $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" +run: kernel initramfs.cpio + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out # re-run the tests from an existing kernel rerun: - $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out # report with existing test log @@ -227,6 +235,8 @@ clean: $(Q)rm -f nolibc-test $(call QUIET_CLEAN, libc-test) $(Q)rm -f libc-test + $(call QUIET_CLEAN, initramfs.cpio) + $(Q)rm -rf initramfs.cpio $(call QUIET_CLEAN, initramfs) $(Q)rm -rf initramfs $(call QUIET_CLEAN, run.out) -- 2.40.1