Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 2010 20:41:20 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        mdf@freebsd.org
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Multi-zone malloc(9)
Message-ID:  <20100722174120.GR2381@deviant.kiev.zoral.com.ua>
In-Reply-To: <AANLkTikoY8CuAF3DThBAXH_mu1QAuUWyRMtkaIomaoi7@mail.gmail.com>
References:  <AANLkTikoY8CuAF3DThBAXH_mu1QAuUWyRMtkaIomaoi7@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--ngluH3DisTFy0Cjl
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 22, 2010 at 09:54:51AM -0700, mdf@freebsd.org wrote:
> Occasionally we run into use-after-free and malloc'd buffer overrun
> scenarios.  When this happens it can be rather difficult to determine
> what code is at fault, since e.g. every 64 byte allocation, regardless
> of malloc type, comes from the same UMA zone.  This means that an
> overflow in M_TEMP will affect M_DEVBUF, etc.  Adding multiple uma
> zones for each bucket size means that we can hash on the malloc type's
> shortdesc field so that there are fewer collisions and misused memory
> from one malloc type only affects a subset of other malloc types.
> Varying the hash means that, with several crashes due to memory stomp,
> a single malloc type can usually be determined as the culprit.  If the
> bug isn't obvious from inspection at this point, MemGuard will help
> catch the offender.
>=20
> The patch at:
>=20
>    http://people.freebsd.org/~mdf/multizone_malloc.patch
>=20
> implements an optional multi-zone malloc(9).  By default there is a
> single zone, and MALLOC_DEBUG_MAXZONES can be specified in the kernel
> configuration file.  A ddb function will print all the malloc types
> that have a hash collision with the specified type.
>=20
> A few questions for -arch@:
>=20
>  - We found this very useful at Isilon.  Should this go into CURRENT?
>=20
>  - Should this be on by default for GENERIC?  The memory overhead of 8
> uma zones per malloc allocation size shouldn't be very large.
>=20
>  - would a __FreeBSD_version bump be needed since the malloc_internal
> type is known by user-space?

Can you quantify the overhead, both in CPU time and memory usage terms
? I would much prefer to have debug and non-debug kernels to run
similar code, in other words, can the multizone allocation be enabled
unconditionally ?

--ngluH3DisTFy0Cjl
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEUEARECAAYFAkxIgr8ACgkQC3+MBN1Mb4j2cwCfSRtigwr3xkLvmJ0eAbh4ho2y
+70Al1bwaSE6Q4RtO+BaHj0hT6X8oRc=
=mVa3
-----END PGP SIGNATURE-----

--ngluH3DisTFy0Cjl--



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