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

pids: Compute task_tgid using signal->leader_pid

The cost is the the same and this removes the need
to worry about complications that come from de_thread
and group_leader changing.

__task_pid_nr_ns has been updated to take advantage of this change.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+22 -17
+1 -1
arch/ia64/kernel/asm-offsets.c
··· 50 50 51 51 DEFINE(IA64_TASK_BLOCKED_OFFSET,offsetof (struct task_struct, blocked)); 52 52 DEFINE(IA64_TASK_CLEAR_CHILD_TID_OFFSET,offsetof (struct task_struct, clear_child_tid)); 53 - DEFINE(IA64_TASK_GROUP_LEADER_OFFSET, offsetof (struct task_struct, group_leader)); 54 53 DEFINE(IA64_TASK_TGIDLINK_OFFSET, offsetof (struct task_struct, pids[PIDTYPE_PID].pid)); 55 54 DEFINE(IA64_PID_LEVEL_OFFSET, offsetof (struct pid, level)); 56 55 DEFINE(IA64_PID_UPID_OFFSET, offsetof (struct pid, numbers[0])); ··· 67 68 DEFINE(IA64_SIGNAL_GROUP_STOP_COUNT_OFFSET,offsetof (struct signal_struct, 68 69 group_stop_count)); 69 70 DEFINE(IA64_SIGNAL_SHARED_PENDING_OFFSET,offsetof (struct signal_struct, shared_pending)); 71 + DEFINE(IA64_SIGNAL_LEADER_PID_OFFSET, offsetof (struct signal_struct, leader_pid)); 70 72 71 73 BLANK(); 72 74
+4 -4
arch/ia64/kernel/fsys.S
··· 62 62 .prologue 63 63 .altrp b6 64 64 .body 65 - add r17=IA64_TASK_GROUP_LEADER_OFFSET,r16 65 + add r17=IA64_TASK_SIGNAL_OFFSET,r16 66 66 ;; 67 - ld8 r17=[r17] // r17 = current->group_leader 67 + ld8 r17=[r17] // r17 = current->signal 68 68 add r9=TI_FLAGS+IA64_TASK_SIZE,r16 69 69 ;; 70 70 ld4 r9=[r9] 71 - add r17=IA64_TASK_TGIDLINK_OFFSET,r17 71 + add r17=IA64_SIGNAL_LEADER_PID_OFFSET,r17 72 72 ;; 73 73 and r9=TIF_ALLWORK_MASK,r9 74 - ld8 r17=[r17] // r17 = current->group_leader->pids[PIDTYPE_PID].pid 74 + ld8 r17=[r17] // r17 = current->signal->leader_pid 75 75 ;; 76 76 add r8=IA64_PID_LEVEL_OFFSET,r17 77 77 ;;
+1
drivers/platform/x86/thinkpad_acpi.c
··· 57 57 #include <linux/list.h> 58 58 #include <linux/mutex.h> 59 59 #include <linux/sched.h> 60 + #include <linux/sched/signal.h> 60 61 #include <linux/kthread.h> 61 62 #include <linux/freezer.h> 62 63 #include <linux/delay.h>
+1
fs/fuse/file.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/sched.h> 15 + #include <linux/sched/signal.h> 15 16 #include <linux/module.h> 16 17 #include <linux/compat.h> 17 18 #include <linux/swap.h>
+1
fs/notify/fanotify/fanotify.c
··· 8 8 #include <linux/mount.h> 9 9 #include <linux/sched.h> 10 10 #include <linux/sched/user.h> 11 + #include <linux/sched/signal.h> 11 12 #include <linux/types.h> 12 13 #include <linux/wait.h> 13 14 #include <linux/audit.h>
-5
include/linux/sched.h
··· 1202 1202 return task->pids[PIDTYPE_PID].pid; 1203 1203 } 1204 1204 1205 - static inline struct pid *task_tgid(struct task_struct *task) 1206 - { 1207 - return task->group_leader->pids[PIDTYPE_PID].pid; 1208 - } 1209 - 1210 1205 /* 1211 1206 * Without tasklist or RCU lock it is not safe to dereference 1212 1207 * the result of task_pgrp/task_session even if task == current,
+5
include/linux/sched/signal.h
··· 564 564 return task->pids[type].pid; 565 565 } 566 566 567 + static inline struct pid *task_tgid(struct task_struct *task) 568 + { 569 + return task->signal->leader_pid; 570 + } 571 + 567 572 static inline int get_nr_threads(struct task_struct *tsk) 568 573 { 569 574 return tsk->signal->nr_threads;
+1
include/net/scm.h
··· 8 8 #include <linux/security.h> 9 9 #include <linux/pid.h> 10 10 #include <linux/nsproxy.h> 11 + #include <linux/sched/signal.h> 11 12 12 13 /* Well, we should have at least one descriptor open 13 14 * to accept passed FDs 8)
+8 -7
kernel/pid.c
··· 421 421 if (!ns) 422 422 ns = task_active_pid_ns(current); 423 423 if (likely(pid_alive(task))) { 424 - if (type != PIDTYPE_PID) { 425 - if (type == __PIDTYPE_TGID) 426 - type = PIDTYPE_PID; 427 - 428 - task = task->group_leader; 429 - } 430 - nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns); 424 + struct pid *pid; 425 + if (type == PIDTYPE_PID) 426 + pid = task_pid(task); 427 + else if (type == __PIDTYPE_TGID) 428 + pid = task_tgid(task); 429 + else 430 + pid = rcu_dereference(task->group_leader->pids[type].pid); 431 + nr = pid_nr_ns(pid, ns); 431 432 } 432 433 rcu_read_unlock(); 433 434