From nobody Fri May 19 14:07:04 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QN7vK2jJfz4C0Ss; Fri, 19 May 2023 14:07:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4QN7vJ5fJ5z3mD2; Fri, 19 May 2023 14:07:08 +0000 (UTC) (envelope-from hps@selasky.org) Authentication-Results: mx1.freebsd.org; none Received: from [10.36.2.145] (unknown [46.212.121.255]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 6E12E2623F5; Fri, 19 May 2023 16:07:05 +0200 (CEST) Message-ID: Date: Fri, 19 May 2023 16:07:04 +0200 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: git: 40b287054521 - main - mi_startup: Instrument the bubblesort with TSLOG To: Colin Percival , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202305191349.34JDnp8J060770@gitrepo.freebsd.org> Content-Language: en-US From: Hans Petter Selasky In-Reply-To: <202305191349.34JDnp8J060770@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4QN7vJ5fJ5z3mD2 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/32, country:DE] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 5/19/23 15:49, Colin Percival wrote: > The branch main has been updated by cperciva: > > URL: https://cgit.FreeBSD.org/src/commit/?id=40b287054521f0a92e5ae9a26e6a87d17ee85eea > > commit 40b287054521f0a92e5ae9a26e6a87d17ee85eea > Author: Colin Percival > AuthorDate: 2023-05-19 13:46:42 +0000 > Commit: Colin Percival > CommitDate: 2023-05-19 13:46:42 +0000 > > mi_startup: Instrument the bubblesort with TSLOG > > The bubblesort of SYSINITs is currently responsible for 7% of the > kernel boot time when booting a 1 CPU / 128 MB VM under Firecracker. > > It needs to be replaced with a faster sort, but until that happens > at least instrumenting it with TSLOG makes it show up in flamecharts. > --- > sys/kern/init_main.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c > index 1974c4e68ce4..e4cb501bc57b 100644 > --- a/sys/kern/init_main.c > +++ b/sys/kern/init_main.c > @@ -255,6 +255,7 @@ restart: > * Perform a bubble sort of the system initialization objects by > * their subsystem (primary key) and order (secondary key). > */ > + TSENTER2("bubblesort"); > for (sipp = sysinit; sipp < sysinit_end; sipp++) { > for (xipp = sipp + 1; xipp < sysinit_end; xipp++) { > if ((*sipp)->subsystem < (*xipp)->subsystem || > @@ -266,6 +267,7 @@ restart: > *xipp = save; > } > } > + TSEXIT2("bubblesort"); > > last = SI_SUB_COPYRIGHT; > #if defined(VERBOSE_SYSINIT) > Hi Colin, If all kernel modules and the kernel could sort their SYSINIT() and SYSUNINIT() data at compile time, then all you need to do, is to merge two sorted lists, when loading new modules. Maybe this even could be part of the compiler's existing __constructor attribute. In FreeBSD we have an example of build boot loader modules, and statically sorting all sysinit data at compile time. See the tool I made many years ago for this purpose: stand/usb/tools/sysinit.c What do you think? --HPS