Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: fix clear_refs_write locking

Turning page table entries read-only requires the mmap_sem held for
writing.

So stop doing the odd games with turning things from read locks to write
locks and back. Just get the write lock.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+9 -23
+9 -23
fs/proc/task_mmu.c
··· 1215 1215 .type = type, 1216 1216 }; 1217 1217 1218 + if (mmap_write_lock_killable(mm)) { 1219 + count = -EINTR; 1220 + goto out_mm; 1221 + } 1218 1222 if (type == CLEAR_REFS_MM_HIWATER_RSS) { 1219 - if (mmap_write_lock_killable(mm)) { 1220 - count = -EINTR; 1221 - goto out_mm; 1222 - } 1223 - 1224 1223 /* 1225 1224 * Writing 5 to /proc/pid/clear_refs resets the peak 1226 1225 * resident set size to this mm's current rss value. 1227 1226 */ 1228 1227 reset_mm_hiwater_rss(mm); 1229 - mmap_write_unlock(mm); 1230 - goto out_mm; 1228 + goto out_unlock; 1231 1229 } 1232 1230 1233 - if (mmap_read_lock_killable(mm)) { 1234 - count = -EINTR; 1235 - goto out_mm; 1236 - } 1237 1231 tlb_gather_mmu(&tlb, mm, 0, -1); 1238 1232 if (type == CLEAR_REFS_SOFT_DIRTY) { 1239 1233 for (vma = mm->mmap; vma; vma = vma->vm_next) { 1240 1234 if (!(vma->vm_flags & VM_SOFTDIRTY)) 1241 1235 continue; 1242 - mmap_read_unlock(mm); 1243 - if (mmap_write_lock_killable(mm)) { 1244 - count = -EINTR; 1245 - goto out_mm; 1246 - } 1247 - for (vma = mm->mmap; vma; vma = vma->vm_next) { 1248 - vma->vm_flags &= ~VM_SOFTDIRTY; 1249 - vma_set_page_prot(vma); 1250 - } 1251 - mmap_write_downgrade(mm); 1252 - break; 1236 + vma->vm_flags &= ~VM_SOFTDIRTY; 1237 + vma_set_page_prot(vma); 1253 1238 } 1254 1239 1255 1240 mmu_notifier_range_init(&range, MMU_NOTIFY_SOFT_DIRTY, ··· 1246 1261 if (type == CLEAR_REFS_SOFT_DIRTY) 1247 1262 mmu_notifier_invalidate_range_end(&range); 1248 1263 tlb_finish_mmu(&tlb, 0, -1); 1249 - mmap_read_unlock(mm); 1264 + out_unlock: 1265 + mmap_write_unlock(mm); 1250 1266 out_mm: 1251 1267 mmput(mm); 1252 1268 }