[PATCH] ptwalk: change_protection
Begin the pagetable walker cleanup with a straightforward example, mprotect's change_protection. Started out from Nick Piggin's for_each proposal, but I prefer less hidden; and these are all do while loops, which degrade slightly when converted to for loops. Firmly agree with Andi and Nick that addr,end is the way to go: size is good at the user interface level, but unhelpful down in the loops. And the habit of an "address" which is actually an offset from some base has bitten us several times: use proper address at each level, whyever not? Don't apply each mask at two levels: all we need is a set of macros pgd_addr_end, pud_addr_end, pmd_addr_end to give the address of the end of each range. Which need to take the min of two addresses, with 0 as the greatest. Started out with a different macro, assumed end never 0; but clear_page_range (alone) might be passed end 0 by some out-of-tree memory layouts: could special case it, but this macro compiles smaller. Check "addr != end" instead of "addr < end" to work on that end 0 case. Signed-off-by:Hugh Dickins <hugh@veritas.com> Signed-off-by:
Andrew Morton <akpm@osdl.org> Signed-off-by:
Linus Torvalds <torvalds@osdl.org>
Showing
Please register or sign in to comment