Date: Mon, 03 Feb 1997 17:09:35 -0800 From: Julian Elischer <julian@whistle.com> To: Bill Kish <kish@browncow.com> Cc: hackers@freefall.freebsd.org Subject: Re: kernel malloc options Message-ID: <32F68C4F.3F54BC7E@whistle.com> References: <199702031942.OAA18041@browncow.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > --
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32F68C4F.3F54BC7E>