@@ -10238,7 +10238,7 @@ static int io_uring_show_cred(struct seq_file *m, unsigned int id,
10238
10238
10239
10239
static void __io_uring_show_fdinfo (struct io_ring_ctx * ctx , struct seq_file * m )
10240
10240
{
10241
- struct io_sq_data * sq = NULL ;
10241
+ int sq_pid = -1 , sq_cpu = -1 ;
10242
10242
bool has_lock ;
10243
10243
int i ;
10244
10244
@@ -10251,13 +10251,19 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
10251
10251
has_lock = mutex_trylock (& ctx -> uring_lock );
10252
10252
10253
10253
if (has_lock && (ctx -> flags & IORING_SETUP_SQPOLL )) {
10254
- sq = ctx -> sq_data ;
10255
- if (!sq -> thread )
10256
- sq = NULL ;
10254
+ struct io_sq_data * sq = ctx -> sq_data ;
10255
+
10256
+ if (mutex_trylock (& sq -> lock )) {
10257
+ if (sq -> thread ) {
10258
+ sq_pid = task_pid_nr (sq -> thread );
10259
+ sq_cpu = task_cpu (sq -> thread );
10260
+ }
10261
+ mutex_unlock (& sq -> lock );
10262
+ }
10257
10263
}
10258
10264
10259
- seq_printf (m , "SqThread:\t%d\n" , sq ? task_pid_nr ( sq -> thread ) : -1 );
10260
- seq_printf (m , "SqThreadCpu:\t%d\n" , sq ? task_cpu ( sq -> thread ) : -1 );
10265
+ seq_printf (m , "SqThread:\t%d\n" , sq_pid );
10266
+ seq_printf (m , "SqThreadCpu:\t%d\n" , sq_cpu );
10261
10267
seq_printf (m , "UserFiles:\t%u\n" , ctx -> nr_user_files );
10262
10268
for (i = 0 ; has_lock && i < ctx -> nr_user_files ; i ++ ) {
10263
10269
struct file * f = io_file_from_index (ctx , i );
0 commit comments