aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@redhat.com>2010-03-10 18:23:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:39 -0500
commita56704ef6b0c5796c9ff38cc78aa232dfb9644d7 (patch)
tree7f304a916fbcd22388ed1a66c63c5571f9572bd7
parente34112e3966fc466ced2698e6c196bb50b1ee20e (diff)
copy_signal() cleanup: use zalloc and remove initializations
Use kmem_cache_zalloc() on signal creation and remove unneeded initialization lines in copy_signal(). Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/fork.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index b0ec34abc0bb..ce2666f84d85 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -863,7 +863,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
863 if (clone_flags & CLONE_THREAD) 863 if (clone_flags & CLONE_THREAD)
864 return 0; 864 return 0;
865 865
866 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); 866 sig = kmem_cache_zalloc(signal_cachep, GFP_KERNEL);
867 tsk->signal = sig; 867 tsk->signal = sig;
868 if (!sig) 868 if (!sig)
869 return -ENOMEM; 869 return -ENOMEM;
@@ -871,46 +871,21 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
871 atomic_set(&sig->count, 1); 871 atomic_set(&sig->count, 1);
872 atomic_set(&sig->live, 1); 872 atomic_set(&sig->live, 1);
873 init_waitqueue_head(&sig->wait_chldexit); 873 init_waitqueue_head(&sig->wait_chldexit);
874 sig->flags = 0;
875 if (clone_flags & CLONE_NEWPID) 874 if (clone_flags & CLONE_NEWPID)
876 sig->flags |= SIGNAL_UNKILLABLE; 875 sig->flags |= SIGNAL_UNKILLABLE;
877 sig->group_exit_code = 0;
878 sig->group_exit_task = NULL;
879 sig->group_stop_count = 0;
880 sig->curr_target = tsk; 876 sig->curr_target = tsk;
881 init_sigpending(&sig->shared_pending); 877 init_sigpending(&sig->shared_pending);
882 INIT_LIST_HEAD(&sig->posix_timers); 878 INIT_LIST_HEAD(&sig->posix_timers);
883 879
884 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 880 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
885 sig->it_real_incr.tv64 = 0;
886 sig->real_timer.function = it_real_fn; 881 sig->real_timer.function = it_real_fn;
887 882
888 sig->leader = 0; /* session leadership doesn't inherit */
889 sig->tty_old_pgrp = NULL;
890 sig->tty = NULL;
891
892 sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero;
893 sig->gtime = cputime_zero;
894 sig->cgtime = cputime_zero;
895#ifndef CONFIG_VIRT_CPU_ACCOUNTING
896 sig->prev_utime = sig->prev_stime = cputime_zero;
897#endif
898 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
899 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
900 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0;
901 sig->maxrss = sig->cmaxrss = 0;
902 task_io_accounting_init(&sig->ioac);
903 sig->sum_sched_runtime = 0;
904 taskstats_tgid_init(sig);
905
906 task_lock(current->group_leader); 883 task_lock(current->group_leader);
907 memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); 884 memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
908 task_unlock(current->group_leader); 885 task_unlock(current->group_leader);
909 886
910 posix_cpu_timers_init_group(sig); 887 posix_cpu_timers_init_group(sig);
911 888
912 acct_init_pacct(&sig->pacct);
913
914 tty_audit_fork(sig); 889 tty_audit_fork(sig);
915 890
916 sig->oom_adj = current->signal->oom_adj; 891 sig->oom_adj = current->signal->oom_adj;