]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
rlimits: Print more information when CPU/RT limits are exceeded
authorArun Raghavan <arun@arunraghavan.net>
Wed, 1 Mar 2017 14:53:09 +0000 (20:23 +0530)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 13 Mar 2017 20:32:15 +0000 (21:32 +0100)
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>
kernel/time/posix-cpu-timers.c

index 4513ad16a253f6d2b0ccf6a3aa178b1e058c5c52..76bea3a47d4bdae375c5a26be0a556821d1a1418 100644 (file)
@@ -825,6 +825,8 @@ static void check_thread_timers(struct task_struct *tsk,
                         * At the hard limit, we just die.
                         * No need to calculate anything else now.
                         */
+                       pr_info("CPU Watchdog Timeout (hard): %s[%d]\n",
+                               tsk->comm, task_pid_nr(tsk));
                        __group_send_sig_info(SIGKILL, SEND_SIG_PRIV, tsk);
                        return;
                }
@@ -836,8 +838,7 @@ static void check_thread_timers(struct task_struct *tsk,
                                soft += USEC_PER_SEC;
                                sig->rlim[RLIMIT_RTTIME].rlim_cur = soft;
                        }
-                       printk(KERN_INFO
-                               "RT Watchdog Timeout: %s[%d]\n",
+                       pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
                                tsk->comm, task_pid_nr(tsk));
                        __group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
                }
@@ -935,6 +936,8 @@ static void check_process_timers(struct task_struct *tsk,
                         * At the hard limit, we just die.
                         * No need to calculate anything else now.
                         */
+                       pr_info("RT Watchdog Timeout (hard): %s[%d]\n",
+                               tsk->comm, task_pid_nr(tsk));
                        __group_send_sig_info(SIGKILL, SEND_SIG_PRIV, tsk);
                        return;
                }
@@ -942,6 +945,8 @@ static void check_process_timers(struct task_struct *tsk,
                        /*
                         * At the soft limit, send a SIGXCPU every second.
                         */
+                       pr_info("CPU Watchdog Timeout (soft): %s[%d]\n",
+                               tsk->comm, task_pid_nr(tsk));
                        __group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
                        if (soft < hard) {
                                soft++;