OSDN Git Service

s390/mm: avoid empty zero pages for KVM guests to avoid postcopy hangs
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 24 Aug 2017 10:55:08 +0000 (12:55 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 29 Aug 2017 14:31:27 +0000 (16:31 +0200)
commitfa41ba0d08de7c975c3e94d0067553f9b934221f
tree2e164b5bcec801921ee648bd625515dba2d34c80
parent28b841b3a7cb07a4bfd436a15b31bc88509dcf9a
s390/mm: avoid empty zero pages for KVM guests to avoid postcopy hangs

Right now there is a potential hang situation for postcopy migrations,
if the guest is enabling storage keys on the target system during the
postcopy process.

For storage key virtualization, we have to forbid the empty zero page as
the storage key is a property of the physical page frame.  As we enable
storage key handling lazily we then drop all mappings for empty zero
pages for lazy refaulting later on.

This does not work with the postcopy migration, which relies on the
empty zero page never triggering a fault again in the future. The reason
is that postcopy migration will simply read a page on the target system
if that page is a known zero page to fault in an empty zero page.  At
the same time postcopy remembers that this page was already transferred
- so any future userfault on that page will NOT be retransmitted again
to avoid races.

If now the guest enters the storage key mode while in postcopy, we will
break this assumption of postcopy.

The solution is to disable the empty zero page for KVM guests early on
and not during storage key enablement. With this change, the postcopy
migration process is guaranteed to start after no zero pages are left.

As guest pages are very likely not empty zero pages anyway the memory
overhead is also pretty small.

While at it this also adds proper page table locking to the zero page
removal.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/pgtable.h
arch/s390/mm/gmap.c