fork.c (257058ae2b971646b96ab3a15605ac69186e562a) | fork.c (6e736be7f282fff705db7c34a15313281b372a76) |
---|---|
1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 856 unchanged lines hidden (view full) --- 865out: 866 return error; 867} 868 869static int copy_io(unsigned long clone_flags, struct task_struct *tsk) 870{ 871#ifdef CONFIG_BLOCK 872 struct io_context *ioc = current->io_context; | 1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 856 unchanged lines hidden (view full) --- 865out: 866 return error; 867} 868 869static int copy_io(unsigned long clone_flags, struct task_struct *tsk) 870{ 871#ifdef CONFIG_BLOCK 872 struct io_context *ioc = current->io_context; |
873 struct io_context *new_ioc; |
|
873 874 if (!ioc) 875 return 0; 876 /* 877 * Share io context with parent, if CLONE_IO is set 878 */ 879 if (clone_flags & CLONE_IO) { 880 tsk->io_context = ioc_task_link(ioc); 881 if (unlikely(!tsk->io_context)) 882 return -ENOMEM; 883 } else if (ioprio_valid(ioc->ioprio)) { | 874 875 if (!ioc) 876 return 0; 877 /* 878 * Share io context with parent, if CLONE_IO is set 879 */ 880 if (clone_flags & CLONE_IO) { 881 tsk->io_context = ioc_task_link(ioc); 882 if (unlikely(!tsk->io_context)) 883 return -ENOMEM; 884 } else if (ioprio_valid(ioc->ioprio)) { |
884 tsk->io_context = alloc_io_context(GFP_KERNEL, -1); 885 if (unlikely(!tsk->io_context)) | 885 new_ioc = get_task_io_context(tsk, GFP_KERNEL, NUMA_NO_NODE); 886 if (unlikely(!new_ioc)) |
886 return -ENOMEM; 887 | 887 return -ENOMEM; 888 |
888 tsk->io_context->ioprio = ioc->ioprio; | 889 new_ioc->ioprio = ioc->ioprio; 890 put_io_context(new_ioc); |
889 } 890#endif 891 return 0; 892} 893 894static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) 895{ 896 struct sighand_struct *sig; --- 70 unchanged lines hidden (view full) --- 967 task_unlock(current->group_leader); 968 969 posix_cpu_timers_init_group(sig); 970 971 tty_audit_fork(sig); 972 sched_autogroup_fork(sig); 973 974#ifdef CONFIG_CGROUPS | 891 } 892#endif 893 return 0; 894} 895 896static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) 897{ 898 struct sighand_struct *sig; --- 70 unchanged lines hidden (view full) --- 969 task_unlock(current->group_leader); 970 971 posix_cpu_timers_init_group(sig); 972 973 tty_audit_fork(sig); 974 sched_autogroup_fork(sig); 975 976#ifdef CONFIG_CGROUPS |
975 init_rwsem(&sig->group_rwsem); | 977 init_rwsem(&sig->threadgroup_fork_lock); |
976#endif 977 978 sig->oom_adj = current->signal->oom_adj; 979 sig->oom_score_adj = current->signal->oom_score_adj; 980 sig->oom_score_adj_min = current->signal->oom_score_adj_min; 981 982 mutex_init(&sig->cred_guard_mutex); 983 984 return 0; 985} 986 987static void copy_flags(unsigned long clone_flags, struct task_struct *p) 988{ 989 unsigned long new_flags = p->flags; 990 991 new_flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER); 992 new_flags |= PF_FORKNOEXEC; 993 new_flags |= PF_STARTING; 994 p->flags = new_flags; | 978#endif 979 980 sig->oom_adj = current->signal->oom_adj; 981 sig->oom_score_adj = current->signal->oom_score_adj; 982 sig->oom_score_adj_min = current->signal->oom_score_adj_min; 983 984 mutex_init(&sig->cred_guard_mutex); 985 986 return 0; 987} 988 989static void copy_flags(unsigned long clone_flags, struct task_struct *p) 990{ 991 unsigned long new_flags = p->flags; 992 993 new_flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER); 994 new_flags |= PF_FORKNOEXEC; 995 new_flags |= PF_STARTING; 996 p->flags = new_flags; |
997 clear_freeze_flag(p); |
|
995} 996 997SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr) 998{ 999 current->clear_child_tid = tidptr; 1000 1001 return task_pid_vnr(current); 1002} --- 149 unchanged lines hidden (view full) --- 1152 posix_cpu_timers_init(p); 1153 1154 do_posix_clock_monotonic_gettime(&p->start_time); 1155 p->real_start_time = p->start_time; 1156 monotonic_to_bootbased(&p->real_start_time); 1157 p->io_context = NULL; 1158 p->audit_context = NULL; 1159 if (clone_flags & CLONE_THREAD) | 998} 999 1000SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr) 1001{ 1002 current->clear_child_tid = tidptr; 1003 1004 return task_pid_vnr(current); 1005} --- 149 unchanged lines hidden (view full) --- 1155 posix_cpu_timers_init(p); 1156 1157 do_posix_clock_monotonic_gettime(&p->start_time); 1158 p->real_start_time = p->start_time; 1159 monotonic_to_bootbased(&p->real_start_time); 1160 p->io_context = NULL; 1161 p->audit_context = NULL; 1162 if (clone_flags & CLONE_THREAD) |
1160 threadgroup_change_begin(current); | 1163 threadgroup_fork_read_lock(current); |
1161 cgroup_fork(p); 1162#ifdef CONFIG_NUMA 1163 p->mempolicy = mpol_dup(p->mempolicy); 1164 if (IS_ERR(p->mempolicy)) { 1165 retval = PTR_ERR(p->mempolicy); 1166 p->mempolicy = NULL; 1167 goto bad_fork_cleanup_cgroup; 1168 } --- 198 unchanged lines hidden (view full) --- 1367 } 1368 1369 total_forks++; 1370 spin_unlock(¤t->sighand->siglock); 1371 write_unlock_irq(&tasklist_lock); 1372 proc_fork_connector(p); 1373 cgroup_post_fork(p); 1374 if (clone_flags & CLONE_THREAD) | 1164 cgroup_fork(p); 1165#ifdef CONFIG_NUMA 1166 p->mempolicy = mpol_dup(p->mempolicy); 1167 if (IS_ERR(p->mempolicy)) { 1168 retval = PTR_ERR(p->mempolicy); 1169 p->mempolicy = NULL; 1170 goto bad_fork_cleanup_cgroup; 1171 } --- 198 unchanged lines hidden (view full) --- 1370 } 1371 1372 total_forks++; 1373 spin_unlock(¤t->sighand->siglock); 1374 write_unlock_irq(&tasklist_lock); 1375 proc_fork_connector(p); 1376 cgroup_post_fork(p); 1377 if (clone_flags & CLONE_THREAD) |
1375 threadgroup_change_end(current); | 1378 threadgroup_fork_read_unlock(current); |
1376 perf_event_fork(p); 1377 return p; 1378 1379bad_fork_free_pid: 1380 if (pid != &init_struct_pid) 1381 free_pid(pid); 1382bad_fork_cleanup_io: 1383 if (p->io_context) --- 18 unchanged lines hidden (view full) --- 1402 audit_free(p); 1403bad_fork_cleanup_policy: 1404 perf_event_free_task(p); 1405#ifdef CONFIG_NUMA 1406 mpol_put(p->mempolicy); 1407bad_fork_cleanup_cgroup: 1408#endif 1409 if (clone_flags & CLONE_THREAD) | 1379 perf_event_fork(p); 1380 return p; 1381 1382bad_fork_free_pid: 1383 if (pid != &init_struct_pid) 1384 free_pid(pid); 1385bad_fork_cleanup_io: 1386 if (p->io_context) --- 18 unchanged lines hidden (view full) --- 1405 audit_free(p); 1406bad_fork_cleanup_policy: 1407 perf_event_free_task(p); 1408#ifdef CONFIG_NUMA 1409 mpol_put(p->mempolicy); 1410bad_fork_cleanup_cgroup: 1411#endif 1412 if (clone_flags & CLONE_THREAD) |
1410 threadgroup_change_end(current); | 1413 threadgroup_fork_read_unlock(current); |
1411 cgroup_exit(p, cgroup_callbacks_done); 1412 delayacct_tsk_free(p); 1413 module_put(task_thread_info(p)->exec_domain->module); 1414bad_fork_cleanup_count: 1415 atomic_dec(&p->cred->user->processes); 1416 exit_creds(p); 1417bad_fork_free: 1418 free_task(p); --- 353 unchanged lines hidden --- | 1414 cgroup_exit(p, cgroup_callbacks_done); 1415 delayacct_tsk_free(p); 1416 module_put(task_thread_info(p)->exec_domain->module); 1417bad_fork_cleanup_count: 1418 atomic_dec(&p->cred->user->processes); 1419 exit_creds(p); 1420bad_fork_free: 1421 free_task(p); --- 353 unchanged lines hidden --- |