Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2010 18:04:11 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        kalash nainwal <kalash.nainwal@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: how to do page level mem alloc in freebsd kernel?
Message-ID:  <20100715150411.GV2381@deviant.kiev.zoral.com.ua>
In-Reply-To: <AANLkTilkxsfj-LsJ9-Al-nMnvrzpcjaGOwRFihRiHv-W@mail.gmail.com>
References:  <AANLkTikg2K95ffSL_dAnYIri_NnqUGarViVETjrew8EB@mail.gmail.com> <201007150811.11721.jhb@freebsd.org> <AANLkTilkxsfj-LsJ9-Al-nMnvrzpcjaGOwRFihRiHv-W@mail.gmail.com>

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

--YwTTlJgQ7QoYB9ta
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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. :) =9Amalloc(=
4096)
> > will be aligned on a 4096-byte boundary if PAGE_SIZE is >=3D 4096. =9AMy
> > understanding is that objects returned from malloc() are aligned to the
> > smallest power-of-2 value >=3D the requested size up to a page. =9AAllo=
cations
> > larger than a page are page aligned. =9ASo a malloc of 24 bytes or 32 b=
ytes is
> > 32-byte aligned for example.
> >
>=20
> Thanks John for explaining.
>=20
> 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
             ^^^^^^kernel_map.
> purpose fine.
>=20
> Regards,
> -Kalash
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"

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

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

iEYEARECAAYFAkw/I2sACgkQC3+MBN1Mb4gsqACg4QUGH4z/5/u7u+znZupw0b1i
P3kAnRa0rMG7JK/wN7GCM3Q0btfWqaNC
=xrbY
-----END PGP SIGNATURE-----

--YwTTlJgQ7QoYB9ta--



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