MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lim_cb

Function lim_cb

freebsd/kern/kern_resource.c:612–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610}
611
612static void
613lim_cb(void *arg)
614{
615 struct rlimit rlim;
616 struct thread *td;
617 struct proc *p;
618
619 p = arg;
620 PROC_LOCK_ASSERT(p, MA_OWNED);
621 /*
622 * Check if the process exceeds its cpu resource allocation. If
623 * it reaches the max, arrange to kill the process in ast().
624 */
625 if (p->p_cpulimit == RLIM_INFINITY)
626 return;
627 PROC_STATLOCK(p);
628 FOREACH_THREAD_IN_PROC(p, td) {
629 ruxagg(p, td);
630 }
631 PROC_STATUNLOCK(p);
632 if (p->p_rux.rux_runtime > p->p_cpulimit * cpu_tickrate()) {
633 lim_rlimit_proc(p, RLIMIT_CPU, &rlim);
634 if (p->p_rux.rux_runtime >= rlim.rlim_max * cpu_tickrate()) {
635 killproc(p, "exceeded maximum CPU limit");
636 } else {
637 if (p->p_cpulimit < rlim.rlim_max)
638 p->p_cpulimit += 5;
639 kern_psignal(p, SIGXCPU);
640 }
641 }
642 if ((p->p_flag & P_WEXIT) == 0)
643 callout_reset_sbt(&p->p_limco, SBT_1S, 0,
644 lim_cb, p, C_PREL(1));
645}
646
647int
648kern_setrlimit(struct thread *td, u_int which, struct rlimit *limp)

Callers

nothing calls this directly

Calls 5

ruxaggFunction · 0.85
cpu_tickrateFunction · 0.85
killprocFunction · 0.85
kern_psignalFunction · 0.85
lim_rlimit_procFunction · 0.70

Tested by

no test coverage detected