From df0f73b43c438f0ed6bb21c28fd010ab23ac7bff Mon Sep 17 00:00:00 2001 From: Alexander Stetsenko Date: Fri, 31 Jan 2025 17:46:15 +0200 Subject: [PATCH] tmp --- module/zfs/arc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 5a3178485f66..9ef1f74826c2 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -475,7 +475,7 @@ static taskq_t *arc_flush_taskq; * 1 (disabled) one thread - parallel eviction is disabled. * 2+ (manual) set the number manually, limited by zfs_arc_evict_threads_max. */ -static uint_t zfs_arc_evict_threads = 1; +static uint_t zfs_arc_evict_threads = 0; /* * The number of allocated ARC eviction threads. This limits the maximum value @@ -4126,6 +4126,7 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa, uint_t nthreads = (arc_evict_taskq == NULL ? 1 : MIN(num_sublists, (zfs_arc_evict_threads == 0 ? zfs_arc_evict_threads_max : MIN(zfs_arc_evict_threads, zfs_arc_evict_threads_max)))); + nthreads = zfs_arc_evict_threads_max; /* XXX: */ boolean_t use_evcttq = nthreads > 1; @@ -4152,12 +4153,17 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa, if (use_evcttq) { evarg = kmem_alloc(sizeof (*evarg) * nthreads, KM_NOSLEEP); - /* - * Fall back to the regular single evict if it is not possible - * to allocate memory for the task queue entries. - */ - if (evarg == NULL) + if (evarg) { + for (int i = 0; i < nthreads; i++) + taskq_init_ent(&evarg[i].tqe); + } else { + /* + * Fall back to the regular single evict if it is not + * possible to allocate memory for the taskq entries. + */ use_evcttq = B_FALSE; + } + } /* @@ -4176,14 +4182,18 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa, if (left == ARC_EVICT_ALL) { evict = left; ntasks = nthreads; + /* } else if (left > nthreads * MIN_EVICT_SIZE) { evict = DIV_ROUND_UP(left, nthreads); ntasks = nthreads; + */ } else { evict = MIN_EVICT_SIZE; - ntasks = DIV_ROUND_UP(left, MIN_EVICT_SIZE); + //ntasks = DIV_ROUND_UP(left, MIN_EVICT_SIZE); + ntasks = nthreads; } } else { + ASSERT(0); /* XXX: */ ntasks = num_sublists; evict = left; } @@ -4204,7 +4214,6 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa, sublist_idx = 0; if (use_evcttq) { - taskq_init_ent(&evarg[i].tqe); evarg[i].ml = ml; evarg[i].marker = markers[sublist_idx]; evarg[i].spa = spa; @@ -4212,8 +4221,8 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa, evarg[i].bytes = evict; taskq_dispatch_ent(arc_evict_taskq, - arc_evict_task, - &evarg[i], 0, &evarg[i].tqe); + arc_evict_task, &evarg[i], 0, + &evarg[i].tqe); continue; } @@ -7996,6 +8005,7 @@ arc_init(void) zfs_arc_evict_threads_max = max_ncpus / 2; } + zfs_arc_evict_threads_max = 4; /* XXX: */ if (zfs_arc_evict_threads_max > 1) { arc_evict_taskq = taskq_create("arc_evict", zfs_arc_evict_threads_max,