Re: [Lhms-devel] [RFC] free_area[] bitmap elimination [0/3]

Dave Hansen
2004-08-24T02:49:23Z

On Mon, 2004-08-23 at 17:00, Hiroyuki KAMEZAWA wrote:
> In this patch, "whether a page is free and in buddy allocator ?" is confirmed by
> page_count(page) == 0 and page_order(page) == valid_order.
> A valid_order is a value between (unsigned long)~0 - (unsigned long)~(MAX_ORDER)
>
> But there may be pages which have vague page->private and conflict with my
> buddy page checking.
> I'd like to read free_pages_check() more and take page->flags into account.

I'm not saying that there *is* a bug with your code, just that
page->private has no *guarantees* about its contents, and there *can* be
a bug under certain conditions. You rely on it not having particular
values but, since there are no checks and no zeroing, you really can't
assume anything. Try setting page->private to random values just before
the free pages check, and I bet you'll eventually get some oopses.

So, either don't rely on page->private for page_order(), or zero out
page->private before you zero the count. Also, since you might
effectively be using one of these fields as a pseudo lock, make sure to
take memory ordering into account. Unless it's an atomic function with
a test, things can get reordered quite easily.

-- Dave