Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806436/?format=api
{ "id": 806436, "url": "http://patchwork.ozlabs.org/api/patches/806436/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1503908887-67060-2-git-send-email-borntraeger@de.ibm.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1503908887-67060-2-git-send-email-borntraeger@de.ibm.com>", "list_archive_url": null, "date": "2017-08-28T08:28:07", "name": "[1/1] s390/mm: avoid empty zero pages for KVM guests to avoid postcopy hangs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "6d8711fceed71f0213e9d9c22702c2a3535cb946", "submitter": { "id": 590, "url": "http://patchwork.ozlabs.org/api/people/590/?format=api", "name": "Christian Borntraeger", "email": "borntraeger@de.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1503908887-67060-2-git-send-email-borntraeger@de.ibm.com/mbox/", "series": [ { "id": 102, "url": "http://patchwork.ozlabs.org/api/series/102/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=102", "date": "2017-08-28T08:28:06", "name": "kernel fix for s390 postcopy hang", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/102/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806436/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806436/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xglKz3hSWz9s7p\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 28 Aug 2017 18:29:00 +1000 (AEST)", "from localhost ([::1]:37476 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dmFPh-0007lN-En\n\tfor incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 04:28:53 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33593)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <borntraeger@de.ibm.com>) id 1dmFPC-0007kP-83\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:28:23 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <borntraeger@de.ibm.com>) id 1dmFP7-0002I8-A8\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:28:22 -0400", "from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54958)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <borntraeger@de.ibm.com>)\n\tid 1dmFP7-0002Hm-12\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:28:17 -0400", "from pps.filterd (m0098399.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7S8RoXl133932\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 04:28:15 -0400", "from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2cm5wnn36a-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 04:28:15 -0400", "from localhost\n\tby e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <borntraeger@de.ibm.com>;\n\tMon, 28 Aug 2017 09:28:12 +0100", "from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198)\n\tby e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tMon, 28 Aug 2017 09:28:09 +0100", "from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com\n\t[9.149.105.58])\n\tby b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v7S8S9jO5636158; Mon, 28 Aug 2017 08:28:09 GMT", "from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id B377C4C040;\n\tMon, 28 Aug 2017 09:25:03 +0100 (BST)", "from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 9D88F4C046;\n\tMon, 28 Aug 2017 09:25:03 +0100 (BST)", "from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9])\n\tby d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS;\n\tMon, 28 Aug 2017 09:25:03 +0100 (BST)", "by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651)\n\tid 0349120F69C; Mon, 28 Aug 2017 10:28:08 +0200 (CEST)" ], "From": "Christian Borntraeger <borntraeger@de.ibm.com>", "To": "\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tAndrea Arcangeli <aarcange@redhat.com>", "Date": "Mon, 28 Aug 2017 10:28:07 +0200", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1503908887-67060-1-git-send-email-borntraeger@de.ibm.com>", "References": "<1503908887-67060-1-git-send-email-borntraeger@de.ibm.com>", "X-TM-AS-GCONF": "00", "x-cbid": "17082808-0016-0000-0000-000004E6C688", "X-IBM-AV-DETECTION": "SAVI=unused REMOTE=unused XFE=unused", "x-cbparentid": "17082808-0017-0000-0000-0000282031AD", "Message-Id": "<1503908887-67060-2-git-send-email-borntraeger@de.ibm.com>", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-28_04:, , signatures=0", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708280134", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]", "X-Received-From": "148.163.156.1", "Subject": "[Qemu-devel] [PATCH 1/1] s390/mm: avoid empty zero pages for KVM\n\tguests to avoid postcopy hangs", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "linux-s390 <linux-s390@vger.kernel.org>, Thomas Huth <thuth@redhat.com>, \n\tKVM <kvm@vger.kernel.org>, Juan Quintela <quintela@redhat.com>,\n\tCornelia Huck <cohuck@redhat.com>, qemu-devel <qemu-devel@nongnu.org>,\n\tChristian Borntraeger <borntraeger@de.ibm.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Right now there is a potential hang situation for postcopy migrations,\nif the guest is enabling storage keys on the target system during the\npostcopy process.\n\nFor storage key virtualization, we have to forbid the empty zero page as\nthe storage key is a property of the physical page frame. As we enable\nstorage key handling lazily we then drop all mappings for empty zero\npages for lazy refaulting later on.\n\nThis does not work with the postcopy migration, which relies on the\nempty zero page never triggering a fault again in the future. The reason\nis that postcopy migration will simply read a page on the target system\nif that page is a known zero page to fault in an empty zero page. At\nthe same time postcopy remembers that this page was already transferred\n- so any future userfault on that page will be NOT retransmitted again\nto avoid races.\n\nIf now the guest enters the storage key mode while in postcopy, we will\nbreak this assumption of postcopy.\n\nThe solution is to disable the empty zero page for KVM guests early on\nand not during storage key enablement. With this change, the postcopy\nmigration process is guaranteed to start after no zero pages are left.\n\nAs guest pages are very likely not empty zero pages anyway the memory\noverhead is also pretty small.\n\nWhile at it this also adds proper page table locking to the zero page\nremoval.\n\nSigned-off-by: Christian Borntraeger <borntraeger@de.ibm.com>\nCc: stable@vger.kernel.org\n---\n arch/s390/include/asm/pgtable.h | 2 +-\n arch/s390/mm/gmap.c | 41 ++++++++++++++++++++++++++++++++++-------\n 2 files changed, 35 insertions(+), 8 deletions(-)", "diff": "diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h\nindex bb59a0a..9d7f62a 100644\n--- a/arch/s390/include/asm/pgtable.h\n+++ b/arch/s390/include/asm/pgtable.h\n@@ -506,7 +506,7 @@ static inline int mm_alloc_pgste(struct mm_struct *mm)\n * In the case that a guest uses storage keys\n * faults should no longer be backed by zero pages\n */\n-#define mm_forbids_zeropage mm_use_skey\n+#define mm_forbids_zeropage mm_has_pgste\n static inline int mm_use_skey(struct mm_struct *mm)\n {\n #ifdef CONFIG_PGSTE\ndiff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c\nindex 4fb3d3c..ae8bd57 100644\n--- a/arch/s390/mm/gmap.c\n+++ b/arch/s390/mm/gmap.c\n@@ -2121,6 +2121,39 @@ static inline void thp_split_mm(struct mm_struct *mm)\n }\n \n /*\n+ * Remove all empty zero pages from the mapping for lazy refaulting\n+ * - This must be called after mm->context.has_pgste is set, to avoid\n+ * future creation of zero pages\n+ * - This must be called after THP was enabled\n+ */\n+static int __zap_zero_pages(pmd_t *pmd, unsigned long start,\n+\t\t\t unsigned long end, struct mm_walk *walk)\n+{\n+\tunsigned long addr;\n+\n+\tfor (addr = start; addr != end; addr += PAGE_SIZE) {\n+\t\tpte_t *ptep;\n+\t\tspinlock_t *ptl;\n+\n+\t\tptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);\n+\t\tif (is_zero_pfn(pte_pfn(*ptep)))\n+\t\t\tptep_xchg_direct(walk->mm, addr, ptep, __pte(_PAGE_INVALID));\n+\t\tpte_unmap_unlock(ptep, ptl);\n+\t}\n+\n+\treturn 0;\n+\n+}\n+\n+static inline void zap_zero_pages(struct mm_struct *mm)\n+{\n+\tstruct mm_walk walk = { .pmd_entry = __zap_zero_pages };\n+\n+\twalk.mm = mm;\n+\twalk_page_range(0, TASK_SIZE, &walk);\n+}\n+\n+/*\n * switch on pgstes for its userspace process (for kvm)\n */\n int s390_enable_sie(void)\n@@ -2137,6 +2170,7 @@ int s390_enable_sie(void)\n \tmm->context.has_pgste = 1;\n \t/* split thp mappings and disable thp for future mappings */\n \tthp_split_mm(mm);\n+\tzap_zero_pages(mm);\n \tup_write(&mm->mmap_sem);\n \treturn 0;\n }\n@@ -2149,13 +2183,6 @@ EXPORT_SYMBOL_GPL(s390_enable_sie);\n static int __s390_enable_skey(pte_t *pte, unsigned long addr,\n \t\t\t unsigned long next, struct mm_walk *walk)\n {\n-\t/*\n-\t * Remove all zero page mappings,\n-\t * after establishing a policy to forbid zero page mappings\n-\t * following faults for that page will get fresh anonymous pages\n-\t */\n-\tif (is_zero_pfn(pte_pfn(*pte)))\n-\t\tptep_xchg_direct(walk->mm, addr, pte, __pte(_PAGE_INVALID));\n \t/* Clear storage key */\n \tptep_zap_key(walk->mm, addr, pte);\n \treturn 0;\n", "prefixes": [ "1/1" ] }