Module Name: src
Committed By: apb
Date: Wed Oct 5 13:22:13 UTC 2011
Modified Files:
src/sys/kern: kern_synch.c
Log Message:
When killing a process due to RLIMIT_CPU, also log a message
with LOG_NOTICE, and print a message to the user with uprintf.
>From PR 45421 by Greg Woods, but I changed the log priority (the user
might think it's an error, but the kernel is just doing its job) and the
wording of the message, and I edited a nearby comment.
To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/kern/kern_synch.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.292 src/sys/kern/kern_synch.c:1.293
--- src/sys/kern/kern_synch.c:1.292 Wed Oct 5 13:05:49 2011
+++ src/sys/kern/kern_synch.c Wed Oct 5 13:22:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.292 2011/10/05 13:05:49 apb Exp $ */
+/* $NetBSD: kern_synch.c,v 1.293 2011/10/05 13:22:13 apb Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.292 2011/10/05 13:05:49 apb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.293 2011/10/05 13:22:13 apb Exp $");
#include "opt_kstack.h"
#include "opt_perfctrs.h"
@@ -1245,14 +1245,21 @@ sched_pstats(void)
/*
* Check if the process exceeds its CPU resource allocation.
- * If over max, kill it.
+ * If over the hard limit, kill it with SIGKILL.
+ * If over the soft limit, send SIGXCPU and raise
+ * the soft limit a little.
*/
rlim = &p->p_rlimit[RLIMIT_CPU];
sig = 0;
if (__predict_false(runtm >= rlim->rlim_cur)) {
- if (runtm >= rlim->rlim_max)
+ if (runtm >= rlim->rlim_max) {
sig = SIGKILL;
- else {
+ log(LOG_NOTICE, "pid %d is killed: %s\n",
+ p->p_pid, "exceeded RLIMIT_CPU");
+ uprintf("pid %d, command %s, is killed: %s\n",
+ p->p_pid, p->p_comm,
+ "exceeded RLIMIT_CPU");
+ } else {
sig = SIGXCPU;
if (rlim->rlim_cur < rlim->rlim_max)
rlim->rlim_cur += 5;