From owner-p4-projects@FreeBSD.ORG Fri Jul 16 14:54:14 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 30D601065676; Fri, 16 Jul 2010 14:54:14 +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 DBDE01065673 for ; Fri, 16 Jul 2010 14:54:13 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id B02AE8FC08 for ; Fri, 16 Jul 2010 14:54:13 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o6GEsDeU053407 for ; Fri, 16 Jul 2010 14:54:13 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o6GEsDGP053405 for perforce@freebsd.org; Fri, 16 Jul 2010 14:54:13 GMT (envelope-from trasz@freebsd.org) Date: Fri, 16 Jul 2010 14:54:13 GMT Message-Id: <201007161454.o6GEsDGP053405@repoman.freebsd.org> X-Authentication-Warning: repoman.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 181051 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: Fri, 16 Jul 2010 14:54:14 -0000 http://p4web.freebsd.org/@@181051?ac=10 Change 181051 by trasz@trasz_victim on 2010/07/16 14:53:13 Straighten up the situation with pty accounting. Still not quite right, but that will require some more thinking. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#38 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#18 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#38 (text+ko) ==== @@ -1491,6 +1491,7 @@ return (1); } +#ifndef CONTAINERS /* * Change the count associated with number of pseudo-terminals * a given user is using. When 'max' is 0, don't enforce a limit @@ -1515,3 +1516,4 @@ } return (1); } +#endif ==== //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#18 (text+ko) ==== @@ -576,6 +576,10 @@ tty_lock(tp); tty_rel_gone(tp); +#ifdef CONTAINERS + rusage_sub(td->td_proc, RUSAGE_PTY, 1); +#endif + /* * Open of /dev/ptmx or /dev/ptyXX changes the type of file * from DTYPE_VNODE to DTYPE_PTS. vn_open() increases vnode @@ -682,7 +686,9 @@ if (psc->pts_unit >= 0) free_unr(pts_pool, psc->pts_unit); +#ifndef CONTAINERS chgptscnt(psc->pts_uidinfo, -1, 0); +#endif uifree(psc->pts_uidinfo); knlist_destroy(&psc->pts_inpoll.si_note); @@ -714,24 +720,18 @@ pts_alloc(int fflags, struct thread *td, struct file *fp) { int unit, ok; -#ifdef CONTAINERS - int error; -#endif 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_PTY, 1); +#else PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); -#ifdef CONTAINERS - error = rusage_add(p, RUSAGE_PTY, 1); -#endif PROC_UNLOCK(p); -#ifdef CONTAINERS - if (ok != !error) - printf("pts_alloc: ok = %d, error = %d\n", ok, error); #endif if (!ok) return (EAGAIN); @@ -739,9 +739,10 @@ /* Try to allocate a new pts unit number. */ unit = alloc_unr(pts_pool); if (unit < 0) { - chgptscnt(uid, -1, 0); #ifdef CONTAINERS rusage_sub(p, RUSAGE_PTY, 1); +#else + chgptscnt(uid, -1, 0); #endif return (EAGAIN); } @@ -773,24 +774,18 @@ struct cdev *dev, const char *name) { int ok; -#ifdef CONTAINERS - int error; -#endif 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_PTY, 1); +#else PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); -#ifdef CONTAINERS - error = rusage_add(p, RUSAGE_PTY, 1); -#endif PROC_UNLOCK(p); -#ifdef CONTAINERS - if (ok != !error) - printf("pts_alloc: ok = %d, error = %d\n", ok, error); #endif if (!ok) return (EAGAIN);