From patchwork Thu Jun 15 19:09:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9790047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE2BA60325 for ; Thu, 15 Jun 2017 19:12:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2DA28620 for ; Thu, 15 Jun 2017 19:12:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B41482862A; Thu, 15 Jun 2017 19:12:41 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 059A328620 for ; Thu, 15 Jun 2017 19:12:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLa9Z-0001Cb-Hm; Thu, 15 Jun 2017 19:10:01 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLa9Y-00015V-7r for xen-devel@lists.xen.org; Thu, 15 Jun 2017 19:10:00 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id C4/C1-17076-78BD2495; Thu, 15 Jun 2017 19:09:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVybKJssm7bbad Ig2sLzCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxHh+cxF/zhrdi48gRjA+Nb7i5GLg4hgTYm iW2vHrB3MXJysAg4SJz43ghkc3AwCsRIPPhhDRJmFAiTmHx5CSuIzSZgKPH3ySY2EFtEQFri2 ufLjCBzmAUmM0q8fveLGaRXWMBdYuPvOoiRqhLbnt5kBLF5Bdwk/q9/AdYrISAncfLYZLCZnE Dxs90TWaHuYZR482wp6wRG3gWMDKsYNYpTi8pSi3SNDPWSijLTM0pyEzNzdA0NjPVyU4uLE9N TcxKTivWS83M3MQLDoZ6BgXEHY89ev0OMkhxMSqK8/HJOkUJ8SfkplRmJxRnxRaU5qcWHGGU4 OJQkeFtvAeUEi1LTUyvSMnOAgQmTluDgURLhnX4TKM1bXJCYW5yZDpE6xajLsWH1+i9MQix5+ XmpUuK8PSAzBECKMkrz4EbAouQSo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeB5ApPJl5JX CbXgEdwQR0RNAFB5AjShIRUlINjKZTa7//tVuQWLn4xERJ1l8BUSslDp0048zS7OD8PVd2S1w 35+FjRfulmHbvnvLU73DAHotHWpfY05dllTdwP1rTlDltonbCYp/J32eGLr5wKFz/kOSa32LZ wQKGudOzOaUXJ3hJH0n7/qJFvsGyIPvp+QP3bzC2WhSXc4cmnS8+sO2f3iHLI0osxRmJhlrMR cWJANwXIRqNAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-3.tower-31.messagelabs.com!1497553797!105857495!1 X-Originating-IP: [198.145.29.99] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47186 invoked from network); 15 Jun 2017 19:09:58 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.99) by server-3.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jun 2017 19:09:58 -0000 Received: from localhost.localdomain (unknown [99.165.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8515239CF; Thu, 15 Jun 2017 19:09:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8515239CF From: Stefano Stabellini To: xen-devel@lists.xen.org Date: Thu, 15 Jun 2017 12:09:44 -0700 Message-Id: <1497553787-3709-15-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497553787-3709-1-git-send-email-sstabellini@kernel.org> References: <1497553787-3709-1-git-send-email-sstabellini@kernel.org> Cc: jgross@suse.com, Stefano Stabellini , boris.ostrovsky@oracle.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH v4 15/18] xen/pvcalls: implement the ioworker functions X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP We have one ioworker per socket. Each ioworker goes through the list of outstanding read/write requests. Once all requests have been dealt with, it returns. We use one atomic counter per socket for "read" operations and one for "write" operations to keep track of the reads/writes to do. We also use one atomic counter ("io") per ioworker to keep track of how many outstanding requests we have in total assigned to the ioworker. The ioworker finishes when there are none. Signed-off-by: Stefano Stabellini CC: boris.ostrovsky@oracle.com CC: jgross@suse.com Reviewed-by: Boris Ostrovsky --- drivers/xen/pvcalls-back.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index 94e4c3f..b9a10b9 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -98,8 +98,35 @@ static int pvcalls_back_release_active(struct xenbus_device *dev, struct pvcalls_fedata *fedata, struct sock_mapping *map); +static void pvcalls_conn_back_read(void *opaque) +{ +} + +static int pvcalls_conn_back_write(struct sock_mapping *map) +{ + return 0; +} + static void pvcalls_back_ioworker(struct work_struct *work) { + struct pvcalls_ioworker *ioworker = container_of(work, + struct pvcalls_ioworker, register_work); + struct sock_mapping *map = container_of(ioworker, struct sock_mapping, + ioworker); + + while (atomic_read(&map->io) > 0) { + if (atomic_read(&map->release) > 0) { + atomic_set(&map->release, 0); + return; + } + + if (atomic_read(&map->read) > 0) + pvcalls_conn_back_read(map); + if (atomic_read(&map->write) > 0) + pvcalls_conn_back_write(map); + + atomic_dec(&map->io); + } } static int pvcalls_back_socket(struct xenbus_device *dev,