From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 15 15:04:25 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C65D7106567E; Thu, 15 Jul 2010 15:04:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 2448D8FC21; Thu, 15 Jul 2010 15:04:24 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o6FF4B8n002155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Jul 2010 18:04:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o6FF4BBO005966; Thu, 15 Jul 2010 18:04:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o6FF4Bxv005965; Thu, 15 Jul 2010 18:04:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 15 Jul 2010 18:04:11 +0300 From: Kostik Belousov To: kalash nainwal Message-ID: <20100715150411.GV2381@deviant.kiev.zoral.com.ua> References: <201007150811.11721.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YwTTlJgQ7QoYB9ta" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_20, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: how to do page level mem alloc in freebsd kernel? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 15:04:25 -0000 --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 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--