]> git.baikalelectronics.ru Git - kernel.git/commit
mm/cow: don't bother write protecting already write-protected pages
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 9 Jul 2018 20:19:49 +0000 (13:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 25 Aug 2018 20:15:03 +0000 (13:15 -0700)
commit1a0a5d4c61e4b6816610ef442bfdcf4d7bdd1250
treeecae1ad75f1b24eba699b6aa0e2a2cb09a7d1c7f
parent4514841f41ed85eaab46f4a3ac52ff0469d51cc7
mm/cow: don't bother write protecting already write-protected pages

This is not normally noticeable, but repeated forks are unnecessarily
expensive because they repeatedly dirty the parent page tables during
the page table copy operation.

It's trivial to just avoid write protecting the page table entry if it
was already not writable.

This patch was inspired by

    https://bugzilla.kernel.org/show_bug.cgi?id=200447

which points to an ancient "waste time re-doing fork" issue in the
presence of lots of signals.

That bug was fixed by Eric Biederman's signal handling series
culminating in commit bc3a7d03c31e ("signal: Don't restart fork when
signals come in"), but the unnecessary work for repeated forks is still
work just fixing, particularly since the fix is trivial.

Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory.c