From nobody Wed Sep 13 20:03:45 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 4RmBGn5HVSz4tFpG; Wed, 13 Sep 2023 20:03:45 +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 4RmBGn3s5hz3N89; Wed, 13 Sep 2023 20:03:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694635425; 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=PsRqOmI2cdpWl9Nevr4kAXiSE1cROKcdo6DlTasWrdY=; b=pv5SIsPbmCeCOnaE5AKkaG5Dxy54MSuePCcmtq9kDJsA+xu465wiqAL66hJJQ85tzaHnWN o/2+J3M0bz5lDvXcFCd1E/DRR1yqm8B/GeJjMvDLFinhVwb0zuKPHzPQVGvQcPIpjipU0m fkLIz3V1sUDhabvvg3YSWMBi/arYUNp/TMqph3uRmu2CHaFwxaD6QuOFJAxfoMu7+r2GnP 4TDSMehBlxVdFP7GkM3rrTVcaOaF+kJbCD1JdIQviRBFcr7cgLoAn7dUSIKhUnG+02WHtt p1GMkLS5iAF94tRCMW6Y833C73/fhMo0d/nWeH7UbNNM/aLYvN4cvgmTdvDoTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694635425; a=rsa-sha256; cv=none; b=YhBETKV+fXTz8qJnV14X7Ay9bF/q6N8hgYq1QChkch6/jPo4ROAMXsdkiZ28D/M38kWJMc DfSvIld8wu6VwF6taTxd3lTpy6MP/WEPKiKEn9XXuA5OAhQBtczDNXGBJiItXvWmA7tC1x 4t81gk4lC120VLt7oSphOZLJ2rUdmy9LoNL5wmR4rx5tNBwEghKsI8E3jUH1rjmdAbckFv 7iYjCf4mDOga6ohWj2hzO34tnnnPHH7zND6sSjtSB5KHrStceo15NRE+orvMuqqcPozW9o omRhP9ZyQ+Xse4PwLuhEJQXA1Sbvw8KgzehTFnCOx7SDdxMAggGaUFwhvCw+dA== 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=1694635425; 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=PsRqOmI2cdpWl9Nevr4kAXiSE1cROKcdo6DlTasWrdY=; b=EEK0WOXFLSHWP5N6yPBnAOTQ6cAvgzNeH7hd85HJsxLKbiD08XcLzXpFgI/GbcofnFqAcC YLly5gtb0jDTFgBjWB6m6PciWisdGHxLliPJ5VRYzGfG62H/KEwdED/QFonc+ePoOomPoV GQybLU/YSXUxEqqcKqty8As/PoZ8yo3DwPq7b45ypYTkyj/S4JkFG5Ww1Dr6zZgGnwop+h zxm/crtq5gvVXjNF0j0q+p4ioKFoAanKB04kXYlbQvCWO4U/dQoFJgHg06WWXxT2+0Y2UC 5uPzo9oEwEXfvB7UlUF7tYEjtK513tUOGXhTQYlSkQwfj7KpMRLXniAIpjSlxQ== 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 4RmBGn2dsJzCfP; Wed, 13 Sep 2023 20:03:45 +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 38DK3jiN096959; Wed, 13 Sep 2023 20:03:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38DK3j1q096956; Wed, 13 Sep 2023 20:03:45 GMT (envelope-from git) Date: Wed, 13 Sep 2023 20:03:45 GMT Message-Id: <202309132003.38DK3j1q096956@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: 3a9ca394c0c9 - releng/14.0 - 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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 3a9ca394c0c9b2a3deb43910d05982495ef8e491 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=3a9ca394c0c9b2a3deb43910d05982495ef8e491 commit 3a9ca394c0c9b2a3deb43910d05982495ef8e491 Author: Colin Percival AuthorDate: 2023-09-05 23:46:38 +0000 Commit: Colin Percival CommitDate: 2023-09-13 20:03:09 +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 Approved by: re (gjb) Tested by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41748 (cherry picked from commit 71679cf468ba28c0e3c88371f3fde13fccec99bd) (cherry picked from commit 144db6a1c9fe8bd0bf19aee1d427ad9ceaf292ce) --- 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 */ };