summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/os/freebsd/spl/sys/proc.h9
-rw-r--r--include/os/linux/spl/sys/thread.h5
-rw-r--r--include/sys/zfs_context.h3
-rw-r--r--include/sys/zthr.h9
-rw-r--r--module/zfs/arc.c8
-rw-r--r--module/zfs/spa.c12
-rw-r--r--module/zfs/vdev_indirect.c3
-rw-r--r--module/zfs/zthr.c17
8 files changed, 43 insertions, 23 deletions
diff --git a/include/os/freebsd/spl/sys/proc.h b/include/os/freebsd/spl/sys/proc.h
index fdb2126d6..e52d37593 100644
--- a/include/os/freebsd/spl/sys/proc.h
+++ b/include/os/freebsd/spl/sys/proc.h
@@ -65,7 +65,7 @@ extern struct proc *zfsproc;
static __inline kthread_t *
do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg,
- size_t len, proc_t *pp, int state, pri_t pri)
+ size_t len, proc_t *pp, int state, pri_t pri, const char *name)
{
kthread_t *td = NULL;
int error;
@@ -78,7 +78,7 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg,
ASSERT(state == TS_RUN);
error = kproc_kthread_add(proc, arg, &zfsproc, &td,
- RFSTOPPED, stksize / PAGE_SIZE, "zfskern", "solthread %p", proc);
+ RFSTOPPED, stksize / PAGE_SIZE, "zfskern", "%s", name);
if (error == 0) {
thread_lock(td);
sched_prio(td, pri);
@@ -90,8 +90,11 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg,
return (td);
}
+#define thread_create_named(name, stk, stksize, proc, arg, len, \
+ pp, state, pri) \
+ do_thread_create(stk, stksize, proc, arg, len, pp, state, pri, name)
#define thread_create(stk, stksize, proc, arg, len, pp, state, pri) \
- do_thread_create(stk, stksize, proc, arg, len, pp, state, pri)
+ do_thread_create(stk, stksize, proc, arg, len, pp, state, pri, #proc)
#define thread_exit() kthread_exit()
int uread(proc_t *, void *, size_t, uintptr_t);
diff --git a/include/os/linux/spl/sys/thread.h b/include/os/linux/spl/sys/thread.h
index 3762717da..72dcf9f05 100644
--- a/include/os/linux/spl/sys/thread.h
+++ b/include/os/linux/spl/sys/thread.h
@@ -45,6 +45,11 @@
typedef void (*thread_func_t)(void *);
+#define thread_create_named(name, stk, stksize, func, arg, len, \
+ pp, state, pri) \
+ __thread_create(stk, stksize, (thread_func_t)func, \
+ name, arg, len, pp, state, pri)
+
/* BEGIN CSTYLED */
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
__thread_create(stk, stksize, (thread_func_t)func, \
diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h
index ccae941b4..2abdb3e44 100644
--- a/include/sys/zfs_context.h
+++ b/include/sys/zfs_context.h
@@ -218,6 +218,9 @@ typedef pthread_t kthread_t;
#define kpreempt(x) yield()
#define getcomm() "unknown"
+#define thread_create_named(name, stk, stksize, func, arg, len, \
+ pp, state, pri) \
+ zk_thread_create(func, arg, stksize, state)
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
zk_thread_create(func, arg, stksize, state)
#define thread_exit() pthread_exit(NULL)
diff --git a/include/sys/zthr.h b/include/sys/zthr.h
index 0a05f5225..ae8c57e9e 100644
--- a/include/sys/zthr.h
+++ b/include/sys/zthr.h
@@ -24,10 +24,11 @@ typedef struct zthr zthr_t;
typedef void (zthr_func_t)(void *, zthr_t *);
typedef boolean_t (zthr_checkfunc_t)(void *, zthr_t *);
-extern zthr_t *zthr_create(zthr_checkfunc_t checkfunc,
- zthr_func_t *func, void *arg);
-extern zthr_t *zthr_create_timer(zthr_checkfunc_t *checkfunc,
- zthr_func_t *func, void *arg, hrtime_t nano_wait);
+extern zthr_t *zthr_create(const char *zthr_name,
+ zthr_checkfunc_t checkfunc, zthr_func_t *func, void *arg);
+extern zthr_t *zthr_create_timer(const char *zthr_name,
+ zthr_checkfunc_t *checkfunc, zthr_func_t *func, void *arg,
+ hrtime_t nano_wait);
extern void zthr_destroy(zthr_t *t);
extern void zthr_wakeup(zthr_t *t);
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index 785ad9775..9e9227271 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -7339,10 +7339,10 @@ arc_init(void)
kstat_install(arc_ksp);
}
- arc_evict_zthr = zthr_create_timer(arc_evict_cb_check,
- arc_evict_cb, NULL, SEC2NSEC(1));
- arc_reap_zthr = zthr_create_timer(arc_reap_cb_check,
- arc_reap_cb, NULL, SEC2NSEC(1));
+ arc_evict_zthr = zthr_create_timer("arc_evict",
+ arc_evict_cb_check, arc_evict_cb, NULL, SEC2NSEC(1));
+ arc_reap_zthr = zthr_create_timer("arc_reap",
+ arc_reap_cb_check, arc_reap_cb, NULL, SEC2NSEC(1));
arc_warm = B_FALSE;
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 2783e9e29..86e5d0125 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -2548,7 +2548,8 @@ static void
spa_start_livelist_destroy_thread(spa_t *spa)
{
ASSERT3P(spa->spa_livelist_delete_zthr, ==, NULL);
- spa->spa_livelist_delete_zthr = zthr_create(
+ spa->spa_livelist_delete_zthr =
+ zthr_create("z_livelist_destroy",
spa_livelist_delete_cb_check, spa_livelist_delete_cb, spa);
}
@@ -2755,8 +2756,10 @@ spa_start_livelist_condensing_thread(spa_t *spa)
spa->spa_to_condense.cancelled = B_FALSE;
ASSERT3P(spa->spa_livelist_condense_zthr, ==, NULL);
- spa->spa_livelist_condense_zthr = zthr_create(
- spa_livelist_condense_cb_check, spa_livelist_condense_cb, spa);
+ spa->spa_livelist_condense_zthr =
+ zthr_create("z_livelist_condense",
+ spa_livelist_condense_cb_check,
+ spa_livelist_condense_cb, spa);
}
static void
@@ -2772,7 +2775,8 @@ spa_spawn_aux_threads(spa_t *spa)
ASSERT3P(spa->spa_checkpoint_discard_zthr, ==, NULL);
spa->spa_checkpoint_discard_zthr =
- zthr_create(spa_checkpoint_discard_thread_check,
+ zthr_create("z_checkpoint_discard",
+ spa_checkpoint_discard_thread_check,
spa_checkpoint_discard_thread, spa);
}
diff --git a/module/zfs/vdev_indirect.c b/module/zfs/vdev_indirect.c
index ac3e13d37..fc49bad06 100644
--- a/module/zfs/vdev_indirect.c
+++ b/module/zfs/vdev_indirect.c
@@ -884,7 +884,8 @@ void
spa_start_indirect_condensing_thread(spa_t *spa)
{
ASSERT3P(spa->spa_condense_zthr, ==, NULL);
- spa->spa_condense_zthr = zthr_create(spa_condense_indirect_thread_check,
+ spa->spa_condense_zthr = zthr_create("z_indirect_condense",
+ spa_condense_indirect_thread_check,
spa_condense_indirect_thread, spa);
}
diff --git a/module/zfs/zthr.c b/module/zfs/zthr.c
index 53c0a0b3d..fdc4b8633 100644
--- a/module/zfs/zthr.c
+++ b/module/zfs/zthr.c
@@ -14,7 +14,7 @@
*/
/*
- * Copyright (c) 2017, 2019 by Delphix. All rights reserved.
+ * Copyright (c) 2017, 2020 by Delphix. All rights reserved.
*/
/*
@@ -269,9 +269,11 @@ zthr_procedure(void *arg)
}
zthr_t *
-zthr_create(zthr_checkfunc_t *checkfunc, zthr_func_t *func, void *arg)
+zthr_create(const char *zthr_name, zthr_checkfunc_t *checkfunc,
+ zthr_func_t *func, void *arg)
{
- return (zthr_create_timer(checkfunc, func, arg, (hrtime_t)0));
+ return (zthr_create_timer(zthr_name, checkfunc,
+ func, arg, (hrtime_t)0));
}
/*
@@ -280,8 +282,8 @@ zthr_create(zthr_checkfunc_t *checkfunc, zthr_func_t *func, void *arg)
* start working if required) will be triggered.
*/
zthr_t *
-zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_func_t *func,
- void *arg, hrtime_t max_sleep)
+zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc,
+ zthr_func_t *func, void *arg, hrtime_t max_sleep)
{
zthr_t *t = kmem_zalloc(sizeof (*t), KM_SLEEP);
mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL);
@@ -295,8 +297,9 @@ zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_func_t *func,
t->zthr_arg = arg;
t->zthr_sleep_timeout = max_sleep;
- t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t,
- 0, &p0, TS_RUN, minclsyspri);
+ t->zthr_thread = thread_create_named(zthr_name, NULL, 0,
+ zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
+
mutex_exit(&t->zthr_state_lock);
return (t);