From owner-dev-commits-src-all@freebsd.org Mon Mar 8 23:01:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B492255C9A5; Mon, 8 Mar 2021 23:01:39 +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 4DvYkC4n9cz3vqq; Mon, 8 Mar 2021 23:01:39 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9795E114FB; Mon, 8 Mar 2021 23:01:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 128N1dm6078407; Mon, 8 Mar 2021 23:01:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 128N1d79078406; Mon, 8 Mar 2021 23:01:39 GMT (envelope-from git) Date: Mon, 8 Mar 2021 23:01:39 GMT Message-Id: <202103082301.128N1d79078406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 88a55912032a - main - config_intrhook: Move from TAILQ to STAILQ and padding MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 88a55912032a981bfdb62d340cab058188dd1dc2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 23:01:39 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=88a55912032a981bfdb62d340cab058188dd1dc2 commit 88a55912032a981bfdb62d340cab058188dd1dc2 Author: Warner Losh AuthorDate: 2021-03-08 21:41:37 +0000 Commit: Warner Losh CommitDate: 2021-03-08 22:59:00 +0000 config_intrhook: Move from TAILQ to STAILQ and padding config_intrhook doesn't need to be a two-pointer TAILQ. We rarely add/delete from this and so those need not be optimized. Instaed, use the one-pointer STAILQ plus a uintptr_t to be used as a flags word. This will allow these changes to be MFC'd to 12 and 13 to fix a race in removable devices. Feedback from: jhb Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D29004 --- sys/kern/subr_autoconf.c | 22 +++++++++++----------- sys/sys/kernel.h | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 6a998a533801..063396a8e139 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -56,8 +56,8 @@ __FBSDID("$FreeBSD$"); /* * "Interrupt driven config" functions. */ -static TAILQ_HEAD(, intr_config_hook) intr_config_hook_list = - TAILQ_HEAD_INITIALIZER(intr_config_hook_list); +static STAILQ_HEAD(, intr_config_hook) intr_config_hook_list = + STAILQ_HEAD_INITIALIZER(intr_config_hook_list); static struct intr_config_hook *next_to_notify; static struct mtx intr_config_hook_lock; MTX_SYSINIT(intr_config_hook, &intr_config_hook_lock, "intr config", MTX_DEF); @@ -101,7 +101,7 @@ run_interrupt_driven_config_hooks_warning(int warned) if (warned < 6) { printf("run_interrupt_driven_hooks: still waiting after %d " "seconds for", warned * WARNING_INTERVAL_SECS); - TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) { + STAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) { if (linker_search_symbol_name( (caddr_t)hook_entry->ich_func, namebuf, sizeof(namebuf), &offset) == 0) @@ -137,7 +137,7 @@ run_interrupt_driven_config_hooks() while (next_to_notify != NULL) { hook_entry = next_to_notify; - next_to_notify = TAILQ_NEXT(hook_entry, ich_links); + next_to_notify = STAILQ_NEXT(hook_entry, ich_links); mtx_unlock(&intr_config_hook_lock); (*hook_entry->ich_func)(hook_entry->ich_arg); mtx_lock(&intr_config_hook_lock); @@ -158,7 +158,7 @@ boot_run_interrupt_driven_config_hooks(void *dummy) TSWAIT("config hooks"); mtx_lock(&intr_config_hook_lock); warned = 0; - while (!TAILQ_EMPTY(&intr_config_hook_list)) { + while (!STAILQ_EMPTY(&intr_config_hook_list)) { if (msleep(&intr_config_hook_list, &intr_config_hook_lock, 0, "conifhk", WARNING_INTERVAL_SECS * hz) == EWOULDBLOCK) { @@ -187,7 +187,7 @@ config_intrhook_establish(struct intr_config_hook *hook) TSHOLD("config hooks"); mtx_lock(&intr_config_hook_lock); - TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) + STAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) if (hook_entry == hook) break; if (hook_entry != NULL) { @@ -196,7 +196,7 @@ config_intrhook_establish(struct intr_config_hook *hook) "already established hook.\n"); return (1); } - TAILQ_INSERT_TAIL(&intr_config_hook_list, hook, ich_links); + STAILQ_INSERT_TAIL(&intr_config_hook_list, hook, ich_links); if (next_to_notify == NULL) next_to_notify = hook; mtx_unlock(&intr_config_hook_lock); @@ -232,7 +232,7 @@ config_intrhook_disestablish(struct intr_config_hook *hook) struct intr_config_hook *hook_entry; mtx_lock(&intr_config_hook_lock); - TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) + STAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) if (hook_entry == hook) break; if (hook_entry == NULL) @@ -240,8 +240,8 @@ config_intrhook_disestablish(struct intr_config_hook *hook) "unestablished hook"); if (next_to_notify == hook) - next_to_notify = TAILQ_NEXT(hook, ich_links); - TAILQ_REMOVE(&intr_config_hook_list, hook, ich_links); + next_to_notify = STAILQ_NEXT(hook, ich_links); + STAILQ_REMOVE(&intr_config_hook_list, hook, intr_config_hook, ich_links); TSRELEASE("config hooks"); /* Wakeup anyone watching the list */ @@ -258,7 +258,7 @@ DB_SHOW_COMMAND(conifhk, db_show_conifhk) char namebuf[64]; long offset; - TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) { + STAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) { if (linker_ddb_search_symbol_name( (caddr_t)hook_entry->ich_func, namebuf, sizeof(namebuf), &offset) == 0) { diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 181036c98a6a..89582ca5403d 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -466,7 +466,8 @@ struct tunable_str { typedef void (*ich_func_t)(void *_arg); struct intr_config_hook { - TAILQ_ENTRY(intr_config_hook) ich_links; + STAILQ_ENTRY(intr_config_hook) ich_links; + uintptr_t ich_padding; ich_func_t ich_func; void *ich_arg; };