@@ -4088,6 +4088,8 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
4088
4088
multilist_t * ml = & state -> arcs_list [type ];
4089
4089
arc_buf_hdr_t * * markers ;
4090
4090
unsigned num_sublists = multilist_get_num_sublists (ml );
4091
+ evict_arg_t * evarg ;
4092
+ boolean_t usetskq = zfs_arc_evict_threads_live > 1 ;
4091
4093
4092
4094
if (bytes == 0 )
4093
4095
return (total_evicted );
@@ -4113,15 +4115,22 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
4113
4115
multilist_sublist_unlock (mls );
4114
4116
}
4115
4117
4116
- evict_arg_t * evarg = kmem_alloc (sizeof (* evarg ) * num_sublists ,
4117
- KM_SLEEP );
4118
+ if (usetskq ) {
4119
+ evarg = kmem_alloc (sizeof (* evarg ) * num_sublists , KM_NOSLEEP );
4120
+ /*
4121
+ * Fall back to the regular single evict if it is not possible
4122
+ * to allocate memory for the task queue entries.
4123
+ */
4124
+ if (evarg == NULL )
4125
+ usetskq = B_FALSE ;
4126
+ }
4127
+
4118
4128
/*
4119
4129
* While we haven't hit our target number of bytes to evict, or
4120
4130
* we're evicting all available buffers.
4121
4131
*/
4122
4132
while (total_evicted < bytes ) {
4123
4133
int sublist_idx = multilist_get_random_index (ml );
4124
- boolean_t usetskq = zfs_arc_evict_threads_live > 1 ;
4125
4134
uint64_t scan_evicted = 0 ;
4126
4135
4127
4136
uint64_t left = (bytes == ARC_EVICT_ALL ? bytes :
@@ -4254,7 +4263,8 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
4254
4263
}
4255
4264
}
4256
4265
4257
- kmem_free (evarg , sizeof (* evarg ) * num_sublists );
4266
+ if (usetskq )
4267
+ kmem_free (evarg , sizeof (* evarg ) * num_sublists );
4258
4268
4259
4269
for (int i = 0 ; i < num_sublists ; i ++ ) {
4260
4270
multilist_sublist_t * mls = multilist_sublist_lock_idx (ml , i );
0 commit comments