process_procfs_request(): use IRQ save MCS locks while iterating thread list to avoid deadlock

This commit is contained in:
Balazs Gerofi
2016-12-28 12:29:10 +09:00
parent 4e5ec74ffe
commit 536ce9f927

View File

@ -161,7 +161,7 @@ process_procfs_request(unsigned long rarg)
*/ */
ret = sscanf(p, "%d/", &pid); ret = sscanf(p, "%d/", &pid);
if (ret == 1) { if (ret == 1) {
struct mcs_rwlock_node tlock; struct mcs_rwlock_node_irqsave tlock;
int tids; int tids;
struct thread *thread1 = NULL; struct thread *thread1 = NULL;
@ -178,7 +178,7 @@ process_procfs_request(unsigned long rarg)
else else
tid = pid; tid = pid;
mcs_rwlock_reader_lock_noirq(&proc->threads_lock, &tlock); mcs_rwlock_reader_lock(&proc->threads_lock, &tlock);
list_for_each_entry(thread, &proc->threads_list, siblings_list){ list_for_each_entry(thread, &proc->threads_list, siblings_list){
if(thread->tid == tid) if(thread->tid == tid)
break; break;
@ -188,15 +188,15 @@ process_procfs_request(unsigned long rarg)
if(thread == NULL){ if(thread == NULL){
kprintf("process_procfs_request: no such tid %d-%d\n", pid, tid); kprintf("process_procfs_request: no such tid %d-%d\n", pid, tid);
if(tids){ if(tids){
mcs_rwlock_reader_unlock(&proc->threads_lock, &tlock);
process_unlock(proc, &lock); process_unlock(proc, &lock);
mcs_rwlock_reader_unlock_noirq(&proc->threads_lock, &tlock);
goto end; goto end;
} }
thread = thread1; thread = thread1;
} }
if(thread) if(thread)
hold_thread(thread); hold_thread(thread);
mcs_rwlock_reader_unlock_noirq(&proc->threads_lock, &tlock); mcs_rwlock_reader_unlock(&proc->threads_lock, &tlock);
hold_process(proc); hold_process(proc);
vm = proc->vm; vm = proc->vm;
if(vm) if(vm)