[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XenPPC] [PATCH] [POWERPC][XEN] Mark heap memory based on boot_of.c's allocator



On Mon, 2007-01-15 at 18:01 -0500, Jimi Xenidis wrote:
> > @@ -530,6 +538,33 @@ static ulong boot_of_alloc(ulong size)
> >
> >          pos = pos + i;
> >      }
> > +}
> > +
> > +int boot_of_mem_avail(int pos, ulong *startpage, ulong *endpage)
> If you'd like to hide the bitmap, then perhaps the first arg should
> be a start address and return the address of the next "used" page?

That's an idea. However, I was thinking something more along the lines
of an opaque iterator token.

> > +{
> > +    ulong freebit;
> > +    ulong usedbit;
> > +
> > +    /* find first free page. */
> > +    freebit = find_next_zero_bit(mem_available_pages,
> > MEM_AVAILABLE_PAGES, pos);
> > +    if (freebit >= MEM_AVAILABLE_PAGES) {
> > +        /* We know everything after MEM_AVAILABLE_PAGES is still
> > free. */
> > +        *startpage = MEM_AVAILABLE_PAGES << PAGE_SHIFT;
> > +        *endpage = ~0UL;
> > +        return -1;
> > +    }
> > +    *startpage = freebit << PAGE_SHIFT;
> > +
> > +    /* now find first used page after that. */
> > +    usedbit = find_next_bit(mem_available_pages,
> > MEM_AVAILABLE_PAGES, freebit);
> > +    if (usedbit >= MEM_AVAILABLE_PAGES) {
> > +        /* We know everything after MEM_AVAILABLE_PAGES is still
> > free. */
> > +        *endpage = ~0UL;
> > +        return -1;
> > +    }
> > +    *endpage = usedbit << PAGE_SHIFT;
> 
> I'm not 100% but the code below looks like require that end represent
> a free page so "usedbit - 1"?

It's actually the address of the end of the free memory. For example, if
you have a single page available, let's say at 0x4000, start would be
0x4000 and end would be 0x5000. The length is end - start, or 0x1000.

> > @@ -214,16 +148,22 @@ void memory_init(module_t *mod, int mcou
> >
> >      printk("End of RAM: %luMiB (%luKiB)\n", eomem >> 20, eomem >>
> > 10);
> >
> > -    /* Architecturally the first 4 pages are exception hendlers, we
> > -     * will also be copying down some code there */
> > +    /* Architecturally the first 4 pages are exception handlers. */
> >      heap_start = 4 << PAGE_SHIFT;
> > -    if (oftree < (ulong)_start)
> > -        heap_start = ALIGN_UP(oftree_end, PAGE_SIZE);
> > -
> 
> all the images below are in the bitmap, so can;t you use
> boot_of_mem_avail() to figure this out?

Yes, and that makes me very happy. :) Revised patch follows.

-- 
Hollis Blanchard
IBM Linux Technology Center


_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.