> On Jul 26, 2019, at 1:44 AM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote: > > On 07/25, Song Liu wrote: >> >> I guess I know the case now. We can probably avoid this with an simple >> check for old_page == new_page? > > better yet, I think we can check PageAnon(old_page) and avoid the unnecessary > __replace_page() in this case. See the patch below. I added PageAnon(old_page) check in v9 of the patch. > > Anyway, why __replace_page() needs to lock both pages? This doesn't look nice > even if it were correct. I think it can do lock_page(old_page) later. > Agreed. I have changed the v9 to only unmap old_page. So it should be cleaner. Thanks again for these good suggestions, Song