From nobody Wed Sep 06 18:37:03 2023 X-Original-To: dev-commits-src-all@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 4Rgrh023Psz4strt; Wed, 6 Sep 2023 18:37:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rgrh01ccsz4TTV; Wed, 6 Sep 2023 18:37:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694025424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BwTFVic/3s4up7H5vpN4Sl/ES6yt4QvKG8rlSM4weAQ=; b=H+k17A8FHEl0RIF7nmuIuCMtz2VXWus4WLYKAnoVx50TnAO97OxGo1NBFIUjFHe/68Xg5K biociB8Y/oLJelU1jMCeNs8lfp4jZ+g4yvZeRJizd6N/XqT9ql10500yvpiw0vlObgV0E1 eZX1dZwQxRJW/OQbHQRPapoMrp2UZ2XL7YnC+/dO+VyND89PrtKRO6s4tW8hWAJGHruPE2 spYEn91zqD48Wrg0WPUmuTE3fToB7fXzecqmwgaGEFe6EIqS8z0ulCrp5TENGRffJeSzw2 jOkgV+H3NK5q0TanuSmnCgM0cmEohw1layaziJA3aL19D0iMxSS9OccHUWFfaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694025424; a=rsa-sha256; cv=none; b=JLR3qfr/Ao5qC4ZLAXIER5Tid28TahLO/J2kH3JRqgnUwgRySppQIM8izm+XM9nbRWDgX2 M7+UKtipqtwWQBLEOhtFRrOoUolZK/WV0Wu0kqBOD3gbNk4WoJYxgr5JslKHtowZeiAk4p 6FgaPl9s2WG7Yxh1q6akiGmvi9b7tlrgQnAWC33SWHRZjTJzHUxdfCVKGIg7F9V+CBRZEC UzY2jybY/wUTwLtRnt/jmVq33Tlr2lxErOFQJX5pdsyHmdYwtELgBWTjxsdCtlx0iYTXvC ppfK0/UArYgRoGqz/Js/PNwDwbOky6wjJhR1y1FhHe63E7oI85uYuCWt4GVMSA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694025424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BwTFVic/3s4up7H5vpN4Sl/ES6yt4QvKG8rlSM4weAQ=; b=JGxE14JJ6dDeu0u1gjNWwI5194oXNIzOntkz5J/CkLXtTW4qtedGe2mOXcCpYlw0H940K/ /CPHWFVgDO1hyAmJwLQyqWZKI9bxEZWJKcwJ24Au8NGj5nnxbn7LV1W/M+Q7rkSKlJLryg ZsOXq5oTUVK7HEW4QdLPrJ35CRO0stqwMiYQaRK86ZeUgbmZSpQuGihbYtmXZhWW2yzqr2 LJQk3nZR6NI8BwkceLyyc+9zP42xR+PshyX3hfWJfWIb4BbicYW5KCePtAZNUFvDQ0vV6E m9RRI5M+C1S1oeMyuyXgthSZF/+eS5jYuAiMdUgrqg2Cwp3z4MMT/TsvYSwxbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rgrh00QhxzCZt; Wed, 6 Sep 2023 18:37:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 386Ib4bL086221; Wed, 6 Sep 2023 18:37:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386Ib3nL086218; Wed, 6 Sep 2023 18:37:03 GMT (envelope-from git) Date: Wed, 6 Sep 2023 18:37:03 GMT Message-Id: <202309061837.386Ib3nL086218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 71679cf468ba - main - init_main: Switch from SLIST to STAILQ, fix order List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71679cf468ba28c0e3c88371f3fde13fccec99bd Auto-Submitted: auto-generated The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=71679cf468ba28c0e3c88371f3fde13fccec99bd commit 71679cf468ba28c0e3c88371f3fde13fccec99bd Author: Colin Percival AuthorDate: 2023-09-05 23:46:38 +0000 Commit: Colin Percival CommitDate: 2023-09-06 18:36:36 +0000 init_main: Switch from SLIST to STAILQ, fix order Constructing an SLIST of SYSINITs by inserting them one by one at the head of the list resulted in them being sorted in anti-stable order: When two SYSINITs tied for (subsystem, order), they were executed in the reverse order to the order in which they appeared in the linker set. Note that while this changes struct sysinit, it doesn't affect ABI since SLIST_ENTRY and STAILQ_ENTRY are compatible (in both cases a single pointer to the next element). Fixes: 9a7add6d01f3 "init_main: Switch from sysinit array to SLIST" Reported by: gallatin Reviewed by: jhb, gallatin, emaste Tested by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41748 --- sys/kern/init_main.c | 22 +++++++++++----------- sys/sys/kernel.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index aa82eafff9b0..a6b327339c80 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -165,7 +165,7 @@ SET_DECLARE(sysinit_set, struct sysinit); /* * The sysinit list itself. Items are removed as they are run. */ -static SLIST_HEAD(sysinitlist, sysinit) sysinit_list; +static STAILQ_HEAD(sysinitlist, sysinit) sysinit_list; /* * Compare two sysinits; return -1, 0, or 1 if a comes before, at the same time @@ -194,12 +194,12 @@ sysinit_mklist(struct sysinitlist *list, struct sysinit **set, TSENTER(); TSENTER2("listify"); - SLIST_INIT(list); + STAILQ_INIT(list); for (sipp = set; sipp < set_end; sipp++) - SLIST_INSERT_HEAD(list, *sipp, next); + STAILQ_INSERT_TAIL(list, *sipp, next); TSEXIT2("listify"); TSENTER2("mergesort"); - SLIST_MERGESORT(list, NULL, sysinit_compar, sysinit, next); + STAILQ_MERGESORT(list, NULL, sysinit_compar, sysinit, next); TSEXIT2("mergesort"); TSEXIT(); } @@ -218,9 +218,9 @@ sysinit_add(struct sysinit **set, struct sysinit **set_end) sysinit_mklist(&new_list, set, set_end); /* Merge the new list into the existing one. */ - TSENTER2("SLIST_MERGE"); - SLIST_MERGE(&sysinit_list, &new_list, NULL, sysinit_compar, sysinit, next); - TSEXIT2("SLIST_MERGE"); + TSENTER2("STAILQ_MERGE"); + STAILQ_MERGE(&sysinit_list, &new_list, NULL, sysinit_compar, sysinit, next); + TSEXIT2("STAILQ_MERGE"); TSEXIT(); } @@ -284,11 +284,11 @@ mi_startup(void) * Perform each system initialization task from the ordered list. Note * that if sysinit_list is modified (e.g. by a KLD) we will nonetheless * always perform the earlist-sorted sysinit at each step; using the - * SLIST_FOREACH macro would result in items being skipped if inserted + * STAILQ_FOREACH macro would result in items being skipped if inserted * earlier than the "current item". */ - while ((sip = SLIST_FIRST(&sysinit_list)) != NULL) { - SLIST_REMOVE_HEAD(&sysinit_list, next); + while ((sip = STAILQ_FIRST(&sysinit_list)) != NULL) { + STAILQ_REMOVE_HEAD(&sysinit_list, next); if (sip->subsystem == SI_SUB_DUMMY) continue; /* skip dummy task(s)*/ @@ -904,7 +904,7 @@ DB_SHOW_COMMAND_FLAGS(sysinit, db_show_sysinit, DB_CMD_MEMSAFE) db_printf("SYSINIT vs Name(Ptr)\n"); db_printf(" Subsystem Order\n"); db_printf(" Function(Name)(Arg)\n"); - SLIST_FOREACH(sip, &sysinit_list, next) { + STAILQ_FOREACH(sip, &sysinit_list, next) { db_show_print_syinit(sip, true); if (db_pager_quit) break; diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 12e346514d1a..62b9e6a02b3c 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -220,7 +220,7 @@ typedef void (*sysinit_cfunc_t)(const void *); struct sysinit { enum sysinit_sub_id subsystem; /* subsystem identifier*/ enum sysinit_elem_order order; /* init order within subsystem*/ - SLIST_ENTRY(sysinit) next; /* singly-linked list */ + STAILQ_ENTRY(sysinit) next; /* singly-linked list */ sysinit_cfunc_t func; /* function */ const void *udata; /* multiplexer/argument */ };