Date: Thu, 15 Jul 2010 21:04:15 +0530 From: kalash nainwal <kalash.nainwal@gmail.com> To: Kostik Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: how to do page level mem alloc in freebsd kernel? Message-ID: <AANLkTimNDi0pdFx3mfzRnMCHOMWvXET-LB00QT81QcT1@mail.gmail.com> In-Reply-To: <20100715150411.GV2381@deviant.kiev.zoral.com.ua> References: <AANLkTikg2K95ffSL_dAnYIri_NnqUGarViVETjrew8EB@mail.gmail.com> <201007150811.11721.jhb@freebsd.org> <AANLkTilkxsfj-LsJ9-Al-nMnvrzpcjaGOwRFihRiHv-W@mail.gmail.com> <20100715150411.GV2381@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
2010/7/15 Kostik Belousov <kostikbel@gmail.com>: > On Thu, Jul 15, 2010 at 08:24:53PM +0530, kalash nainwal wrote: >> On Thu, Jul 15, 2010 at 5:41 PM, John Baldwin <jhb@freebsd.org> wrote: >> > On Thursday, July 15, 2010 6:28:53 am kalash nainwal wrote: >> >> Hi, >> >> >> >> I want to allocate one (or more) pages in kernel space. >> >> I'm not sure what is the api in freebsd (something which >> >> is similar to __get_free_pages() of linux). >> >> >> >> Would malloc(4096, ...) guarantee that the returned >> >> address is aligned on page boundary? >> > >> > Well, malloc(PAGE_SIZE) will align it on a page boundary. :) =A0malloc= (4096) >> > will be aligned on a 4096-byte boundary if PAGE_SIZE is >=3D 4096. =A0= My >> > understanding is that objects returned from malloc() are aligned to th= e >> > smallest power-of-2 value >=3D the requested size up to a page. =A0All= ocations >> > larger than a page are page aligned. =A0So a malloc of 24 bytes or 32 = bytes is >> > 32-byte aligned for example. >> > >> >> Thanks John for explaining. >> >> After going through the kernel src I was not sure about >> malloc, as the code is little hard to follow. However I figured >> kmem_alloc(kernel_pmap, PAGE_SIZE) would serve my > =A0 =A0 =A0 =A0 =A0 =A0 ^^^^^^kernel_map. oops. my bad. thanks for correcting.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimNDi0pdFx3mfzRnMCHOMWvXET-LB00QT81QcT1>