git: 88a55912032a - main - config_intrhook: Move from TAILQ to STAILQ and padding

Warner Losh imp at FreeBSD.org
Mon Mar 8 23:01:39 UTC 2021


The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=88a55912032a981bfdb62d340cab058188dd1dc2

commit 88a55912032a981bfdb62d340cab058188dd1dc2
Author:     Warner Losh <imp at FreeBSD.org>
AuthorDate: 2021-03-08 21:41:37 +0000
Commit:     Warner Losh <imp at FreeBSD.org>
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;
 };


More information about the dev-commits-src-main mailing list