From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 1 23:47:26 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 9BC66106564A for ; Mon, 1 Mar 2010 23:47:26 +0000 (UTC) (envelope-from shrivatsan_v@yahoo.com) Received: from web112006.mail.gq1.yahoo.com (web112006.mail.gq1.yahoo.com [67.195.23.84]) by mx1.freebsd.org (Postfix) with SMTP id 55C988FC13 for ; Mon, 1 Mar 2010 23:47:26 +0000 (UTC) Received: (qmail 53764 invoked by uid 60001); 1 Mar 2010 23:47:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1267487243; bh=Ds6rTIr4Onphax3SIkqcILW1T8w7JTYYQ2PsTu1Yke0=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=bTKth+O0BZIkBEio6p9carsLGj7/ak7iIckec9/or0GgqwtGP2ni/XCunJv/ckPdekk7+EyjtvP+kU0iQe1BMD7AUuROzM4j+CYNgaFHuhKMSyRQe+AigBbHUDI2edNzP0V5xMIJHr7pTkqWrHcsr2h22MKYV9ek2WZxDB1SYGI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=HvY/75ZHE7QHft3Xo7pd/GRYQUgaB+y58VOD2KrtbY212dREx+qqCcC+gX5b/hPDm7Nd0PsUtQ6WQWLWXiWavbE14mpc76lut3w3oQo5Fq0riRG6BESK0uuT7N2ZYvNxqN3YiRc9dQ+Q7ggWIXxu6uNZtbB9U89OwxHy5AkCt04=; Message-ID: <178848.53651.qm@web112006.mail.gq1.yahoo.com> X-YMail-OSG: _gpwkLsVM1lhji6ss3iUG2xEP4AN0tAFc5LCb1MBPnBhYmCb.NbCcxYNx5WfBQIdDjxfFyD2QJ.Pkl2IzOOHdzXUdfyhkokfvFOK37b4g8BnrzwPcJGwBvJ3SaFelobl9kZ.xQ2VWEtHbtv9W39mANZnoWBV2X6SQlPt8DpAEyGU6iqGf.0eAH41LYeTqme0ctGesuUW4vpUj2.Je0b2DHW43rfpUACpKRPGp7BYGH1FKBJRVjWtU4lOzaAtYjXDvGqZ5QILQQ9n6ImewV3JsQ-- Received: from [66.129.224.36] by web112006.mail.gq1.yahoo.com via HTTP; Mon, 01 Mar 2010 15:47:23 PST X-Mailer: YahooMailClassic/9.2.12 YahooMailWebService/0.8.100.260964 Date: Mon, 1 Mar 2010 15:47:23 -0800 (PST) From: Shrivatsan To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: shrivatsan@gmail.com Subject: kernel malloc() and free() 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: Mon, 01 Mar 2010 23:47:26 -0000 Hi, I am looking at the code that allocates and frees kernel memory. I understand that allocating kernel memory is quite different from the user level mallocs. In case of user level mallocs, we allocate requested size + 4 bytes and store the requested size in the additional 4 bytes. However, in the case of kernel, allocating an additional 4 bytes is a overhead since the request might fall in the next bucket. I looked into the code and the documentation in the file uma_int.h, but I don't quite understand the relation between slabs, zones and keg. How do we determine the size of the memory that we are trying to free from given the virtual address? Thanks in advance for the help. -shrivatsan