@@ -3437,6 +3437,23 @@ static int worker_thread(void *__worker)
34373437 goto woke_up ;
34383438}
34393439
3440+ static bool assign_rescuer_work (struct pool_workqueue * pwq , struct worker * rescuer )
3441+ {
3442+ struct worker_pool * pool = pwq -> pool ;
3443+ struct work_struct * work , * n ;
3444+
3445+ /*
3446+ * Slurp in all works issued via this workqueue and
3447+ * process'em.
3448+ */
3449+ list_for_each_entry_safe (work , n , & pool -> worklist , entry ) {
3450+ if (get_work_pwq (work ) == pwq && assign_work (work , rescuer , & n ))
3451+ pwq -> stats [PWQ_STAT_RESCUED ]++ ;
3452+ }
3453+
3454+ return !list_empty (& rescuer -> scheduled );
3455+ }
3456+
34403457/**
34413458 * rescuer_thread - the rescuer thread function
34423459 * @__rescuer: self
@@ -3491,7 +3508,6 @@ static int rescuer_thread(void *__rescuer)
34913508 struct pool_workqueue * pwq = list_first_entry (& wq -> maydays ,
34923509 struct pool_workqueue , mayday_node );
34933510 struct worker_pool * pool = pwq -> pool ;
3494- struct work_struct * work , * n ;
34953511
34963512 __set_current_state (TASK_RUNNING );
34973513 list_del_init (& pwq -> mayday_node );
@@ -3502,18 +3518,9 @@ static int rescuer_thread(void *__rescuer)
35023518
35033519 raw_spin_lock_irq (& pool -> lock );
35043520
3505- /*
3506- * Slurp in all works issued via this workqueue and
3507- * process'em.
3508- */
35093521 WARN_ON_ONCE (!list_empty (& rescuer -> scheduled ));
3510- list_for_each_entry_safe (work , n , & pool -> worklist , entry ) {
3511- if (get_work_pwq (work ) == pwq &&
3512- assign_work (work , rescuer , & n ))
3513- pwq -> stats [PWQ_STAT_RESCUED ]++ ;
3514- }
35153522
3516- if (! list_empty ( & rescuer -> scheduled )) {
3523+ if (assign_rescuer_work ( pwq , rescuer )) {
35173524 process_scheduled_works (rescuer );
35183525
35193526 /*
0 commit comments