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/memory-failure.c: fix spinlock vs mutex order

We cannot take a mutex while holding a spinlock, so flip the order and
fix the locking documentation.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Peter Zijlstra and committed by
Linus Torvalds
9b679320 aa2c96d6

+8 -18
+6 -15
mm/memory-failure.c
··· 391 391 struct task_struct *tsk; 392 392 struct anon_vma *av; 393 393 394 - read_lock(&tasklist_lock); 395 394 av = page_lock_anon_vma(page); 396 395 if (av == NULL) /* Not actually mapped anymore */ 397 - goto out; 396 + return; 397 + 398 + read_lock(&tasklist_lock); 398 399 for_each_process (tsk) { 399 400 struct anon_vma_chain *vmac; 400 401 ··· 409 408 add_to_kill(tsk, page, vma, to_kill, tkc); 410 409 } 411 410 } 412 - page_unlock_anon_vma(av); 413 - out: 414 411 read_unlock(&tasklist_lock); 412 + page_unlock_anon_vma(av); 415 413 } 416 414 417 415 /* ··· 424 424 struct prio_tree_iter iter; 425 425 struct address_space *mapping = page->mapping; 426 426 427 - /* 428 - * A note on the locking order between the two locks. 429 - * We don't rely on this particular order. 430 - * If you have some other code that needs a different order 431 - * feel free to switch them around. Or add a reverse link 432 - * from mm_struct to task_struct, then this could be all 433 - * done without taking tasklist_lock and looping over all tasks. 434 - */ 435 - 436 - read_lock(&tasklist_lock); 437 427 mutex_lock(&mapping->i_mmap_mutex); 428 + read_lock(&tasklist_lock); 438 429 for_each_process(tsk) { 439 430 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 440 431 ··· 445 454 add_to_kill(tsk, page, vma, to_kill, tkc); 446 455 } 447 456 } 448 - mutex_unlock(&mapping->i_mmap_mutex); 449 457 read_unlock(&tasklist_lock); 458 + mutex_unlock(&mapping->i_mmap_mutex); 450 459 } 451 460 452 461 /*
+2 -3
mm/rmap.c
··· 38 38 * in arch-dependent flush_dcache_mmap_lock, 39 39 * within inode_wb_list_lock in __sync_single_inode) 40 40 * 41 - * (code doesn't rely on that order so it could be switched around) 42 - * ->tasklist_lock 43 - * anon_vma->mutex (memory_failure, collect_procs_anon) 41 + * anon_vma->mutex,mapping->i_mutex (memory_failure, collect_procs_anon) 42 + * ->tasklist_lock 44 43 * pte map lock 45 44 */ 46 45