diff options
Diffstat (limited to 'kernel/exit.c')
| -rw-r--r-- | kernel/exit.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index ca6a11b73023..57626692cd90 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -858,6 +858,34 @@ static void exit_notify(struct task_struct *tsk) | |||
| 858 | release_task(tsk); | 858 | release_task(tsk); |
| 859 | } | 859 | } |
| 860 | 860 | ||
| 861 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
| 862 | static void check_stack_usage(void) | ||
| 863 | { | ||
| 864 | static DEFINE_SPINLOCK(low_water_lock); | ||
| 865 | static int lowest_to_date = THREAD_SIZE; | ||
| 866 | unsigned long *n = end_of_stack(current); | ||
| 867 | unsigned long free; | ||
| 868 | |||
| 869 | while (*n == 0) | ||
| 870 | n++; | ||
| 871 | free = (unsigned long)n - (unsigned long)end_of_stack(current); | ||
| 872 | |||
| 873 | if (free >= lowest_to_date) | ||
| 874 | return; | ||
| 875 | |||
| 876 | spin_lock(&low_water_lock); | ||
| 877 | if (free < lowest_to_date) { | ||
| 878 | printk(KERN_WARNING "%s used greatest stack depth: %lu bytes " | ||
| 879 | "left\n", | ||
| 880 | current->comm, free); | ||
| 881 | lowest_to_date = free; | ||
| 882 | } | ||
| 883 | spin_unlock(&low_water_lock); | ||
| 884 | } | ||
| 885 | #else | ||
| 886 | static inline void check_stack_usage(void) {} | ||
| 887 | #endif | ||
| 888 | |||
| 861 | fastcall NORET_TYPE void do_exit(long code) | 889 | fastcall NORET_TYPE void do_exit(long code) |
| 862 | { | 890 | { |
| 863 | struct task_struct *tsk = current; | 891 | struct task_struct *tsk = current; |
| @@ -937,6 +965,8 @@ fastcall NORET_TYPE void do_exit(long code) | |||
| 937 | if (unlikely(tsk->compat_robust_list)) | 965 | if (unlikely(tsk->compat_robust_list)) |
| 938 | compat_exit_robust_list(tsk); | 966 | compat_exit_robust_list(tsk); |
| 939 | #endif | 967 | #endif |
| 968 | if (group_dead) | ||
| 969 | tty_audit_exit(); | ||
| 940 | if (unlikely(tsk->audit_context)) | 970 | if (unlikely(tsk->audit_context)) |
| 941 | audit_free(tsk); | 971 | audit_free(tsk); |
| 942 | 972 | ||
| @@ -949,6 +979,7 @@ fastcall NORET_TYPE void do_exit(long code) | |||
| 949 | exit_sem(tsk); | 979 | exit_sem(tsk); |
| 950 | __exit_files(tsk); | 980 | __exit_files(tsk); |
| 951 | __exit_fs(tsk); | 981 | __exit_fs(tsk); |
| 982 | check_stack_usage(); | ||
| 952 | exit_thread(); | 983 | exit_thread(); |
| 953 | cpuset_exit(tsk); | 984 | cpuset_exit(tsk); |
| 954 | exit_keys(tsk); | 985 | exit_keys(tsk); |
