Skip to content

Commit e7ea7c9

Browse files
ford-prefectKAGA-KOKO
authored andcommitted
rlimits: Print more information when CPU/RT limits are exceeded
When a process is sent a SIGKILL because it exceeded CPU or RT limits, the cause may not be obvious in userspace -- daemonised processes just get killed, and even foreground process just see a 'Killed' message. The lack of any information on why this might be happening in logs can be confusing to users who are not aware of this mechanism. Add messages which dump the process name and tid in dmesg when a process exceeds its CPU or RT limits (soft and hard) in order to make it clearer to people debugging such issues. Signed-off-by: Arun Raghavan <arun@arunraghavan.net> Link: http://lkml.kernel.org/r/20170301145309.27214-1-arun@arunraghavan.net Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 4495c08 commit e7ea7c9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎kernel/time/posix-cpu-timers.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@ static void check_thread_timers(struct task_struct *tsk,
825825
* At the hard limit, we just die.
826826
* No need to calculate anything else now.
827827
*/
828+
pr_info("CPU Watchdog Timeout (hard): %s[%d]\n",
829+
tsk->comm, task_pid_nr(tsk));
828830
__group_send_sig_info(SIGKILL, SEND_SIG_PRIV, tsk);
829831
return;
830832
}
@@ -836,8 +838,7 @@ static void check_thread_timers(struct task_struct *tsk,
836838
soft += USEC_PER_SEC;
837839
sig->rlim[RLIMIT_RTTIME].rlim_cur = soft;
838840
}
839-
printk(KERN_INFO
840-
"RT Watchdog Timeout: %s[%d]\n",
841+
pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
841842
tsk->comm, task_pid_nr(tsk));
842843
__group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
843844
}
@@ -935,13 +936,17 @@ static void check_process_timers(struct task_struct *tsk,
935936
* At the hard limit, we just die.
936937
* No need to calculate anything else now.
937938
*/
939+
pr_info("RT Watchdog Timeout (hard): %s[%d]\n",
940+
tsk->comm, task_pid_nr(tsk));
938941
__group_send_sig_info(SIGKILL, SEND_SIG_PRIV, tsk);
939942
return;
940943
}
941944
if (psecs >= soft) {
942945
/*
943946
* At the soft limit, send a SIGXCPU every second.
944947
*/
948+
pr_info("CPU Watchdog Timeout (soft): %s[%d]\n",
949+
tsk->comm, task_pid_nr(tsk));
945950
__group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
946951
if (soft < hard) {
947952
soft++;

0 commit comments

Comments
 (0)