Re: [PATCH 4/5] mm: Do early cow for pinned pages during fork() for ptes
From: Linus Torvalds
Date: Wed Sep 23 2020 - 16:26:15 EST
On Tue, Sep 22, 2020 at 6:03 PM Peter Xu <peterx@xxxxxxxxxx> wrote:
>
> > If we rely on "copy_ret == COPY_MM_BREAK_COW" we can unify "again" and
> > "again_break_cow", we don't need to clear ->cow_new_page, this makes the
> > logic more understandable. To me at least ;)
>
> I see your point. I'll definitely try it out. I think I'll at least use what
> you preferred above since it's actually the same as before, logically. Then
> I'll consider drop the again_break_cow, as long as I'm still as confident after
> I do the change on not leaking anything :).
So the two patches I sent out to re-organize copy_one_pte() were
literally meant to make all this mess go away.
IOW, the third patch would be something (COMPLETELY UNTESTED) like the attached.
I think the logic for the preallocation is fairly obvious, but it
might be better to allocate a batch of pages for all I know. That
said, I can't really make myself care about the performance of a
fork() after you've pinned pages in it, so..
Linus
Attachment:
patch
Description: Binary data