Commit c6669c22 authored by Graf Yang's avatar Graf Yang Committed by Mike Frysinger

Blackfin: fix up mm locking in address dumping

The locking code in the address dumper needs to grab the mm's mmap_sem
so that other CPUs do not get an inconsistent view.  On UP systems this
really wasn't a problem, but it is easy to trigger a race on SMP systems
when another CPU removes a mapping.
Signed-off-by: default avatarGraf Yang <graf.yang@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent 7e1082b7
...@@ -138,6 +138,12 @@ static void decode_address(char *buf, unsigned long address) ...@@ -138,6 +138,12 @@ static void decode_address(char *buf, unsigned long address)
if (!mm) if (!mm)
continue; continue;
if (!down_read_trylock(&mm->mmap_sem)) {
if (!in_atomic)
mmput(mm);
continue;
}
for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) { for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) {
struct vm_area_struct *vma; struct vm_area_struct *vma;
...@@ -177,6 +183,7 @@ static void decode_address(char *buf, unsigned long address) ...@@ -177,6 +183,7 @@ static void decode_address(char *buf, unsigned long address)
sprintf(buf, "[ %s vma:0x%lx-0x%lx]", sprintf(buf, "[ %s vma:0x%lx-0x%lx]",
name, vma->vm_start, vma->vm_end); name, vma->vm_start, vma->vm_end);
up_read(&mm->mmap_sem);
if (!in_atomic) if (!in_atomic)
mmput(mm); mmput(mm);
...@@ -186,11 +193,16 @@ static void decode_address(char *buf, unsigned long address) ...@@ -186,11 +193,16 @@ static void decode_address(char *buf, unsigned long address)
goto done; goto done;
} }
} }
up_read(&mm->mmap_sem);
if (!in_atomic) if (!in_atomic)
mmput(mm); mmput(mm);
} }
/* we were unable to find this address anywhere */ /*
* we were unable to find this address anywhere,
* or some MMs were skipped because they were in use.
*/
sprintf(buf, "/* kernel dynamic memory */"); sprintf(buf, "/* kernel dynamic memory */");
done: done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment