Unverified Commit fa4e0344 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2337 mm: memory-failure: use rcu lock instead of tasklist_lock when collect_procs()

parents d23f8017 e1ec07eb
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -166,9 +166,6 @@ static void page_cache_kill(struct page *page)
 *    bdi.wb->list_lock		(zap_pte_range->set_page_dirty)
 *    ->inode->i_lock		(zap_pte_range->set_page_dirty)
 *    ->private_lock		(zap_pte_range->__set_page_dirty_buffers)
 *
 * ->i_mmap_rwsem
 *   ->tasklist_lock            (memory_failure, collect_procs_ao)
 */

static int page_cache_tree_insert(struct address_space *mapping,
+6 −6
Original line number Diff line number Diff line
@@ -427,8 +427,8 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
 * on behalf of the thread group. Return task_struct of the (first found)
 * dedicated thread if found, and return NULL otherwise.
 *
 * We already hold read_lock(&tasklist_lock) in the caller, so we don't
 * have to call rcu_read_lock/unlock() in this function.
 * We already hold rcu lock in the caller, so we don't have to call
 * rcu_read_lock/unlock() in this function.
 */
static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
{
@@ -478,7 +478,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
		return;

	pgoff = page_to_pgoff(page);
	read_lock(&tasklist_lock);
	rcu_read_lock();
	for_each_process (tsk) {
		struct anon_vma_chain *vmac;
		struct task_struct *t = task_early_kill(tsk, force_early);
@@ -494,7 +494,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
				add_to_kill(t, page, vma, to_kill, tkc);
		}
	}
	read_unlock(&tasklist_lock);
	rcu_read_unlock();
	page_unlock_anon_vma_read(av);
}

@@ -509,7 +509,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
	struct address_space *mapping = page->mapping;

	i_mmap_lock_read(mapping);
	read_lock(&tasklist_lock);
	rcu_read_lock();
	for_each_process(tsk) {
		pgoff_t pgoff = page_to_pgoff(page);
		struct task_struct *t = task_early_kill(tsk, force_early);
@@ -529,7 +529,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
				add_to_kill(t, page, vma, to_kill, tkc);
		}
	}
	read_unlock(&tasklist_lock);
	rcu_read_unlock();
	i_mmap_unlock_read(mapping);
}