From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [PATCH 4/9] move x86's simple heap management to common code Date: Thu, 2 Jan 2014 09:17:42 -0800 Message-ID: <20140102171742.GC27806@cbox> References: <1386175377-23086-1-git-send-email-drjones@redhat.com> <1386175377-23086-5-git-send-email-drjones@redhat.com> <20131229063024.GC13601@cbox> <20140102151707.GC9725@hawk.usersys.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org To: Andrew Jones Return-path: Received: from mail-pa0-f44.google.com ([209.85.220.44]:44487 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbaABRRY (ORCPT ); Thu, 2 Jan 2014 12:17:24 -0500 Received: by mail-pa0-f44.google.com with SMTP id fa1so14748405pad.31 for ; Thu, 02 Jan 2014 09:17:24 -0800 (PST) Content-Disposition: inline In-Reply-To: <20140102151707.GC9725@hawk.usersys.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Jan 02, 2014 at 04:17:08PM +0100, Andrew Jones wrote: > 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). > yeah you're right. duh.