NetBSD Problem Report #45421
From woods@once.weird.com Tue Oct 4 18:37:52 2011
Return-Path: <woods@once.weird.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 693E763B85F
for <gnats-bugs@gnats.NetBSD.org>; Tue, 4 Oct 2011 18:37:52 +0000 (UTC)
Message-Id: <m1RB9sC-001EBeC@once.weird.com>
Date: Tue, 4 Oct 2011 11:37:48 -0700 (PDT)
From: "Greg A. Woods" <woods@planix.com>
Sender: "Greg A. Woods" <woods@once.weird.com>
Reply-To: "Greg A. Woods" <woods@planix.com>
To: gnats-bugs@gnats.NetBSD.org
Subject: kernel should log and inform user when it uses SIGKILL because of RLIMIT_CPU
X-Send-Pr-Version: 3.95
>Number: 45421
>Category: kern
>Synopsis: kernel should log and inform user when it uses SIGKILL because of RLIMIT_CPU
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 04 18:40:00 +0000 2011
>Closed-Date: Wed Oct 05 13:54:52 +0000 2011
>Last-Modified: Wed Oct 05 13:54:52 +0000 2011
>Originator: Greg A. Woods
>Release: NetBSD-current 2011/10/04
>Organization:
Planix, Inc.; Kelowna, BC; Canada
>Environment:
System: NetBSD
Architecture: all
Machine: all
>Description:
the kernel should log, and inform the user, when it uses SIGKILL
to terminate a process because it has exceeded RLIMIT_CPU.
also, fix a nearby errant use of printf() instead of log().
>How-To-Repeat:
try to make actual use of CPU limits without confusing and
angering users
>Fix:
Index: sys/kern/kern_synch.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/kern/kern_synch.c,v
retrieving revision 1.291
diff -u -r1.291 kern_synch.c
--- sys/kern/kern_synch.c 27 Sep 2011 01:02:38 -0000 1.291
+++ sys/kern/kern_synch.c 4 Oct 2011 17:59:40 -0000
@@ -1250,9 +1250,11 @@
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_ERR, "pid %d is killed: %s\n", p->p_pid, "exceeded RLIMIT_CPU");
+ uprintf("sorry, 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;
@@ -1262,7 +1264,7 @@
if (__predict_false(runtm < 0)) {
if (!backwards) {
backwards = true;
- printf("WARNING: negative runtime; "
+ log(LOG_WARNING, "WARNING: negative runtime; "
"monotonic clock has gone backwards\n");
}
} else if (__predict_false(sig)) {
>Release-Note:
>Audit-Trail:
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45421 CVS commit: src/sys/kern
Date: Wed, 5 Oct 2011 13:05:49 +0000
Module Name: src
Committed By: apb
Date: Wed Oct 5 13:05:49 UTC 2011
Modified Files:
src/sys/kern: kern_synch.c
Log Message:
Print "WARNING: negative runtime; monotonic clock has gone backwards\n"
using log(LOG_WARNING, ...), not just printf(...).
From PR 45421 by Greg Woods.
To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 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.
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45421 CVS commit: src/sys/kern
Date: Wed, 5 Oct 2011 13:22:13 +0000
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.
State-Changed-From-To: open->closed
State-Changed-By: apb@NetBSD.org
State-Changed-When: Wed, 05 Oct 2011 13:54:52 +0000
State-Changed-Why:
patch applied, with small changes.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.