Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1E01Hn-0004ro-S1 for mharc-grub-devel@gnu.org; Tue, 02 Aug 2005 14:14:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E01Hj-0004li-1m for grub-devel@gnu.org; Tue, 02 Aug 2005 14:14:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E01Hb-0004hL-Q1 for grub-devel@gnu.org; Tue, 02 Aug 2005 14:14:33 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E01Ha-0004YJ-0S for grub-devel@gnu.org; Tue, 02 Aug 2005 14:14:30 -0400 Received: from [130.104.239.239] (helo=sprbodj.inma.ucl.ac.be) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E01Mf-0000su-CU for grub-devel@gnu.org; Tue, 02 Aug 2005 14:19:45 -0400 Received: from [192.168.0.20] (unknown [213.213.238.70]) by sprbodj.inma.ucl.ac.be (Postfix) with ESMTP id B2F9A19C8129 for ; Tue, 2 Aug 2005 20:06:50 +0200 (CEST) Message-ID: <42EFB636.1050606@inma.ucl.ac.be> Date: Tue, 02 Aug 2005 20:06:46 +0200 From: Vincent Guffens User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) X-Accept-Language: en MIME-Version: 1.0 To: The development of GRUB 2 References: <42EF862F.1080306@inma.ucl.ac.be> <42EF9CFB.7040804@yahoo.fr> In-Reply-To: <42EF9CFB.7040804@yahoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-ucl-inma-MailScanner-Information: Please contact the ISP for more information X-ucl-inma-MailScanner: Found to be clean X-MailScanner-From: guffens@inma.ucl.ac.be Content-Transfer-Encoding: quoted-printable Subject: Re: doc on memory management X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2005 18:14:41 -0000 Vincent Pelletier wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >=20 > Vincent Guffens wrote: >=20 >>I have written some doc about mm in grub2. >=20 >=20 > Nice work, explained with nice and clear schematics. > Now I understand that piece of code :). > I had trouble understanding : > the macro you explain in "Allocation memory" Is it the calculation of the number of blocks n to allocate ? > the reason why the first free chunk of the ring is sometime moved I found one reason in the Knuth's book I mentioned in the introduction=20 but I'm not too sure it really applies. The argument is that if you=20 always start looking at the same first header, you will tend to=20 accumulate after a few allocations/deallocations a long list of free=20 small chunks after the first free chunk. So if you have to allocate a=20 bigger block, you will have to traverse this list first. > the reason why alloc'ed chunks were removed from the list It makes the allocation faster as the list you have to traverse is smalle= r. > I wonder why the region header contains, to me, a useless field : addr. > It is only set in grub_mm_init_region, invariably to the first header > which is invariably at the same offset from the region beginning, > defined by GRUB_MM_ALIGN. I don't think loosing sizeof(int) bytes is > critical, though, as it would be padded anyway. It only made my > comprehension of what's going on a little harder :). yes, it is not used anywhere ! > I see a light improvement in grub_mm_init_region : > /* If this region is too small, ignore it. */ > if (size < GRUB_MM_ALIGN * 2) > return; > If the region is 2*GRUB_MM_ALIGN, we can put a grub_mm_header_t plus a > grub_mm_region_t, and it would be full. Maybe adding 1 byte (or more) > might make more sense (but has it any practical impact...). >=20 > My realloc implementation handled the case where the realloc'ed block > had enough space after to expand. I might send a patch for this someday > if anyone finds it interesting to add. That would probably be a better way of doing it. > I also implemented a memory defrag that merges successive free chunks i= n > one bigger. Although it relied on the fact both alloc'ed and free chuck= s > are known I think it can be adapted (if h->next !=3D h+h->size*16, don'= t > merge h and h->next) and even a bit faster (as we only see free chunks)= . I don't think this is needed in this case as all the necessary merging=20 is done when a chunk is freed. > Vincent Pelletier > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.1 (GNU/Linux) >=20 > iD8DBQFC75z7FEQoKRQyjtURAla2AJ9SZk9V8RSHhDHm0hajC5uOA+f28wCglptX > mpVBwRDWdcPc+uAxuSvJcWA=3D > =3D1Sd1 > -----END PGP SIGNATURE----- >=20 > =09 >=20 > =09 > =09 > _______________________________________________________________________= ____=20 > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messen= ger=20 > T=E9l=E9chargez cette version sur http://fr.messenger.yahoo.com >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel >=20 --=20 Vincent Guffens PhD Student UCL/CESAME tel: +32 10 47 80 30 Value your freedom, or you will lose it, teaches history. "Don't bother us with politics," respond those who don't want to learn. -- Richard M. Stallman