Re: copy_page_range

Linus Torvalds (torvalds@transmeta.com)
Fri, 9 Jan 1998 11:51:12 -0800


In article <199801090810.JAA08422@sunsite.ms.mff.cuni.cz> you write:
>Hi Linus, hi linux-kernel!
>
>Yeasterday I just go upset again by seeing assembly output of
>copy_page_range. Yes, gcc does a poor job with inlining, but even if it
>compiled optimal program, it would have several unnecessary things.

Actually, less than you think.

>So I sat down and wrote a new copy_page_range without inlining.

I liked your version, and I actually even applied the patch for about
five minutes, until I noticed that you actually optimized away a few
rather important things.

Your copy_page_range() doesn't actually work correctly. It breaks badly
when it hits a sparse region that doesn't have pmd's or pgd's. Look at
what happens to "address" for that case: not only does it get
incorrectly updated (ie not at all), but it also never gets tested
against "end", so the thing can potentially start doing strange things
to kernel mappings etc.

But if you can fix the problems and keep it readable enough that I can
trust that they really are gone I'd be more than happy to apply
something like this patch. I'm not all that excited about the code gcc
generates for the current code either.

Linus