Commit f020bc468fe4a91d32046d448511978c7b611315

Authored by Oleg Nesterov
Committed by Linus Torvalds
1 parent 84d737866e

[PATCH] sys_setpgid: eliminate unnecessary do_each_task_pid(PIDTYPE_PGID)

All tasks in the process group have the same sid, we don't need to iterate
them all to check that the caller of sys_setpgid() doesn't change its
session.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 4 additions and 7 deletions Side-by-side Diff

... ... @@ -1397,16 +1397,13 @@
1397 1397 goto out;
1398 1398  
1399 1399 if (pgid != pid) {
1400   - struct task_struct *p;
  1400 + struct task_struct *g =
  1401 + find_task_by_pid_type(PIDTYPE_PGID, pgid);
1401 1402  
1402   - do_each_task_pid(pgid, PIDTYPE_PGID, p) {
1403   - if (process_session(p) == process_session(group_leader))
1404   - goto ok_pgid;
1405   - } while_each_task_pid(pgid, PIDTYPE_PGID, p);
1406   - goto out;
  1403 + if (!g || process_session(g) != process_session(group_leader))
  1404 + goto out;
1407 1405 }
1408 1406  
1409   -ok_pgid:
1410 1407 err = security_task_setpgid(p, pgid);
1411 1408 if (err)
1412 1409 goto out;