From patchwork Thu Mar 7 07:21:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 10842293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8E861515 for ; Thu, 7 Mar 2019 07:32:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92DB22E8D3 for ; Thu, 7 Mar 2019 07:32:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86C482E54A; Thu, 7 Mar 2019 07:32:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 20C0C2E54A for ; Thu, 7 Mar 2019 07:32:46 +0000 (UTC) Received: from localhost ([127.0.0.1]:46702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nWI-0001bc-90 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 02:32:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nLH-0001fK-Hr for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1nLG-0004gl-Og for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:23 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1nLG-0004gU-GP for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:22 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x277JXWp038021; Thu, 7 Mar 2019 07:21:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=APi4SUqNvnOfi0hO7oGrcqrFOHHEzDuV8v6wpwCdkh4=; b=WMTpZueI5caJeG493v4ktiFH0HG5LLNSJ+NWXqh6uibUtmHlJH/alR95QOvdEAQKB553 01wK7XifAlf0Q476oFtvlQeE/nmUgjNXTz4z1U90n5AQtE4vMw+qsrPkjen2wpN5Tuqo wvrkOnUmYoZaMlJp5xZPKHTdGHuFb4tiIUZLdty8NS3gW+gZsalmKf88lVK799Y4XAPt 9OmoSd+Kdo0Uyo7pgfUYI4Id/RZnnF/X0ZuaTksPRDUie1DqNAy/T8wiiumbI0X1cuwx puUoaSEMccgeqm9e+C5D1c3V97LdgSeEf5qxkm0pBJbwLK+UOTNA/GIb+jxRkGPzL3Yu 4w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2qyh8ug93t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Mar 2019 07:21:18 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x277LH8B028713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2019 07:21:17 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x277LHRs003570; Thu, 7 Mar 2019 07:21:17 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Mar 2019 23:21:17 -0800 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 23:21:15 -0800 Message-Id: <20190307072115.8428-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9187 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903070053 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [multiprocess RFC PATCH 08/37] multi-process: add functions to synchronize proxy and remote endpoints X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com, sstabellini@kernel.org, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman In some cases, for example MMIO read, QEMU has to wait for the remote to complete a command before proceeding. An eventfd based mechanism is added to synchronize QEMU & remote process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- include/io/proxy-link.h | 9 +++++++++ io/proxy-link.c | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index ff602e4..a12c565 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include #include "qemu/osdep.h" #include "qom/object.h" @@ -124,11 +126,18 @@ struct ProxyLinkState { proxy_link_callback callback; }; +#define GET_REMOTE_WAIT eventfd(0, 0) +#define PUT_REMOTE_WAIT(wait) close(wait) +#define PROXY_LINK_WAIT_DONE 1 + ProxyLinkState *proxy_link_create(void); void proxy_link_finalize(ProxyLinkState *s); void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg); int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg); +uint64_t wait_for_remote(int efd); +void notify_proxy(int fd, uint64_t val); + void proxy_link_set_sock(ProxyLinkState *s, int fd); void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callback); void start_handler(ProxyLinkState *s); diff --git a/io/proxy-link.c b/io/proxy-link.c index 9ea0ed7..9f6ae77 100644 --- a/io/proxy-link.c +++ b/io/proxy-link.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "qemu/module.h" #include "io/proxy-link.h" @@ -210,6 +211,31 @@ int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg) return rc; } +uint64_t wait_for_remote(int efd) +{ + uint64_t val; + + if (read(efd, &val, sizeof(val)) == -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + } + + val = (val == ULLONG_MAX) ? val : (val - 1); + + return val; +} + +void notify_proxy(int efd, uint64_t val) +{ + val = (val == ULLONG_MAX) ? val : (val + 1); + + if (write(efd, &val, sizeof(val)) == -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error notify_proxy: %s\n", + strerror(errno)); + } +} + static gboolean proxy_link_handler_prepare(GSource *gsrc, gint *timeout) { g_assert(timeout);