Hugh Dickins wrote: > On Wed, 24 Jan 2007, Nick Piggin wrote: > >>When mremap()ing virtual addresses, some architectures (read: MIPS) switches >>underlying pages if encountering ZERO_PAGE(old_vaddr) != ZERO_PAGE(new_vaddr). >> >>The problem is that the refcount and mapcount remain on the old page, while >>the actual pte is switched to the new one. This would counter underruns and >>confuse the rmap code. > > > Good point. Nasty. > > >>Fix it by actually moving accounting info to the new page. Would it be neater >>to do this in move_pte? maybe rmap.c? (nick mumbles something about not >>accounting ZERO_PAGE()s) > > > Tiresome, I can quite see why it brings you to mumbling. > > Though it looks right, I do hate the patch cluttering up move_ptes() > like that: will the compiler be able to work out that that "unlikely" > means impossible (and optimize away the code) on all arches but MIPS? > Even if it can, I'd rather not see it there. > > Could you make the MIPS move_pte() a proper function, say in > arch/mips/mm/init.c next to setup_zero_pages(), and do that tiresome > stuff there - should then be able to assume ZERO_PAGEs and skip the > BUG_ON embellishments. > > Utter nit-of-nits: my sense of symmetry prefers that you put_page() > after page_remove_rmap() instead of before. OK, how's this one? Not tested on MIPS, but the same move_pte compiled on i386 here. I sent Ralf a little test program that should eventually free a ZERO_PAGE if it is run a few times (with a non-zero zero_page_mask). Do you have time to confirm, Ralf? Thanks, Nick -- SUSE Labs, Novell Inc.