Subject: Re: Corret way to allocate memory in kernel ?
To: Jason Thorpe <email@example.com>
From: Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>
Date: 08/15/1996 14:06:40
> On Thu, 15 Aug 1996 23:17:31 +1000 (EST)
> Darren Reed <firstname.lastname@example.org> wrote:
> > And what about using MALLOC() vs malloc() in the kernel ?
> > Seems like I want to do MALLOC(), for the spl() ?
> > But grep'ing through a 1.1 kernel shows a fair amount of mallc()...
> Most places just use malloc(). Really, MALLOC() is just an attept to
> optimize ... you'll note that if DIAGNOSTIC is defined, it just expands
> to a call to malloc() ... malloc() does an splimp() internally.
> It's mostly a stylistic thing, I think... I usually just use malloc().
it boils down to optimization. MALLOC should be used in 'critical
paths'. How you do determine if something's a critical path?
"profile" is one good answer.
I just about always use malloc(), unless i have good reason to believe
that a piece of code would be used sufficiently frequently that the
inlining would be of significant benefit.