Skip to content

Commit a879bf5

Browse files
gthelentorvalds
authored andcommitted
mm: grab rcu read lock in move_pages()
The move_pages() usage of find_task_by_vpid() requires rcu_read_lock() to prevent free_pid() from reclaiming the pid. Without this patch, RCU warnings are printed in v2.6.38-rc4 move_pages() with: CONFIG_LOCKUP_DETECTOR=y CONFIG_PREEMPT=y CONFIG_LOCKDEP=y CONFIG_PROVE_LOCKING=y CONFIG_PROVE_RCU=y Previously, migrate_pages() went through a similar transformation replacing usage of tasklist_lock with rcu read lock: commit 55cfaa3 Author: Zeng Zhaoming <[email protected]> Date: Thu Dec 2 14:31:13 2010 -0800 mm/mempolicy.c: add rcu read lock to protect pid structure commit 1e50df3 Author: KOSAKI Motohiro <[email protected]> Date: Thu Jan 13 15:46:14 2011 -0800 mempolicy: remove tasklist_lock from migrate_pages Signed-off-by: Greg Thelen <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Rik van Riel <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Zeng Zhaoming <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 22bacca commit a879bf5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/migrate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,14 +1287,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
12871287
return -EPERM;
12881288

12891289
/* Find the mm_struct */
1290-
read_lock(&tasklist_lock);
1290+
rcu_read_lock();
12911291
task = pid ? find_task_by_vpid(pid) : current;
12921292
if (!task) {
1293-
read_unlock(&tasklist_lock);
1293+
rcu_read_unlock();
12941294
return -ESRCH;
12951295
}
12961296
mm = get_task_mm(task);
1297-
read_unlock(&tasklist_lock);
1297+
rcu_read_unlock();
12981298

12991299
if (!mm)
13001300
return -EINVAL;

0 commit comments

Comments
 (0)