| Summary: | CPU Time exceeded delivered multiple times | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Kevin Day <toasty> |
| Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.0-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->feedback Does this problem still exist in more recent releases. State Changed From-To: feedback->closed Mail to submitter bounces. |
If an executable running over NFS hits it's hard CPU limit, killproc is called multiple times as the process exits. I'm not sure if more time is being charged to the process while fd's are being closed over NFS, or cores being dumped, etc. I haven't been able to figure out exactly why this happens, but it's easy to reproduce. Fix: While this isn't an exact fix: /* * Check if the process exceeds its cpu resource allocation. * If over max, kill it. */ if (p->p_stat != SZOMB && p->p_limit->p_cpulimit != RLIM_INFINITY && p->p_runtime > p->p_limit->p_cpulimit) { rlim = &p->p_rlimit[RLIMIT_CPU]; if (p->p_runtime / (rlim_t)1000000 >= rlim->rlim_max) { killproc(p, "exceeded maximum CPU limit"); } else { psignal(p, SIGXCPU); if (rlim->rlim_cur < rlim->rlim_max) { /* XXX: we should make a private copy */ rlim->rlim_cur += 5; } } } This chunk of code doesn't seem to check to see if the process isn't already exiting. I'm not sure if it's ever really valid for a process to get this far after it's already had killproc() hit it, but it appears to be happening for me. It does check to see if the process is a zombie, but a quick check shows that it's not yet a zombie at this stage. I have no idea if this is correct or not, but: if (p->p_stat != SZOMB && p->p_limit->p_cpulimit != RLIM_INFINITY && (p->p_flags & P_WEXIT) == 0 && p->p_runtime > p->p_limit->p_cpulimit) { Looks like it might work. How-To-Repeat: Set your maximum CPU time to a few seconds. Compile a program that just sits in a busy loop. Copy it to an NFS server, and run it on an NFS client. pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit pid 51206 (spin), uid 1001, was killed: exceeded maximum CPU limit