@@ -132,6 +132,10 @@ extern uint64_t zfs_active_rwlock;
132132extern uint64_t total_memory ;
133133extern uint64_t real_total_memory ;
134134
135+ extern kmem_cache_t * abd_chunk_cache ;
136+ extern uint64_t zfs_arc_max ;
137+ extern int zfs_prealloc_percent ;
138+
135139#define MULT 1
136140
137141static const char * KMEM_VA_PREFIX = "kmem_va" ;
@@ -4304,10 +4308,7 @@ spl_free_set_pressure(int64_t new_p)
43044308 // and any spl_free_set_and_wait_pressure() threads
43054309 cv_broadcast (& spl_free_thread_cv );
43064310 }
4307- if (new_p > 0 )
4308- spl_free_last_pressure = zfs_lbolt ();
4309- else
4310- spl_free_last_pressure = zfs_lbolt ();
4311+ spl_free_last_pressure = zfs_lbolt ();
43114312}
43124313
43134314void
@@ -4923,10 +4924,6 @@ spl_event_thread(void *notused)
49234924 thread_exit ();
49244925}
49254926
4926- extern kmem_cache_t * abd_chunk_cache ;
4927- extern uint64_t zfs_arc_max ;
4928- extern int zfs_abd_prealloc_percent ;
4929-
49304927static void
49314928spl_abd_prealloc_thread (void * notused )
49324929{
@@ -4952,13 +4949,14 @@ spl_abd_prealloc_thread(void *notused)
49524949 delay (hz );
49534950 continue ;
49544951 }
4955- node = (abd_prealloc_node_t * )kmem_cache_alloc (abd_chunk_cache , KM_SLEEP );
4956- list_insert_tail (& abd_prealloc_list , node );
49574952
49584953 if (segkmem_total_mem_allocated >=
4959- (zfs_arc_max * zfs_abd_prealloc_percent ) / 100 ) {
4954+ (zfs_arc_max * zfs_prealloc_percent ) / 100 ) {
49604955 break ;
49614956 }
4957+
4958+ node = (abd_prealloc_node_t * )kmem_cache_alloc (abd_chunk_cache , KM_SLEEP );
4959+ list_insert_tail (& abd_prealloc_list , node );
49624960 }
49634961
49644962 while ((node = list_remove_head (& abd_prealloc_list )) != NULL ) {
@@ -4969,7 +4967,7 @@ spl_abd_prealloc_thread(void *notused)
49694967 dprintf ("SPL: %s thread_exit\n" , __func__ );
49704968
49714969 KdPrintEx ((DPFLTR_IHVDRIVER_ID , DPFLTR_ERROR_LEVEL , "SPL: abd prealloc done segkmem_total_mem_allocated: %lld total_memory: %lld zfs_arc_max: %llu zfs_prealloc_percent: %d%\n" ,
4972- segkmem_total_mem_allocated , total_memory , zfs_arc_max , zfs_abd_prealloc_percent ));
4970+ segkmem_total_mem_allocated , total_memory , zfs_arc_max , zfs_prealloc_percent ));
49734971 thread_exit ();
49744972}
49754973
@@ -5401,11 +5399,13 @@ spl_kmem_thread_init(void)
54015399 (void ) thread_create (NULL , 0 , spl_free_thread , 0 , 0 , 0 , 0 , 92 );
54025400 spl_free_thread_running = TRUE;
54035401
5404- //spl_event_thread_exit = FALSE;
5405- //(void) thread_create(NULL, 0, spl_event_thread, 0, 0, 0, 0, 92);
5406-
5407- spl_abd_prealloc_thread_exit = FALSE;
5408- (void ) thread_create (NULL , 0 , spl_abd_prealloc_thread , 0 , 0 , 0 , 0 , 92 );
5402+ if (zfs_prealloc_percent ) {
5403+ spl_abd_prealloc_thread_exit = FALSE;
5404+ (void ) thread_create (NULL , 0 , spl_abd_prealloc_thread , 0 , 0 , 0 , 0 , 92 );
5405+ } else {
5406+ spl_event_thread_exit = FALSE;
5407+ (void ) thread_create (NULL , 0 , spl_event_thread , 0 , 0 , 0 , 0 , 92 );
5408+ }
54095409}
54105410
54115411void
0 commit comments