@@ -697,8 +697,8 @@ static __cold void io_uring_drop_tctx_refs(struct task_struct *task)
697
697
}
698
698
}
699
699
700
- static bool io_cqring_add_overflow (struct io_ring_ctx * ctx ,
701
- struct io_overflow_cqe * ocqe )
700
+ static __cold bool io_cqring_add_overflow (struct io_ring_ctx * ctx ,
701
+ struct io_overflow_cqe * ocqe )
702
702
{
703
703
lockdep_assert_held (& ctx -> completion_lock );
704
704
@@ -813,18 +813,37 @@ static inline struct io_cqe io_init_cqe(u64 user_data, s32 res, u32 cflags)
813
813
return (struct io_cqe ) { .user_data = user_data , .res = res , .flags = cflags };
814
814
}
815
815
816
+ static __cold void io_cqe_overflow (struct io_ring_ctx * ctx , struct io_cqe * cqe ,
817
+ struct io_big_cqe * big_cqe )
818
+ {
819
+ struct io_overflow_cqe * ocqe ;
820
+
821
+ ocqe = io_alloc_ocqe (ctx , cqe , big_cqe , GFP_KERNEL );
822
+ spin_lock (& ctx -> completion_lock );
823
+ io_cqring_add_overflow (ctx , ocqe );
824
+ spin_unlock (& ctx -> completion_lock );
825
+ }
826
+
827
+ static __cold bool io_cqe_overflow_locked (struct io_ring_ctx * ctx ,
828
+ struct io_cqe * cqe ,
829
+ struct io_big_cqe * big_cqe )
830
+ {
831
+ struct io_overflow_cqe * ocqe ;
832
+
833
+ ocqe = io_alloc_ocqe (ctx , cqe , big_cqe , GFP_ATOMIC );
834
+ return io_cqring_add_overflow (ctx , ocqe );
835
+ }
836
+
816
837
bool io_post_aux_cqe (struct io_ring_ctx * ctx , u64 user_data , s32 res , u32 cflags )
817
838
{
818
839
bool filled ;
819
840
820
841
io_cq_lock (ctx );
821
842
filled = io_fill_cqe_aux (ctx , user_data , res , cflags );
822
843
if (unlikely (!filled )) {
823
- struct io_overflow_cqe * ocqe ;
824
844
struct io_cqe cqe = io_init_cqe (user_data , res , cflags );
825
845
826
- ocqe = io_alloc_ocqe (ctx , & cqe , NULL , GFP_ATOMIC );
827
- filled = io_cqring_add_overflow (ctx , ocqe );
846
+ filled = io_cqe_overflow_locked (ctx , & cqe , NULL );
828
847
}
829
848
io_cq_unlock_post (ctx );
830
849
return filled ;
@@ -840,13 +859,9 @@ void io_add_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags)
840
859
lockdep_assert (ctx -> lockless_cq );
841
860
842
861
if (!io_fill_cqe_aux (ctx , user_data , res , cflags )) {
843
- struct io_overflow_cqe * ocqe ;
844
862
struct io_cqe cqe = io_init_cqe (user_data , res , cflags );
845
863
846
- ocqe = io_alloc_ocqe (ctx , & cqe , NULL , GFP_KERNEL );
847
- spin_lock (& ctx -> completion_lock );
848
- io_cqring_add_overflow (ctx , ocqe );
849
- spin_unlock (& ctx -> completion_lock );
864
+ io_cqe_overflow (ctx , & cqe , NULL );
850
865
}
851
866
ctx -> submit_state .cq_flush = true;
852
867
}
@@ -1450,17 +1465,10 @@ void __io_submit_flush_completions(struct io_ring_ctx *ctx)
1450
1465
*/
1451
1466
if (!(req -> flags & (REQ_F_CQE_SKIP | REQ_F_REISSUE )) &&
1452
1467
unlikely (!io_fill_cqe_req (ctx , req ))) {
1453
- gfp_t gfp = ctx -> lockless_cq ? GFP_KERNEL : GFP_ATOMIC ;
1454
- struct io_overflow_cqe * ocqe ;
1455
-
1456
- ocqe = io_alloc_ocqe (ctx , & req -> cqe , & req -> big_cqe , gfp );
1457
- if (ctx -> lockless_cq ) {
1458
- spin_lock (& ctx -> completion_lock );
1459
- io_cqring_add_overflow (ctx , ocqe );
1460
- spin_unlock (& ctx -> completion_lock );
1461
- } else {
1462
- io_cqring_add_overflow (ctx , ocqe );
1463
- }
1468
+ if (ctx -> lockless_cq )
1469
+ io_cqe_overflow (ctx , & req -> cqe , & req -> big_cqe );
1470
+ else
1471
+ io_cqe_overflow_locked (ctx , & req -> cqe , & req -> big_cqe );
1464
1472
}
1465
1473
}
1466
1474
__io_cq_unlock_post (ctx );
0 commit comments