From owner-freebsd-arch Sun Sep 3 8:50: 5 2000 Delivered-To: freebsd-arch@freebsd.org Received: from gatekeeper.tsc.tdk.com (gatekeeper.tsc.tdk.com [207.113.159.21]) by hub.freebsd.org (Postfix) with ESMTP id 109D937B42C for ; Sun, 3 Sep 2000 08:50:03 -0700 (PDT) Received: from imap.gv.tsc.tdk.com (imap.gv.tsc.tdk.com [192.168.241.198]) by gatekeeper.tsc.tdk.com (8.8.8/8.8.8) with ESMTP id IAA25847 for ; Sun, 3 Sep 2000 08:50:02 -0700 (PDT) (envelope-from gdonl@tsc.tdk.com) Received: from salsa.gv.tsc.tdk.com (salsa.gv.tsc.tdk.com [192.168.241.194]) by imap.gv.tsc.tdk.com (8.9.3/8.9.3) with ESMTP id IAA10134 for ; Sun, 3 Sep 2000 08:50:02 -0700 (PDT) (envelope-from Don.Lewis@tsc.tdk.com) Received: (from gdonl@localhost) by salsa.gv.tsc.tdk.com (8.8.5/8.8.5) id IAA19487 for arch@freebsd.org; Sun, 3 Sep 2000 08:50:01 -0700 (PDT) Date: Sun, 3 Sep 2000 08:50:01 -0700 (PDT) From: Don Lewis Message-Id: <200009031550.IAA19487@salsa.gv.tsc.tdk.com> To: arch@freebsd.org Subject: Request for review: restructuring of per-uid resource limits Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The current implemention of the per-uid resource limits has some problems: Increases and decreases in the size of socket buffers and the creation and destruction of processes (calls to chgsbsize() and chgproccnt()) happen much more frequently than credential changes, but the chgsbsize() and chgproccnt() do a hash lookup of the uidinfo structure on the fly for each call. This is especially bad in the case of chgsbsize() which may be called from an interrupt context. It would be much more efficient to do the lookups and save the pointers to the uidinfo structures when credentials are changed and just follow the pointers to update the resource consumption. chgsbsize() can be called from an interrupt context, when the hash table may be in an inconsistent state. Changes to the hash table could be protected by splnet(), but that hurts performance by increasing the amount of time that interrupts are blocked. Under certain circumstances it might be possible for chgsbsize() to call MALLOC(..., M_WAITOK), which would be bad if done in an interrupt context. Most of this code probably belongs in kern_resource.c rather than kern_proc.c. The patch at fixes the above problems, at the expense of a little more memory and some extra messyness in a few other parts of the code. The only real uglyness is in kern_prot.c, which should probably have some duplicate code sequences moved to separate functions. The chgproccnt() and chgsbsize() functions are a lot cleaner should be quite a bit faster. I applied this patch to a couple day old version of -current. It compiles without any extra warnings, and seems to run ok under the light testing that I've done. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message