@@ -86,13 +86,8 @@ static inline void napi_show_fdinfo(struct io_ring_ctx *ctx,
86
86
}
87
87
#endif
88
88
89
- /*
90
- * Caller holds a reference to the file already, we don't need to do
91
- * anything else to get an extra reference.
92
- */
93
- __cold void io_uring_show_fdinfo (struct seq_file * m , struct file * file )
89
+ static void __io_uring_show_fdinfo (struct io_ring_ctx * ctx , struct seq_file * m )
94
90
{
95
- struct io_ring_ctx * ctx = file -> private_data ;
96
91
struct io_overflow_cqe * ocqe ;
97
92
struct io_rings * r = ctx -> rings ;
98
93
struct rusage sq_usage ;
@@ -106,7 +101,6 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
106
101
unsigned int sq_entries , cq_entries ;
107
102
int sq_pid = -1 , sq_cpu = -1 ;
108
103
u64 sq_total_time = 0 , sq_work_time = 0 ;
109
- bool has_lock ;
110
104
unsigned int i ;
111
105
112
106
if (ctx -> flags & IORING_SETUP_CQE32 )
@@ -176,15 +170,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
176
170
seq_printf (m , "\n" );
177
171
}
178
172
179
- /*
180
- * Avoid ABBA deadlock between the seq lock and the io_uring mutex,
181
- * since fdinfo case grabs it in the opposite direction of normal use
182
- * cases. If we fail to get the lock, we just don't iterate any
183
- * structures that could be going away outside the io_uring mutex.
184
- */
185
- has_lock = mutex_trylock (& ctx -> uring_lock );
186
-
187
- if (has_lock && (ctx -> flags & IORING_SETUP_SQPOLL )) {
173
+ if (ctx -> flags & IORING_SETUP_SQPOLL ) {
188
174
struct io_sq_data * sq = ctx -> sq_data ;
189
175
190
176
/*
@@ -206,7 +192,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
206
192
seq_printf (m , "SqTotalTime:\t%llu\n" , sq_total_time );
207
193
seq_printf (m , "SqWorkTime:\t%llu\n" , sq_work_time );
208
194
seq_printf (m , "UserFiles:\t%u\n" , ctx -> file_table .data .nr );
209
- for (i = 0 ; has_lock && i < ctx -> file_table .data .nr ; i ++ ) {
195
+ for (i = 0 ; i < ctx -> file_table .data .nr ; i ++ ) {
210
196
struct file * f = NULL ;
211
197
212
198
if (ctx -> file_table .data .nodes [i ])
@@ -218,7 +204,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
218
204
}
219
205
}
220
206
seq_printf (m , "UserBufs:\t%u\n" , ctx -> buf_table .nr );
221
- for (i = 0 ; has_lock && i < ctx -> buf_table .nr ; i ++ ) {
207
+ for (i = 0 ; i < ctx -> buf_table .nr ; i ++ ) {
222
208
struct io_mapped_ubuf * buf = NULL ;
223
209
224
210
if (ctx -> buf_table .nodes [i ])
@@ -228,7 +214,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
228
214
else
229
215
seq_printf (m , "%5u: <none>\n" , i );
230
216
}
231
- if (has_lock && !xa_empty (& ctx -> personalities )) {
217
+ if (!xa_empty (& ctx -> personalities )) {
232
218
unsigned long index ;
233
219
const struct cred * cred ;
234
220
@@ -238,7 +224,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
238
224
}
239
225
240
226
seq_puts (m , "PollList:\n" );
241
- for (i = 0 ; has_lock && i < (1U << ctx -> cancel_table .hash_bits ); i ++ ) {
227
+ for (i = 0 ; i < (1U << ctx -> cancel_table .hash_bits ); i ++ ) {
242
228
struct io_hash_bucket * hb = & ctx -> cancel_table .hbs [i ];
243
229
struct io_kiocb * req ;
244
230
@@ -247,9 +233,6 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
247
233
task_work_pending (req -> tctx -> task ));
248
234
}
249
235
250
- if (has_lock )
251
- mutex_unlock (& ctx -> uring_lock );
252
-
253
236
seq_puts (m , "CqOverflowList:\n" );
254
237
spin_lock (& ctx -> completion_lock );
255
238
list_for_each_entry (ocqe , & ctx -> cq_overflow_list , list ) {
@@ -262,4 +245,23 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *file)
262
245
spin_unlock (& ctx -> completion_lock );
263
246
napi_show_fdinfo (ctx , m );
264
247
}
248
+
249
+ /*
250
+ * Caller holds a reference to the file already, we don't need to do
251
+ * anything else to get an extra reference.
252
+ */
253
+ __cold void io_uring_show_fdinfo (struct seq_file * m , struct file * file )
254
+ {
255
+ struct io_ring_ctx * ctx = file -> private_data ;
256
+
257
+ /*
258
+ * Avoid ABBA deadlock between the seq lock and the io_uring mutex,
259
+ * since fdinfo case grabs it in the opposite direction of normal use
260
+ * cases.
261
+ */
262
+ if (mutex_trylock (& ctx -> uring_lock )) {
263
+ __io_uring_show_fdinfo (ctx , m );
264
+ mutex_unlock (& ctx -> uring_lock );
265
+ }
266
+ }
265
267
#endif
0 commit comments