Commit 88a55912 authored by Warner Losh's avatar Warner Losh
Browse files

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
parent 7634919e
......@@ -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) {
......
......@@ -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;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment