From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: Re: [PATCH 4/9] move x86's simple heap management to common code Date: Thu, 2 Jan 2014 16:17:08 +0100 Message-ID: <20140102151707.GC9725@hawk.usersys.redhat.com> References: <1386175377-23086-1-git-send-email-drjones@redhat.com> <1386175377-23086-5-git-send-email-drjones@redhat.com> <20131229063024.GC13601@cbox> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org To: Christoffer Dall Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33989 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbaABPRK (ORCPT ); Thu, 2 Jan 2014 10:17:10 -0500 Content-Disposition: inline In-Reply-To: <20131229063024.GC13601@cbox> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, Dec 28, 2013 at 10:30:24PM -0800, Christoffer Dall wrote: > > + > > + if (s != (s & ~(pagesize - 1))) { > > you're just testing 'if (s & (pagesize -1))' right? yeah, I'll simplify that. > > > + s += pagesize; > > + s &= ~(pagesize - 1); > > + p = (void *)s; > > + } > > a one-line comment on this block saying 'page-align start of heap would > be nice. added > > > + > > + while (size >= pagesize) { > > + *(void **)p = free_head; > > + free_head = p; > > + p += pagesize; > > + size -= pagesize; > > + } > > you could also be nice and comment this block of code, saying something > like "set up linked list of free pages using the pages themselves as the > data structure" if you should feel so inclined. added "link free pages" > > why are you not trusting start to be page aligned but you are trusting > size to be? If size is smaller than pagesize then this loop will go > nuts won't it? I don't see how. As soon as size is less than pagesize we won't [re]enter the loop, and thus it can never go negative (big positive). drew