@@ -170,9 +170,9 @@ static inline struct io_wq_acct *io_get_acct(struct io_wq *wq, bool bound)
170
170
}
171
171
172
172
static inline struct io_wq_acct * io_work_get_acct (struct io_wq * wq ,
173
- struct io_wq_work * work )
173
+ unsigned int work_flags )
174
174
{
175
- return io_get_acct (wq , !(atomic_read ( & work -> flags ) & IO_WQ_WORK_UNBOUND ));
175
+ return io_get_acct (wq , !(work_flags & IO_WQ_WORK_UNBOUND ));
176
176
}
177
177
178
178
static inline struct io_wq_acct * io_wq_get_acct (struct io_worker * worker )
@@ -457,9 +457,14 @@ static void __io_worker_idle(struct io_wq_acct *acct, struct io_worker *worker)
457
457
}
458
458
}
459
459
460
+ static inline unsigned int __io_get_work_hash (unsigned int work_flags )
461
+ {
462
+ return work_flags >> IO_WQ_HASH_SHIFT ;
463
+ }
464
+
460
465
static inline unsigned int io_get_work_hash (struct io_wq_work * work )
461
466
{
462
- return atomic_read (& work -> flags ) >> IO_WQ_HASH_SHIFT ;
467
+ return __io_get_work_hash ( atomic_read (& work -> flags )) ;
463
468
}
464
469
465
470
static bool io_wait_on_hash (struct io_wq * wq , unsigned int hash )
@@ -489,17 +494,19 @@ static struct io_wq_work *io_get_next_work(struct io_wq_acct *acct,
489
494
struct io_wq * wq = worker -> wq ;
490
495
491
496
wq_list_for_each (node , prev , & acct -> work_list ) {
497
+ unsigned int work_flags ;
492
498
unsigned int hash ;
493
499
494
500
work = container_of (node , struct io_wq_work , list );
495
501
496
502
/* not hashed, can run anytime */
497
- if (!io_wq_is_hashed (work )) {
503
+ work_flags = atomic_read (& work -> flags );
504
+ if (!__io_wq_is_hashed (work_flags )) {
498
505
wq_list_del (& acct -> work_list , node , prev );
499
506
return work ;
500
507
}
501
508
502
- hash = io_get_work_hash ( work );
509
+ hash = __io_get_work_hash ( work_flags );
503
510
/* all items with this hash lie in [work, tail] */
504
511
tail = wq -> hash_tail [hash ];
505
512
@@ -596,12 +603,13 @@ static void io_worker_handle_work(struct io_wq_acct *acct,
596
603
/* handle a whole dependent link */
597
604
do {
598
605
struct io_wq_work * next_hashed , * linked ;
599
- unsigned int hash = io_get_work_hash (work );
606
+ unsigned int work_flags = atomic_read (& work -> flags );
607
+ unsigned int hash = __io_get_work_hash (work_flags );
600
608
601
609
next_hashed = wq_next_work (work );
602
610
603
611
if (do_kill &&
604
- (atomic_read ( & work -> flags ) & IO_WQ_WORK_UNBOUND ))
612
+ (work_flags & IO_WQ_WORK_UNBOUND ))
605
613
atomic_or (IO_WQ_WORK_CANCEL , & work -> flags );
606
614
wq -> do_work (work );
607
615
io_assign_current_work (worker , NULL );
@@ -917,18 +925,19 @@ static void io_run_cancel(struct io_wq_work *work, struct io_wq *wq)
917
925
} while (work );
918
926
}
919
927
920
- static void io_wq_insert_work (struct io_wq * wq , struct io_wq_acct * acct , struct io_wq_work * work )
928
+ static void io_wq_insert_work (struct io_wq * wq , struct io_wq_acct * acct ,
929
+ struct io_wq_work * work , unsigned int work_flags )
921
930
{
922
931
unsigned int hash ;
923
932
struct io_wq_work * tail ;
924
933
925
- if (!io_wq_is_hashed ( work )) {
934
+ if (!__io_wq_is_hashed ( work_flags )) {
926
935
append :
927
936
wq_list_add_tail (& work -> list , & acct -> work_list );
928
937
return ;
929
938
}
930
939
931
- hash = io_get_work_hash ( work );
940
+ hash = __io_get_work_hash ( work_flags );
932
941
tail = wq -> hash_tail [hash ];
933
942
wq -> hash_tail [hash ] = work ;
934
943
if (!tail )
@@ -944,8 +953,8 @@ static bool io_wq_work_match_item(struct io_wq_work *work, void *data)
944
953
945
954
void io_wq_enqueue (struct io_wq * wq , struct io_wq_work * work )
946
955
{
947
- struct io_wq_acct * acct = io_work_get_acct (wq , work );
948
956
unsigned int work_flags = atomic_read (& work -> flags );
957
+ struct io_wq_acct * acct = io_work_get_acct (wq , work_flags );
949
958
struct io_cb_cancel_data match = {
950
959
.fn = io_wq_work_match_item ,
951
960
.data = work ,
@@ -964,7 +973,7 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
964
973
}
965
974
966
975
raw_spin_lock (& acct -> lock );
967
- io_wq_insert_work (wq , acct , work );
976
+ io_wq_insert_work (wq , acct , work , work_flags );
968
977
clear_bit (IO_ACCT_STALLED_BIT , & acct -> flags );
969
978
raw_spin_unlock (& acct -> lock );
970
979
0 commit comments