[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1494880570-14209-15-git-send-email-sstabellini@kernel.org>
Date: Mon, 15 May 2017 13:36:07 -0700
From: Stefano Stabellini <sstabellini@...nel.org>
To: xen-devel@...ts.xen.org
Cc: linux-kernel@...r.kernel.org, sstabellini@...nel.org,
jgross@...e.com, boris.ostrovsky@...cle.com,
Stefano Stabellini <stefano@...reto.com>
Subject: [PATCH 15/18] xen/pvcalls: introduce the ioworker
We have one ioworker per cpu core. Each ioworker gets assigned active
sockets randomly. Once a socket is assigned to an ioworker, it remains
tied to it until is released.
Each ioworker goes through the list of outstanding read/write requests
by walking a list of struct sock_mapping. Once a request has been dealt
with, the struct sock_mapping is removed from the list.
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 <stefano@...reto.com>
CC: boris.ostrovsky@...cle.com
CC: jgross@...e.com
---
drivers/xen/pvcalls-back.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
index 0daa90a..db3e02c 100644
--- a/drivers/xen/pvcalls-back.c
+++ b/drivers/xen/pvcalls-back.c
@@ -99,8 +99,52 @@ struct sockpass_mapping {
static int pvcalls_back_release_active(struct xenbus_device *dev,
struct pvcalls_back_priv *priv,
struct sock_mapping *map);
+
+static void pvcalls_conn_back_read(unsigned long 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);
+ int num = ioworker->num;
+ struct sock_mapping *map, *n;
+ unsigned long flags;
+
+ while (atomic_read(&ioworker->io) > 0) {
+ spin_lock_irqsave(&ioworker->lock, flags);
+ list_for_each_entry_safe(map, n, &ioworker->wqs, queue) {
+ if (map->data_worker != num)
+ continue;
+
+ if (atomic_read(&map->release) > 0) {
+ list_del_init(&map->queue);
+ atomic_set(&map->release, 0);
+ continue;
+ }
+
+ spin_unlock_irqrestore(&ioworker->lock, flags);
+ if (atomic_read(&map->read) > 0)
+ pvcalls_conn_back_read((unsigned long)map);
+ if (atomic_read(&map->write) > 0)
+ pvcalls_conn_back_write(map);
+ spin_lock_irqsave(&ioworker->lock, flags);
+
+ if (atomic_read(&map->read) == 0 &&
+ atomic_read(&map->write) == 0) {
+ list_del_init(&map->queue);
+ atomic_set(&map->release, 0);
+ }
+ }
+ atomic_dec(&ioworker->io);
+ spin_unlock_irqrestore(&ioworker->lock, flags);
+ }
}
static int pvcalls_back_socket(struct xenbus_device *dev,
--
1.9.1
Powered by blists - more mailing lists