Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Feb 2002 13:54:55 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Alfred Perlstein <alfred@FreeBSD.ORG>
Cc:        Matthew Dillon <dillon@apollo.backplane.com>, Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>, current@FreeBSD.ORG, John Baldwin <jhb@FreeBSD.ORG>
Subject:   Re: How to fix malloc.
Message-ID:  <3C780FAF.F95A23EF@mindspring.com>
References:  <200201051752.g05Hq3gG074525@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp> <XFMail.020114020307.jhb@FreeBSD.org> <200201241022.g0OAMISM093913@faber.r.dl.itc.u-tokyo.ac.jp> <20020124024534.V13686@elvis.mu.org> <200202131739.g1DHdZT5023794@rina.r.dl.itc.u-tokyo.ac.jp> <200202190945.g1J9j9kg076110@rina.r.dl.itc.u-tokyo.ac.jp> <200202232051.g1NKpE741310@apollo.backplane.com> <20020223211449.GJ80761@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alfred Perlstein wrote:
> All these per-subsystem free-lists are making me nervous in both
> complexity and wasted code...

Me too.

> Ok, instead of keeping all these per-subsystem free-lists here's what
> we do:
> 
> In kern_malloc:free() right at the point of
>   if (size > MAXALLOCSAVE) we check if we have Giant or not.
>     if we do not then we simply queue the memory
>     however, if we do then we call into kmem_free with all the queued memory.
> 
> This ought to solve the issue without making us keep all these
> per-cpu caches.

One modification: limit the number that are freed per invocation
to some number small enough that there won't be a big latency.

Once everything gets to this point, though, there will be nothing
to trigger a free with giant held, and you'll just queue things
up forever.

Really, we need counted queues -- queues that know the number of
elemenets on them.  This is a requirement for RED-Queueing, and
it will let us know when the queue gets deep... then you can grab
giant, and flush down the queue if it hits a high watermark.

Obviously, the correct way to handle this is per CPU memory pools
that don't have any need for lock contention at all on the "real"
frees.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C780FAF.F95A23EF>