Messages in this thread | | | From | Linus Torvalds <> | Date | Mon, 14 Mar 2011 10:30:11 -0700 | Subject | Re: [PATCH] mm: PageBuddy and mapcount underflows robustness |
| |
On Mon, Mar 14, 2011 at 9:59 AM, Andrea Arcangeli <aarcange@redhat.com> wrote: > > +#define PAGE_BUDDY_MAPCOUNT_VALUE (-1024*1024)
I realize that this is a nitpick, but from a code generation standpoint, large random constants like these are just nasty.
I would suggest aiming for constants that are easy to generate and/or fit better in the code stream. In many encoding schemes (eg x86), -128 is much easier to generate, since it fits in a signed byte and allows small instructions etc. And in most RISC encodings, 8- or 16-bit constants can be encoded much more easily than something like your current one, and bigger ones often end up resulting in a load from memory or at least several immediate-building instructions.
> - __ClearPageBuddy(page); > + if (PageBuddy(page)) /* __ClearPageBuddy VM_BUG_ON(!PageBuddy(page)) */ > + __ClearPageBuddy(page);
Also, this is just disgusting. It adds no safety here to have that VM_BUG_ON(), so it's just unnecessary code generation to do this. Also, we don't even WANT to do that stupid "__ClearPageBuddy()" in the first place! What those two code-sites actually want are just a simple
reset_page_mapcount(page);
which does the right thing in _general_, and not just for the buddy case - we want to reset the mapcount for other reasons than just pagebuddy (ie the underflow/overflow case).
And it avoids the VM_BUG_ON() too, making the crazy conditionals be not needed.
No?
Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |