From owner-freebsd-hackers Mon Feb 3 17:14:45 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id RAA04893 for hackers-outgoing; Mon, 3 Feb 1997 17:14:45 -0800 (PST) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id RAA04880 for ; Mon, 3 Feb 1997 17:14:38 -0800 (PST) Received: from current1.whistle.com (current1.whistle.com [207.76.205.22]) by alpo.whistle.com (8.8.5/8.8.4) with SMTP id RAA22981; Mon, 3 Feb 1997 17:11:19 -0800 (PST) Message-ID: <32F68C4F.3F54BC7E@whistle.com> Date: Mon, 03 Feb 1997 17:09:35 -0800 From: Julian Elischer Organization: Whistle Communications X-Mailer: Mozilla 3.0Gold (X11; I; FreeBSD 2.2-CURRENT i386) MIME-Version: 1.0 To: Bill Kish CC: hackers@freefall.freebsd.org Subject: Re: kernel malloc options References: <199702031942.OAA18041@browncow.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Bill Kish wrote: > I'm working on a a Network related module which performs a function > similar to Network Address Translation. This module needs to > dynamically allocate small (~40 byte) structures to keep track of > currently established TCP connections between machines on the "inside" > and "outside" networks. Wow, a couple of months ago we had no address translation, now we have *4* different ones.. :) > > Currently, I'm malloc()ing these structures as needed using the > following parameters: > > malloc((u_long)sizeof(*conxn), M_TEMP, M_NOWAIT) > > This appears to work fine in my initial lightly loaded tests, > however, I'm concerned about what will happen when the system is under > heavy load. I have the following questions and would appreciate any > advice offered! What I do is cache a certain number of these.. I keep a free_thing list which will hold a maximum of N items If I ever free more than N then I start actually doing "free(x, M_TEMP)", but until then I just keep them locally, this usually means that if the number of items is gradually increasing I'm doing malloc's, but with small scale fluctuations, they are satisfied from the cache. of course malloc/free are not all that expensive in general.. > > 1) Is malloc() a reasonable allocator for small highly dynamic > objects? > > 2) Is M_TEMP a good choice? Does it make a difference? it's fine. to use any other, you'd have to edit malloc.h and for LKM stuff that's not an option. > > 3) Are there any config options that affect the amount of pinned > kernel memory available for malloc? The system will be doing > little else besides dealing with these packets... > > > > Thanks In Advance, > > -BK > --