[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [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@xxxxxxxxxxx> CC: boris.ostrovsky@xxxxxxxxxx CC: jgross@xxxxxxxx --- 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 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |