| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_synch.c,v 1.311 2016/07/03 14:24:58 christos Exp $ */ | | 1 | /* $NetBSD: kern_synch.c,v 1.312 2017/08/06 09:14:14 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 | | 4 | * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 |
5 | * The NetBSD Foundation, Inc. | | 5 | * The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
10 | * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and | | 10 | * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and |
11 | * Daniel Sieger. | | 11 | * Daniel Sieger. |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
| @@ -59,27 +59,27 @@ | | | @@ -59,27 +59,27 @@ |
59 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 59 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
60 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 60 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
61 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 61 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
62 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 62 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
63 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 63 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
64 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 64 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
65 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 65 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
66 | * SUCH DAMAGE. | | 66 | * SUCH DAMAGE. |
67 | * | | 67 | * |
68 | * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 | | 68 | * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #include <sys/cdefs.h> | | 71 | #include <sys/cdefs.h> |
72 | __KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.311 2016/07/03 14:24:58 christos Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.312 2017/08/06 09:14:14 christos Exp $"); |
73 | | | 73 | |
74 | #include "opt_kstack.h" | | 74 | #include "opt_kstack.h" |
75 | #include "opt_perfctrs.h" | | 75 | #include "opt_perfctrs.h" |
76 | #include "opt_dtrace.h" | | 76 | #include "opt_dtrace.h" |
77 | | | 77 | |
78 | #define __MUTEX_PRIVATE | | 78 | #define __MUTEX_PRIVATE |
79 | | | 79 | |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/systm.h> | | 81 | #include <sys/systm.h> |
82 | #include <sys/proc.h> | | 82 | #include <sys/proc.h> |
83 | #include <sys/kernel.h> | | 83 | #include <sys/kernel.h> |
84 | #if defined(PERFCTRS) | | 84 | #if defined(PERFCTRS) |
85 | #include <sys/pmc.h> | | 85 | #include <sys/pmc.h> |
| @@ -1198,31 +1198,31 @@ sched_pstats(void) | | | @@ -1198,31 +1198,31 @@ sched_pstats(void) |
1198 | } | | 1198 | } |
1199 | | | 1199 | |
1200 | /* | | 1200 | /* |
1201 | * Check if the process exceeds its CPU resource allocation. | | 1201 | * Check if the process exceeds its CPU resource allocation. |
1202 | * If over the hard limit, kill it with SIGKILL. | | 1202 | * If over the hard limit, kill it with SIGKILL. |
1203 | * If over the soft limit, send SIGXCPU and raise | | 1203 | * If over the soft limit, send SIGXCPU and raise |
1204 | * the soft limit a little. | | 1204 | * the soft limit a little. |
1205 | */ | | 1205 | */ |
1206 | rlim = &p->p_rlimit[RLIMIT_CPU]; | | 1206 | rlim = &p->p_rlimit[RLIMIT_CPU]; |
1207 | sig = 0; | | 1207 | sig = 0; |
1208 | if (__predict_false(runtm >= rlim->rlim_cur)) { | | 1208 | if (__predict_false(runtm >= rlim->rlim_cur)) { |
1209 | if (runtm >= rlim->rlim_max) { | | 1209 | if (runtm >= rlim->rlim_max) { |
1210 | sig = SIGKILL; | | 1210 | sig = SIGKILL; |
1211 | log(LOG_NOTICE, "pid %d is killed: %s\n", | | 1211 | log(LOG_NOTICE, |
1212 | p->p_pid, "exceeded RLIMIT_CPU"); | | 1212 | "pid %d, command %s, is killed: %s\n", |
| | | 1213 | p->p_pid, p->p_comm, "exceeded RLIMIT_CPU"); |
1213 | uprintf("pid %d, command %s, is killed: %s\n", | | 1214 | uprintf("pid %d, command %s, is killed: %s\n", |
1214 | p->p_pid, p->p_comm, | | 1215 | p->p_pid, p->p_comm, "exceeded RLIMIT_CPU"); |
1215 | "exceeded RLIMIT_CPU"); | | | |
1216 | } else { | | 1216 | } else { |
1217 | sig = SIGXCPU; | | 1217 | sig = SIGXCPU; |
1218 | if (rlim->rlim_cur < rlim->rlim_max) | | 1218 | if (rlim->rlim_cur < rlim->rlim_max) |
1219 | rlim->rlim_cur += 5; | | 1219 | rlim->rlim_cur += 5; |
1220 | } | | 1220 | } |
1221 | } | | 1221 | } |
1222 | mutex_exit(p->p_lock); | | 1222 | mutex_exit(p->p_lock); |
1223 | if (__predict_false(sig)) { | | 1223 | if (__predict_false(sig)) { |
1224 | KASSERT((p->p_flag & PK_SYSTEM) == 0); | | 1224 | KASSERT((p->p_flag & PK_SYSTEM) == 0); |
1225 | psignal(p, sig); | | 1225 | psignal(p, sig); |
1226 | } | | 1226 | } |
1227 | } | | 1227 | } |
1228 | mutex_exit(proc_lock); | | 1228 | mutex_exit(proc_lock); |