Skip to content

Commit 6bc61d2

Browse files
authored
Run arc_evict thread at higher priority
Run arc_evict thread at higher priority, nice=0, to give it more CPU time which can improve performance for workload with high ARC evict activities. On mixed read/write and sequential read workloads, I've seen between 10-40% better performance. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: George Melikov <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Closes #12397
1 parent f3678d7 commit 6bc61d2

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

include/sys/zthr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ typedef void (zthr_func_t)(void *, zthr_t *);
2525
typedef boolean_t (zthr_checkfunc_t)(void *, zthr_t *);
2626

2727
extern zthr_t *zthr_create(const char *zthr_name,
28-
zthr_checkfunc_t checkfunc, zthr_func_t *func, void *arg);
28+
zthr_checkfunc_t checkfunc, zthr_func_t *func, void *arg,
29+
pri_t pri);
2930
extern zthr_t *zthr_create_timer(const char *zthr_name,
3031
zthr_checkfunc_t *checkfunc, zthr_func_t *func, void *arg,
31-
hrtime_t nano_wait);
32+
hrtime_t nano_wait, pri_t pri);
3233
extern void zthr_destroy(zthr_t *t);
3334

3435
extern void zthr_wakeup(zthr_t *t);

module/zfs/arc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7950,9 +7950,9 @@ arc_init(void)
79507950
}
79517951

79527952
arc_evict_zthr = zthr_create("arc_evict",
7953-
arc_evict_cb_check, arc_evict_cb, NULL);
7953+
arc_evict_cb_check, arc_evict_cb, NULL, defclsyspri);
79547954
arc_reap_zthr = zthr_create_timer("arc_reap",
7955-
arc_reap_cb_check, arc_reap_cb, NULL, SEC2NSEC(1));
7955+
arc_reap_cb_check, arc_reap_cb, NULL, SEC2NSEC(1), minclsyspri);
79567956

79577957
arc_warm = B_FALSE;
79587958

module/zfs/spa.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,8 @@ spa_start_livelist_destroy_thread(spa_t *spa)
26102610
ASSERT3P(spa->spa_livelist_delete_zthr, ==, NULL);
26112611
spa->spa_livelist_delete_zthr =
26122612
zthr_create("z_livelist_destroy",
2613-
spa_livelist_delete_cb_check, spa_livelist_delete_cb, spa);
2613+
spa_livelist_delete_cb_check, spa_livelist_delete_cb, spa,
2614+
minclsyspri);
26142615
}
26152616

26162617
typedef struct livelist_new_arg {
@@ -2820,7 +2821,7 @@ spa_start_livelist_condensing_thread(spa_t *spa)
28202821
spa->spa_livelist_condense_zthr =
28212822
zthr_create("z_livelist_condense",
28222823
spa_livelist_condense_cb_check,
2823-
spa_livelist_condense_cb, spa);
2824+
spa_livelist_condense_cb, spa, minclsyspri);
28242825
}
28252826

28262827
static void
@@ -2838,7 +2839,7 @@ spa_spawn_aux_threads(spa_t *spa)
28382839
spa->spa_checkpoint_discard_zthr =
28392840
zthr_create("z_checkpoint_discard",
28402841
spa_checkpoint_discard_thread_check,
2841-
spa_checkpoint_discard_thread, spa);
2842+
spa_checkpoint_discard_thread, spa, minclsyspri);
28422843
}
28432844

28442845
/*

module/zfs/vdev_indirect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ spa_start_indirect_condensing_thread(spa_t *spa)
885885
ASSERT3P(spa->spa_condense_zthr, ==, NULL);
886886
spa->spa_condense_zthr = zthr_create("z_indirect_condense",
887887
spa_condense_indirect_thread_check,
888-
spa_condense_indirect_thread, spa);
888+
spa_condense_indirect_thread, spa, minclsyspri);
889889
}
890890

891891
/*

module/zfs/zthr.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@
8383
* can be cancelled while doing work and not while checking for work.
8484
*
8585
* To start a zthr:
86-
* zthr_t *zthr_pointer = zthr_create(checkfunc, func, args);
86+
* zthr_t *zthr_pointer = zthr_create(checkfunc, func, args,
87+
* pri);
8788
* or
8889
* zthr_t *zthr_pointer = zthr_create_timer(checkfunc, func,
89-
* args, max_sleep);
90+
* args, max_sleep, pri);
9091
*
9192
* After that you should be able to wakeup, cancel, and resume the
9293
* zthr from another thread using the zthr_pointer.
@@ -220,6 +221,9 @@ struct zthr {
220221
*/
221222
hrtime_t zthr_sleep_timeout;
222223

224+
/* Thread priority */
225+
pri_t zthr_pri;
226+
223227
/* consumer-provided callbacks & data */
224228
zthr_checkfunc_t *zthr_checkfunc;
225229
zthr_func_t *zthr_func;
@@ -269,10 +273,10 @@ zthr_procedure(void *arg)
269273

270274
zthr_t *
271275
zthr_create(const char *zthr_name, zthr_checkfunc_t *checkfunc,
272-
zthr_func_t *func, void *arg)
276+
zthr_func_t *func, void *arg, pri_t pri)
273277
{
274278
return (zthr_create_timer(zthr_name, checkfunc,
275-
func, arg, (hrtime_t)0));
279+
func, arg, (hrtime_t)0, pri));
276280
}
277281

278282
/*
@@ -282,7 +286,7 @@ zthr_create(const char *zthr_name, zthr_checkfunc_t *checkfunc,
282286
*/
283287
zthr_t *
284288
zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc,
285-
zthr_func_t *func, void *arg, hrtime_t max_sleep)
289+
zthr_func_t *func, void *arg, hrtime_t max_sleep, pri_t pri)
286290
{
287291
zthr_t *t = kmem_zalloc(sizeof (*t), KM_SLEEP);
288292
mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL);
@@ -296,9 +300,10 @@ zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc,
296300
t->zthr_arg = arg;
297301
t->zthr_sleep_timeout = max_sleep;
298302
t->zthr_name = zthr_name;
303+
t->zthr_pri = pri;
299304

300305
t->zthr_thread = thread_create_named(zthr_name, NULL, 0,
301-
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
306+
zthr_procedure, t, 0, &p0, TS_RUN, pri);
302307

303308
mutex_exit(&t->zthr_state_lock);
304309

@@ -423,7 +428,7 @@ zthr_resume(zthr_t *t)
423428
*/
424429
if (t->zthr_thread == NULL) {
425430
t->zthr_thread = thread_create_named(t->zthr_name, NULL, 0,
426-
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
431+
zthr_procedure, t, 0, &p0, TS_RUN, t->zthr_pri);
427432
}
428433

429434
mutex_exit(&t->zthr_state_lock);

0 commit comments

Comments
 (0)