Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815701/?format=api
{ "id": 815701, "url": "http://patchwork.ozlabs.org/api/patches/815701/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1505839684-10046-5-git-send-email-a.perevalov@samsung.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": "<1505839684-10046-5-git-send-email-a.perevalov@samsung.com>", "list_archive_url": null, "date": "2017-09-19T16:47:58", "name": "[v10,04/10] migration: split ufd_version_check onto receive/request features part", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "68f924e57de9da0364aa616c5158d2d19048b5ce", "submitter": { "id": 18164, "url": "http://patchwork.ozlabs.org/api/people/18164/?format=api", "name": "Alexey Perevalov", "email": "a.perevalov@samsung.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1505839684-10046-5-git-send-email-a.perevalov@samsung.com/mbox/", "series": [ { "id": 3930, "url": "http://patchwork.ozlabs.org/api/series/3930/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3930", "date": "2017-09-19T16:48:03", "name": "calculate blocktime for postcopy live migration", "version": 10, "mbox": "http://patchwork.ozlabs.org/series/3930/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815701/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815701/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 3xxTyp4pFFz9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 03:15:14 +1000 (AEST)", "from localhost ([::1]:44215 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 1duM76-0007ix-28\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 13:15:12 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:42438)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1duLhE-0001CZ-R8\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:32 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1duLhC-0006OX-3j\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:28 -0400", "from mailout2.w1.samsung.com ([210.118.77.12]:46474)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <a.perevalov@samsung.com>)\n\tid 1duLhB-0006NA-QG\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:26 -0400", "from eucas1p2.samsung.com (unknown [182.198.249.207])\n\tby mailout2.w1.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164824euoutp02e559e21c19e8b6f0a95a8702a463959a~l0Tua0SdX2834328343euoutp02U;\n\tTue, 19 Sep 2017 16:48:24 +0000 (GMT)", "from eusmges2.samsung.com (unknown [203.254.199.241]) by\n\teucas1p2.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164823eucas1p2690fe1cf6ec5099f7a79750731b33b7d~l0TtxLeXi0226002260eucas1p2b;\n\tTue, 19 Sep 2017 16:48:23 +0000 (GMT)", "from eucas1p2.samsung.com ( [182.198.249.207]) by\n\teusmges2.samsung.com (EUCPMTA) with SMTP id 59.6F.12907.75A41C95;\n\tTue, 19 Sep 2017 17:48:23 +0100 (BST)", "from eusmgms1.samsung.com (unknown [182.198.249.179]) by\n\teucas1p2.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164822eucas1p27957a05191b242b4982f62fab15a4539~l0TtD-o1w2115421154eucas1p2i;\n\tTue, 19 Sep 2017 16:48:22 +0000 (GMT)", "from eusync1.samsung.com ( [203.254.199.211]) by\n\teusmgms1.samsung.com (EUCPMTA) with SMTP id 44.6C.18832.65A41C95;\n\tTue, 19 Sep 2017 17:48:22 +0100 (BST)", "from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by\n\teusync1.samsung.com (Oracle Communications Messaging Server\n\t7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id\n\t<0OWJ003OHDC8XU40@eusync1.samsung.com>; \n\tTue, 19 Sep 2017 17:48:22 +0100 (BST)" ], "X-AuditID": "cbfec7f1-f793a6d00000326b-37-59c14a5720c5", "From": "Alexey Perevalov <a.perevalov@samsung.com>", "To": "qemu-devel@nongnu.org", "Date": "Tue, 19 Sep 2017 19:47:58 +0300", "Message-id": "<1505839684-10046-5-git-send-email-a.perevalov@samsung.com>", "X-Mailer": "git-send-email 1.9.1", "In-reply-to": "<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>", "X-Brightmail-Tracker": [ "H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djP87rhXgcjDQ7NlLCYe/c8i0Xvtnvs\n\tFhPfrme1mPb5NrvFlfaf7BZb9n9jtzjeu4PF4s6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NNwEBi3z1bkAYRAUmJ312nmUFqmAW2MEpsPL6SESQh\n\tLJAkMaurnRXEZhFQlbj1YTrYBl4Bd4lzHTehtslJnDw2GayGU8BD4tbxtewgthBQzY2115km\n\tMPIuYGRYxSiSWlqcm55bbKhXnJhbXJqXrpecn7uJERhM24793LyD8dLG4EOMAhyMSjy8K2wO\n\tRgqxJpYVV+YeYpTgYFYS4X3tBBTiTUmsrEotyo8vKs1JLT7EKM3BoiTO27tndaSQQHpiSWp2\n\tampBahFMlomDU6qBkXfmU3Xvp/mnv8kXMetOdQ5OyahznnbhpGJAUdb8Nwnp5jM/5LxZyLZd\n\txzSa5923a3mmcis9hKya1x07et1X3MWa+5jjyisHnGd4LOKvf3xr8t21h9fnC0ZM9kpUdLj9\n\tMKbKzj9wos05rykHjosc8t65LPj80e/pVz1WT2GY12o6o3FtE9PhnUosxRmJhlrMRcWJABRy\n\twHkiAgAA" ], "X-CMS-MailID": "20170919164822eucas1p27957a05191b242b4982f62fab15a4539", "X-Msg-Generator": "CA", "X-Sender-IP": "182.198.249.179", "X-Local-Sender": "=?utf-8?q?Alexey_Perevalov=1BSRR-Virtualization_Lab=1B?=\n\t=?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBFbmdpbmVlcg==?=", "X-Global-Sender": "=?utf-8?q?Alexey_Perevalov=1BSRR-Virtualization_Lab=1BSa?=\n\t=?utf-8?q?msung_Electronics=1BSenior_Engineer?=", "X-Sender-Code": "=?utf-8?q?C10=1BCISHQ=1BC10GD01GD010154?=", "CMS-TYPE": "201P", "X-CMS-RootMailID": "20170919164822eucas1p27957a05191b242b4982f62fab15a4539", "X-RootMTR": "20170919164822eucas1p27957a05191b242b4982f62fab15a4539", "References": "<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>\n\t<CGME20170919164822eucas1p27957a05191b242b4982f62fab15a4539@eucas1p2.samsung.com>", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 3.x [fuzzy]", "X-Received-From": "210.118.77.12", "Subject": "[Qemu-devel] [PATCH v10 04/10] migration: split ufd_version_check\n\tonto receive/request features part", "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": "heetae82.ahn@samsung.com, quintela@redhat.com,\n\tAlexey Perevalov <a.perevalov@samsung.com>, peterx@redhat.com,\n\tdgilbert@redhat.com, i.maximets@samsung.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": "This modification is necessary for userfault fd features which are\nrequired to be requested from userspace.\nUFFD_FEATURE_THREAD_ID is a one of such \"on demand\" feature, which will\nbe introduced in the next patch.\n\nQEMU have to use separate userfault file descriptor, due to\nuserfault context has internal state, and after first call of\nioctl UFFD_API it changes its state to UFFD_STATE_RUNNING (in case of\nsuccess), but kernel while handling ioctl UFFD_API expects UFFD_STATE_WAIT_API.\nSo only one ioctl with UFFD_API is possible per ufd.\n\nReviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\nSigned-off-by: Alexey Perevalov <a.perevalov@samsung.com>\n---\n migration/postcopy-ram.c | 94 ++++++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 88 insertions(+), 6 deletions(-)", "diff": "diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\nindex a0e74db..bec6c2c 100644\n--- a/migration/postcopy-ram.c\n+++ b/migration/postcopy-ram.c\n@@ -61,16 +61,67 @@ struct PostcopyDiscardState {\n #include <sys/eventfd.h>\n #include <linux/userfaultfd.h>\n \n-static bool ufd_version_check(int ufd, MigrationIncomingState *mis)\n+\n+/**\n+ * receive_ufd_features: check userfault fd features, to request only supported\n+ * features in the future.\n+ *\n+ * Returns: true on success\n+ *\n+ * __NR_userfaultfd - should be checked before\n+ * @features: out parameter will contain uffdio_api.features provided by kernel\n+ * in case of success\n+ */\n+static bool receive_ufd_features(uint64_t *features)\n {\n- struct uffdio_api api_struct;\n- uint64_t ioctl_mask;\n+ struct uffdio_api api_struct = {0};\n+ int ufd;\n+ bool ret = true;\n+\n+ /* if we are here __NR_userfaultfd should exists */\n+ ufd = syscall(__NR_userfaultfd, O_CLOEXEC);\n+ if (ufd == -1) {\n+ error_report(\"%s: syscall __NR_userfaultfd failed: %s\", __func__,\n+ strerror(errno));\n+ return false;\n+ }\n \n+ /* ask features */\n api_struct.api = UFFD_API;\n api_struct.features = 0;\n if (ioctl(ufd, UFFDIO_API, &api_struct)) {\n error_report(\"%s: UFFDIO_API failed: %s\", __func__,\n strerror(errno));\n+ ret = false;\n+ goto release_ufd;\n+ }\n+\n+ *features = api_struct.features;\n+\n+release_ufd:\n+ close(ufd);\n+ return ret;\n+}\n+\n+/**\n+ * request_ufd_features: this function should be called only once on a newly\n+ * opened ufd, subsequent calls will lead to error.\n+ *\n+ * Returns: true on succes\n+ *\n+ * @ufd: fd obtained from userfaultfd syscall\n+ * @features: bit mask see UFFD_API_FEATURES\n+ */\n+static bool request_ufd_features(int ufd, uint64_t features)\n+{\n+ struct uffdio_api api_struct = {0};\n+ uint64_t ioctl_mask;\n+\n+ api_struct.api = UFFD_API;\n+ api_struct.features = features;\n+ if (ioctl(ufd, UFFDIO_API, &api_struct)) {\n+ error_report(\"%s failed: UFFDIO_API failed: %s\", __func__,\n+ strerror(errno));\n return false;\n }\n \n@@ -82,11 +133,42 @@ static bool ufd_version_check(int ufd, MigrationIncomingState *mis)\n return false;\n }\n \n+ return true;\n+}\n+\n+static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis)\n+{\n+ uint64_t asked_features = 0;\n+ static uint64_t supported_features;\n+\n+ /*\n+ * it's not possible to\n+ * request UFFD_API twice per one fd\n+ * userfault fd features is persistent\n+ */\n+ if (!supported_features) {\n+ if (!receive_ufd_features(&supported_features)) {\n+ error_report(\"%s failed\", __func__);\n+ return false;\n+ }\n+ }\n+\n+ /*\n+ * request features, even if asked_features is 0, due to\n+ * kernel expects UFFD_API before UFFDIO_REGISTER, per\n+ * userfault file descriptor\n+ */\n+ if (!request_ufd_features(ufd, asked_features)) {\n+ error_report(\"%s failed: features %\" PRIu64, __func__,\n+ asked_features);\n+ return false;\n+ }\n+\n if (getpagesize() != ram_pagesize_summary()) {\n bool have_hp = false;\n /* We've got a huge page */\n #ifdef UFFD_FEATURE_MISSING_HUGETLBFS\n- have_hp = api_struct.features & UFFD_FEATURE_MISSING_HUGETLBFS;\n+ have_hp = supported_features & UFFD_FEATURE_MISSING_HUGETLBFS;\n #endif\n if (!have_hp) {\n error_report(\"Userfault on this host does not support huge pages\");\n@@ -147,7 +229,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)\n }\n \n /* Version and features check */\n- if (!ufd_version_check(ufd, mis)) {\n+ if (!ufd_check_and_apply(ufd, mis)) {\n goto out;\n }\n \n@@ -523,7 +605,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis)\n * Although the host check already tested the API, we need to\n * do the check again as an ABI handshake on the new fd.\n */\n- if (!ufd_version_check(mis->userfault_fd, mis)) {\n+ if (!ufd_check_and_apply(mis->userfault_fd, mis)) {\n return -1;\n }\n \n", "prefixes": [ "v10", "04/10" ] }