From owner-p4-projects@FreeBSD.ORG Sat Dec 4 20:41:56 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 49CE51065674; Sat, 4 Dec 2010 20:41:56 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BD79106564A for ; Sat, 4 Dec 2010 20:41:56 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id EA7CE8FC08 for ; Sat, 4 Dec 2010 20:41:55 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id oB4KftsL067156 for ; Sat, 4 Dec 2010 20:41:55 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id oB4Kft0u067153 for perforce@freebsd.org; Sat, 4 Dec 2010 20:41:55 GMT (envelope-from trasz@freebsd.org) Date: Sat, 4 Dec 2010 20:41:55 GMT Message-Id: <201012042041.oB4Kft0u067153@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 186635 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Dec 2010 20:41:56 -0000 http://p4web.freebsd.org/@@186635?ac=10 Change 186635 by trasz@trasz_victim on 2010/12/04 20:40:57 Get rid of the ugly #ifdef CONTAINERS. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/compat/linux/linux_misc.c#18 edit .. //depot/projects/soc2009/trasz_limits/sys/compat/svr4/imgact_svr4.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/conf/files#39 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/fdescfs/fdesc_vfsops.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/i386/linux/imgact_linux.c#10 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_aout.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#19 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_gzip.c#9 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/init_main.c#31 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#40 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_descrip.c#17 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#29 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#26 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#26 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_sig.c#19 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_thr.c#12 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/sysv_msg.c#9 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/sysv_sem.c#9 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/sysv_shm.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#21 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/uipc_sockbuf.c#7 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/uipc_socket.c#18 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/uipc_usrreq.c#10 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/vfs_vnops.c#20 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#14 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_glue.c#9 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#28 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_mmap.c#20 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_pageout.c#19 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_unix.c#11 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/compat/linux/linux_misc.c#18 (text+ko) ==== @@ -369,7 +369,6 @@ } PROC_UNLOCK(td->td_proc); #endif -#ifdef CONTAINERS if (a_out->a_text > maxtsiz) { error = ENOMEM; goto cleanup; @@ -380,7 +379,6 @@ error = ENOMEM; goto cleanup; } -#endif /* !CONTAINERS */ /* * Prevent more writers. ==== //depot/projects/soc2009/trasz_limits/sys/compat/svr4/imgact_svr4.c#11 (text+ko) ==== @@ -116,14 +116,12 @@ } PROC_UNLOCK(imgp->proc); #endif /* !HRL */ -#ifdef CONTAINERS if (a_out->a_text > maxtsiz) return (ENOMEM); error = rusage_set(imgp->proc, RUSAGE_DATA, a_out->a_data + bss_size); if (error != 0) return (ENOMEM); -#endif VOP_UNLOCK(imgp->vp, 0); ==== //depot/projects/soc2009/trasz_limits/sys/conf/files#39 (text+ko) ==== @@ -2124,7 +2124,7 @@ kern/kern_condvar.c standard kern/kern_conf.c standard kern/kern_cons.c standard -kern/kern_container.c optional containers +kern/kern_container.c standard kern/kern_cpu.c standard kern/kern_cpuset.c standard kern/kern_context.c standard ==== //depot/projects/soc2009/trasz_limits/sys/fs/fdescfs/fdesc_vfsops.c#5 (text+ko) ==== @@ -187,9 +187,7 @@ int i; int last; int freefd; -#ifdef CONTAINERS uint64_t limit; -#endif td = curthread; @@ -206,7 +204,6 @@ #endif fdp = td->td_proc->p_fd; FILEDESC_SLOCK(fdp); -#ifdef CONTAINERS limit = rusage_get_limit(td->td_proc, RUSAGE_NOFILE); #ifdef HRL lim = limit; @@ -214,7 +211,6 @@ if (lim > limit) lim = limit; #endif -#endif last = min(fdp->fd_nfiles, lim); freefd = 0; for (i = fdp->fd_freefile; i < last; i++) ==== //depot/projects/soc2009/trasz_limits/sys/i386/linux/imgact_linux.c#10 (text+ko) ==== @@ -114,14 +114,12 @@ } PROC_UNLOCK(imgp->proc); #endif /* !HRL */ -#ifdef CONTAINERS if (a_out->a_text > maxtsiz) return (ENOMEM); error = rusage_set(imgp->proc, RUSAGE_DATA, a_out->a_data + bss_size); if (error != 0) return (ENOMEM); -#endif /* CONTAINERS */ VOP_UNLOCK(imgp->vp, 0); ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_aout.c#11 (text+ko) ==== @@ -197,7 +197,6 @@ } PROC_UNLOCK(imgp->proc); #endif /* !HRL */ -#ifdef CONTAINERS if (/* text can't exceed maximum text size */ a_out->a_text > maxtsiz) return (ENOMEM); @@ -205,7 +204,6 @@ a_out->a_data + bss_size); if (error != 0) return (ENOMEM); -#endif /* CONTAINERS */ /* * Avoid a possible deadlock if the current address space is destroyed ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#19 (text+ko) ==== @@ -885,7 +885,6 @@ #else PROC_LOCK(imgp->proc); #endif /* !HRL */ -#ifdef CONTAINERS if (text_size > maxtsiz) return (ENOMEM); error = rusage_set(imgp->proc, RUSAGE_DATA, @@ -896,7 +895,6 @@ total_size); if (error != 0) return (ENOMEM); -#endif /* CONTAINERS */ vmspace->vm_tsize = text_size >> PAGE_SHIFT; vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; @@ -1117,12 +1115,10 @@ hdrsize = 0; __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count); -#ifdef CONTAINERS if (rusage_add(td->td_proc, RUSAGE_CORE, hdrsize + seginfo.size)) { error = EFAULT; goto done; } -#endif /* CONTAINERS */ if (hdrsize + seginfo.size >= limit) { error = EFAULT; goto done; ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_gzip.c#9 (text+ko) ==== @@ -224,7 +224,6 @@ } PROC_UNLOCK(gz->ip->proc); #endif /* !HRL */ -#ifdef CONTAINERS if ( /* text can't exceed maximum text size */ gz->a_out.a_text > maxtsiz) { gz->where = __LINE__; @@ -234,7 +233,6 @@ gz->a_out.a_data + gz->bss_size); if (error != 0) return (ENOMEM); -#endif /* CONTAINERS */ /* Find out how far we should go */ gz->file_end = gz->file_offset + gz->a_out.a_text + gz->a_out.a_data; ==== //depot/projects/soc2009/trasz_limits/sys/kern/init_main.c#31 (text+ko) ==== @@ -399,9 +399,6 @@ proc0_init(void *dummy __unused) { struct proc *p; -#ifdef CONTAINERS - unsigned error; -#endif struct thread *td; vm_paddr_t pageablemem; int i; @@ -560,10 +557,7 @@ * Charge root for one process. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, 1, 0); -#ifdef CONTAINERS - error = rusage_add(p, RUSAGE_NPROC, 1); - KASSERT(error == 0, ("rusage_add failed")); -#endif + rusage_add_force(p, RUSAGE_NPROC, 1); } SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#40 (text+ko) ==== @@ -58,6 +58,8 @@ #include #endif +#ifdef CONTAINERS + static struct mtx container_lock; MTX_SYSINIT(container_lock, &container_lock, "container lock", MTX_DEF); @@ -786,3 +788,84 @@ NULL }; SYSINIT(containerd, SI_SUB_RUN_SCHEDULER, SI_ORDER_FIRST, kproc_start, &containerd_kp); + +#else /* !CONTAINERS */ + +int +rusage_add(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +rusage_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +void +rusage_add_force(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +int +rusage_set(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +rusage_sub(struct proc *p, int resource, uint64_t amount) +{ +} + +void +rusage_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +uint64_t +rusage_get_limit(struct proc *p, int resource) +{ + + return (UINT64_MAX); +} + +void +container_create(struct container *container) +{ +} + +void +container_destroy(struct container *container) +{ +} + +int +container_join(struct container *child, struct container *parent) +{ + + return (0); +} + +void +container_leave(struct container *child, struct container *parent) +{ +} + +int +container_proc_fork(struct proc *parent, struct proc *child) +{ + + return (0); +} + +void +container_proc_exit(struct proc *p) +{ +} + +#endif /* !CONTAINERS */ ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_descrip.c#17 (text+ko) ==== @@ -274,19 +274,15 @@ getdtablesize(struct thread *td, struct getdtablesize_args *uap) { struct proc *p = td->td_proc; -#ifdef CONTAINERS uint64_t lim; -#endif PROC_LOCK(p); td->td_retval[0] = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc); PROC_UNLOCK(p); -#ifdef CONTAINERS lim = rusage_get_limit(td->td_proc, RUSAGE_NOFILE); if (lim < td->td_retval[0]) td->td_retval[0] = lim; -#endif return (0); } @@ -800,22 +796,19 @@ */ if (flags & DUP_FIXED) { if (new >= fdp->fd_nfiles) { -#ifdef CONTAINERS /* * The resource limits are here instead of e.g. fdalloc(), * because the file descriptor table may be shared between * processes, so we can't really use rusage_add()/rusage_sub(). - * Instead of e.g. counting the number of actually allocated + * Instead of counting the number of actually allocated * descriptors, just put the limit on the size of the file - * descriptor table. Entries are small, and we'll need a limit - * for vnodes and sockets anyway. + * descriptor table. */ if (rusage_set(p, RUSAGE_NOFILE, new + 1)) { FILEDESC_XUNLOCK(fdp); fdrop(fp, td); return (EMFILE); } -#endif fdgrowtable(fdp, new + 1); } if (fdp->fd_ofiles[new] == NULL) @@ -1486,10 +1479,8 @@ return (EMFILE); if (fd < fdp->fd_nfiles) break; -#ifdef CONTAINERS if (rusage_set(p, RUSAGE_NOFILE, min(fdp->fd_nfiles * 2, maxfd))) return (EMFILE); -#endif fdgrowtable(fdp, min(fdp->fd_nfiles * 2, maxfd)); } @@ -1772,9 +1763,8 @@ if (fdp == NULL) return; -#ifdef CONTAINERS rusage_set(td->td_proc, RUSAGE_NOFILE, 0); -#endif + /* Check for special need to clear POSIX style locks */ fdtol = td->td_proc->p_fdtol; if (fdtol != NULL) { ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#29 (text+ko) ==== @@ -177,9 +177,7 @@ } KASSERT(p->p_numthreads == 1, ("exit1: proc %p exiting with %d threads", p, p->p_numthreads)); -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NTHR, 1); -#endif /* * Wakeup anyone in procfs' PIOCWAIT. They should have a hold * on our vmspace, so we should block below until they have @@ -743,7 +741,6 @@ * Decrement the count of procs running with this uid. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0); -#ifdef CONTAINERS rusage_set(p, RUSAGE_CPU, cputick2usec(p->p_rux.rux_runtime)); rusage_sub(p->p_pptr, RUSAGE_NPROC, 1); @@ -751,7 +748,6 @@ * Destroy resource container associated with the process. */ container_proc_exit(p); -#endif /* * Free credentials, arguments, and sigacts. @@ -912,11 +908,8 @@ if (child->p_pptr == parent) return; -#ifdef CONTAINERS rusage_sub(child->p_pptr, RUSAGE_NPROC, 1); - /* XXX: What about return value? */ - rusage_add(parent, RUSAGE_NPROC, 1); -#endif + rusage_add_force(parent, RUSAGE_NPROC, 1); PROC_LOCK(child->p_pptr); sigqueue_take(child->p_ksi); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#26 (text+ko) ==== @@ -224,11 +224,9 @@ p1 = td->td_proc; -#ifdef CONTAINERS error = rusage_add(p1, RUSAGE_NPROC, 1); if (error != 0) return (error); -#endif /* * Here we don't create a new process, but we divorce @@ -240,9 +238,7 @@ PROC_LOCK(p1); if (thread_single(SINGLE_BOUNDARY)) { PROC_UNLOCK(p1); -#ifdef CONTAINERS rusage_sub(p1, RUSAGE_NPROC, 1); -#endif return (ERESTART); } PROC_UNLOCK(p1); @@ -276,10 +272,8 @@ PROC_UNLOCK(p1); } *procp = NULL; -#ifdef CONTAINERS if (error != 0) rusage_sub(p1, RUSAGE_NPROC, 1); -#endif return (error); } @@ -356,7 +350,6 @@ goto fail; } -#ifdef CONTAINERS /* * Initialize resource container for the child process. */ @@ -373,7 +366,6 @@ error = EAGAIN; goto fail; } -#endif /* * Increment the count of procs running with this uid. Don't allow @@ -810,9 +802,7 @@ *procp = p2; return (0); fail: -#ifdef CONTAINERS container_proc_exit(newproc); -#endif sx_sunlock(&proctree_lock); if (ppsratecheck(&lastfail, &curfail, 1)) printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n", @@ -826,9 +816,7 @@ vmspace_free(vm2); uma_zfree(proc_zone, newproc); pause("fork", hz / 2); -#ifdef CONTAINERS rusage_sub(p1, RUSAGE_NPROC, 1); -#endif return (error); } ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#26 (text+ko) ==== @@ -1188,9 +1188,7 @@ root = mypr->pr_root; vref(root); } -#ifdef CONTAINERS container_create(&pr->pr_container); -#endif strlcpy(pr->pr_hostuuid, DEFAULT_HOSTUUID, HOSTUUIDLEN); pr->pr_flags |= PR_HOST; #if defined(INET) || defined(INET6) @@ -2523,9 +2521,7 @@ if (pr->pr_cpuset != NULL) cpuset_rel(pr->pr_cpuset); osd_jail_exit(pr); -#ifdef CONTAINERS container_destroy(&pr->pr_container); -#endif free(pr, M_PRISON); /* Removing a prison frees a reference on its parent. */ ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_sig.c#19 (text+ko) ==== @@ -3170,12 +3170,8 @@ */ limit = (off_t)lim_cur(p, RLIMIT_CORE); PROC_UNLOCK(p); -#ifdef CONTAINERS if (limit == 0 && rusage_add(td->td_proc, RUSAGE_CORE, 1) == 0) { rusage_sub(td->td_proc, RUSAGE_CORE, 1); -#else - if (limit == 0) { -#endif #ifdef AUDIT audit_proc_coredump(td, name, EFBIG); #endif ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_thr.c#12 (text+ko) ==== @@ -176,10 +176,8 @@ return (EINVAL); } } -#ifdef CONTAINERS if (rusage_add(p, RUSAGE_NTHR, 1)) return (EPROCLIM); -#endif /* Initialize our td */ newtd = thread_alloc(0); @@ -267,9 +265,7 @@ return (0); fail: -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NTHR, 1); -#endif return (error); } @@ -301,9 +297,7 @@ rw_wlock(&tidhash_lock); -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NTHR, 1); -#endif PROC_LOCK(p); /* ==== //depot/projects/soc2009/trasz_limits/sys/kern/sysv_msg.c#9 (text+ko) ==== @@ -465,11 +465,9 @@ } #endif -#ifdef CONTAINERS rusage_sub_cred(msqkptr->cred, RUSAGE_NMSGQ, 1); rusage_sub_cred(msqkptr->cred, RUSAGE_MSGQQUEUED, msqkptr->u.msg_qnum); rusage_sub_cred(msqkptr->cred, RUSAGE_MSGQSIZE, msqkptr->u.msg_cbytes); -#endif crfree(msqkptr->cred); msqkptr->cred = NULL; @@ -620,12 +618,10 @@ error = ENOSPC; goto done2; } -#ifdef CONTAINERS if (rusage_add(td->td_proc, RUSAGE_NMSGQ, 1)) { error = ENOSPC; goto done2; } -#endif DPRINTF(("msqid %d is available\n", msqid)); msqkptr->u.msg_perm.key = key; msqkptr->u.msg_perm.cuid = cred->cr_uid; @@ -685,9 +681,7 @@ register struct msqid_kernel *msqkptr; register struct msg *msghdr; short next; -#ifdef CONTAINERS size_t saved_msgsz; -#endif if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) return (ENOSYS); @@ -725,19 +719,16 @@ goto done2; #endif -#ifdef CONTAINERS if (rusage_add(td->td_proc, RUSAGE_MSGQQUEUED, 1)) { error = EAGAIN; goto done2; } - saved_msgsz = msgsz; if (rusage_add(td->td_proc, RUSAGE_MSGQSIZE, msgsz)) { rusage_sub(td->td_proc, RUSAGE_MSGQQUEUED, 1); error = EAGAIN; goto done2; } -#endif segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz; DPRINTF(("msgsz=%zu, msgssz=%d, segs_needed=%d\n", msgsz, @@ -992,12 +983,10 @@ wakeup(msqkptr); td->td_retval[0] = 0; done3: -#ifdef CONTAINERS if (error != 0) { rusage_sub(td->td_proc, RUSAGE_MSGQQUEUED, 1); rusage_sub(td->td_proc, RUSAGE_MSGQSIZE, saved_msgsz); } -#endif done2: mtx_unlock(&msq_mtx); return (error); @@ -1231,10 +1220,8 @@ msqkptr->u.msg_lrpid = td->td_proc->p_pid; msqkptr->u.msg_rtime = time_second; -#ifdef CONTAINERS rusage_sub_cred(msqkptr->cred, RUSAGE_MSGQQUEUED, 1); rusage_sub_cred(msqkptr->cred, RUSAGE_MSGQSIZE, msghdr->msg_ts); -#endif /* * Make msgsz the actual amount that we'll be returning. ==== //depot/projects/soc2009/trasz_limits/sys/kern/sysv_sem.c#9 (text+ko) ==== @@ -655,9 +655,7 @@ semakptr->u.sem_perm.cuid = cred->cr_uid; semakptr->u.sem_perm.uid = cred->cr_uid; semakptr->u.sem_perm.mode = 0; -#ifdef CONTAINERS rusage_sub_cred(semakptr->cred, RUSAGE_NSEM, semakptr->u.sem_nsems); -#endif crfree(semakptr->cred); semakptr->cred = NULL; SEMUNDO_LOCK(); @@ -931,12 +929,10 @@ error = ENOSPC; goto done2; } -#ifdef CONTAINERS if (rusage_add(td->td_proc, RUSAGE_NSEM, nsems)) { error = ENOSPC; goto done2; } -#endif DPRINTF(("semid %d is available\n", semid)); mtx_lock(&sema_mtx[semid]); KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, @@ -1022,10 +1018,8 @@ DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, nsops)); return (E2BIG); -#ifdef CONTAINERS } else if (nsops > rusage_get_limit(td->td_proc, RUSAGE_NSEMOP)) { return (E2BIG); -#endif } else sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { ==== //depot/projects/soc2009/trasz_limits/sys/kern/sysv_shm.c#11 (text+ko) ==== @@ -245,10 +245,8 @@ #ifdef MAC mac_sysvshm_cleanup(shmseg); #endif -#ifdef CONTAINERS rusage_sub_cred(shmseg->cred, RUSAGE_NSHM, 1); rusage_sub_cred(shmseg->cred, RUSAGE_SHMSIZE, size); -#endif crfree(shmseg->cred); shmseg->cred = NULL; } @@ -672,14 +670,12 @@ shm_last_free = -1; } shmseg = &shmsegs[segnum]; -#ifdef CONTAINERS if (rusage_add(td->td_proc, RUSAGE_NSHM, 1)) return (ENOSPC); if (rusage_add(td->td_proc, RUSAGE_SHMSIZE, size)) { rusage_sub(td->td_proc, RUSAGE_NSHM, 1); return (ENOMEM); } -#endif /* * In case we sleep in malloc(), mark the segment present but deleted * so that noone else tries to create the same key. @@ -696,10 +692,8 @@ shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP, 0, size, VM_PROT_DEFAULT, 0, cred); if (shm_object == NULL) { -#ifdef CONTAINERS rusage_sub(td->td_proc, RUSAGE_NSHM, 1); rusage_sub(td->td_proc, RUSAGE_SHMSIZE, size); -#endif return (ENOMEM); } VM_OBJECT_LOCK(shm_object); ==== //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#21 (text+ko) ==== @@ -576,9 +576,7 @@ tty_lock(tp); tty_rel_gone(tp); -#ifdef CONTAINERS rusage_sub(td->td_proc, RUSAGE_NPTS, 1); -#endif /* * Open of /dev/ptmx or /dev/ptyXX changes the type of file @@ -717,34 +715,28 @@ int pts_alloc(int fflags, struct thread *td, struct file *fp) { - int unit, ok; + int unit, ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; struct uidinfo *uid = td->td_ucred->cr_ruidinfo; /* Resource limiting. */ -#ifdef CONTAINERS - ok = !rusage_add(p, RUSAGE_NPTS, 1); - if (!ok) + error = rusage_add(p, RUSAGE_NPTS, 1); + if (error != 0) return (EAGAIN); -#endif PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); PROC_UNLOCK(p); if (!ok) { -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NPTS, 1); -#endif return (EAGAIN); } /* Try to allocate a new pts unit number. */ unit = alloc_unr(pts_pool); if (unit < 0) { -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NPTS, 1); -#endif chgptscnt(uid, -1, 0); return (EAGAIN); } @@ -775,25 +767,21 @@ pts_alloc_external(int fflags, struct thread *td, struct file *fp, struct cdev *dev, const char *name) { - int ok; + int ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; struct uidinfo *uid = td->td_ucred->cr_ruidinfo; /* Resource limiting. */ -#ifdef CONTAINERS - ok = !rusage_add(p, RUSAGE_NPTS, 1); - if (!ok) + error = rusage_add(p, RUSAGE_NPTS, 1); + if (error != 0) return (EAGAIN); -#endif PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); PROC_UNLOCK(p); if (!ok) { -#ifdef CONTAINERS rusage_sub(p, RUSAGE_NPTS, 1); -#endif return (EAGAIN); } ==== //depot/projects/soc2009/trasz_limits/sys/kern/uipc_sockbuf.c#7 (text+ko) ==== @@ -291,9 +291,7 @@ struct thread *td) { rlim_t sbsize_limit; -#ifdef CONTAINER int error; -#endif SOCKBUF_LOCK_ASSERT(sb); @@ -310,21 +308,16 @@ PROC_LOCK(td->td_proc); sbsize_limit = lim_cur(td->td_proc, RLIMIT_SBSIZE); PROC_UNLOCK(td->td_proc); - } else - sbsize_limit = RLIM_INFINITY; -#ifdef CONTAINER - if (td != NULL) { error = rusage_add(td->td_proc, RUSAGE_SBSIZE, cc); if (error != 0) return (0); - } else + } else { + sbsize_limit = RLIM_INFINITY; rusage_add_cred(so->so_cred, RUSAGE_SBSIZE, cc); -#endif + } if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, sbsize_limit)) { -#ifdef CONTAINER rusage_sub_cred(so->so_cred, RUSAGE_SBSIZE, cc); -#endif return (0); } sb->sb_mbmax = min(cc * sb_efficiency, sb_max); @@ -353,9 +346,7 @@ { sbflush_internal(sb); -#ifdef CONTAINERS rusage_sub_cred(so->so_cred, RUSAGE_SBSIZE, sb->sb_hiwat); -#endif (void)chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, 0, RLIM_INFINITY); sb->sb_mbmax = 0; ==== //depot/projects/soc2009/trasz_limits/sys/kern/uipc_socket.c#18 (text+ko) ==== @@ -323,18 +323,14 @@ #endif mtx_unlock(&so_global_mtx); if (so->so_rcv.sb_hiwat) { -#ifdef CONTAINERS rusage_sub_cred(so->so_cred, RUSAGE_SBSIZE, so->so_rcv.sb_hiwat); -#endif (void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_rcv.sb_hiwat, 0, RLIM_INFINITY); } if (so->so_snd.sb_hiwat) { -#ifdef CONTAINERS rusage_sub_cred(so->so_cred, RUSAGE_SBSIZE, so->so_snd.sb_hiwat); -#endif (void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_snd.sb_hiwat, 0, RLIM_INFINITY); } ==== //depot/projects/soc2009/trasz_limits/sys/kern/uipc_usrreq.c#10 (text+ko) ==== @@ -801,9 +801,7 @@ SOCKBUF_LOCK(&so2->so_snd); so2->so_snd.sb_mbmax += unp->unp_mbcnt - mbcnt; newhiwat = so2->so_snd.sb_hiwat + unp->unp_cc - sbcc; -#ifdef CONTAINERS rusage_add_cred(so2->so_cred, RUSAGE_SBSIZE, newhiwat - so2->so_snd.sb_hiwat); -#endif (void)chgsbsize(so2->so_cred->cr_uidinfo, &so2->so_snd.sb_hiwat, newhiwat, RLIM_INFINITY); sowwakeup_locked(so2); @@ -979,9 +977,7 @@ SOCKBUF_LOCK(&so->so_snd); newhiwat = so->so_snd.sb_hiwat - (sbcc - unp2->unp_cc); -#ifdef CONTAINERS rusage_add_cred(so->so_cred, RUSAGE_SBSIZE, newhiwat - so->so_snd.sb_hiwat); -#endif (void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_snd.sb_hiwat, newhiwat, RLIM_INFINITY); so->so_snd.sb_mbmax -= mbcnt_delta; ==== //depot/projects/soc2009/trasz_limits/sys/kern/vfs_vnops.c#20 (text+ko) ==== @@ -1357,11 +1357,9 @@ } PROC_UNLOCK(td->td_proc); #endif -#ifdef CONTAINERS if (rusage_set(td->td_proc, RUSAGE_FSIZE, (uoff_t)uio->uio_offset + uio->uio_resid)) return (EFBIG); -#endif return (0); } ==== //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#14 (text+ko) ==== @@ -212,9 +212,7 @@ PROC_LOCK(curproc); UIDINFO_VMSIZE_LOCK(uip); if ( -#ifdef CONTAINERS rusage_add(curproc, RUSAGE_SWAP, incr) && -#endif #ifndef HRL (overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 && uip->ui_vmsize + incr > lim_cur(curproc, RLIMIT_SWAP) && @@ -248,9 +246,7 @@ swap_reserved += incr; mtx_unlock(&sw_dev_mtx); -#ifdef CONTAINERS rusage_add_force(curproc, RUSAGE_SWAP, incr); -#endif uip = curthread->td_ucred->cr_ruidinfo; PROC_LOCK(curproc); @@ -293,9 +289,7 @@ uip->ui_vmsize -= decr; UIDINFO_VMSIZE_UNLOCK(uip); -#ifdef CONTAINERS rusage_sub_cred(cred, RUSAGE_SWAP, decr); -#endif } static void swapdev_strategy(struct buf *, struct swdevt *sw); ==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_glue.c#9 (text+ko) ==== @@ -207,10 +207,8 @@ } #endif PROC_UNLOCK(curproc); -#ifdef CONTAINERS if (rusage_set(curproc, RUSAGE_MEMLOCK, nsize)) return (ENOMEM); -#endif #if 0 /* * XXX - not yet @@ -226,11 +224,9 @@ #endif error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); -#ifdef CONTAINERS if (error != KERN_SUCCESS) rusage_sub(curproc, RUSAGE_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); -#endif /* * Return EFAULT on error to match copy{in,out}() behaviour * rather than returning ENOMEM like mlock() would. @@ -247,10 +243,8 @@ trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len), VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); -#ifdef CONTAINERS rusage_set(curproc, RUSAGE_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); -#endif } /* >>> TRUNCATED FOR MAIL (1000 lines) <<<