From 1f3dc3c25b3194f14d9484df53179f696e895393 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 10 Oct 2012 17:38:41 +0800 Subject: [PATCH] kmalloc: Add comment about alignment property --- sys/kern/kern_slaballoc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_slaballoc.c b/sys/kern/kern_slaballoc.c index 611f3013f2..48cc760ffd 100644 --- a/sys/kern/kern_slaballoc.c +++ b/sys/kern/kern_slaballoc.c @@ -78,13 +78,18 @@ * * Allocations >= ZoneLimit go directly to kmem. * + * Alignment properties: + * - All power-of-2 sized allocations are power-of-2 aligned. + * - Allocations with M_POWEROF2 are power-of-2 aligned on the nearest + * power-of-2 round up of 'size'. + * - Non-power-of-2 sized allocations are zone chunk size aligned (see the + * above table 'Chunking' column). + * * API REQUIREMENTS AND SIDE EFFECTS * * To operate as a drop-in replacement to the FreeBSD-4.x malloc() we * have remained compatible with the following API requirements: * - * + small power-of-2 sized allocations are power-of-2 aligned (kern_tty) - * + all power-of-2 sized allocations are power-of-2 aligned (twe) * + malloc(0) is allowed and returns non-NULL (ahc driver) * + ability to allocate arbitrarily large chunks of memory */ -- 2.41.0