Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754097AbdFNA4c (ORCPT ); Tue, 13 Jun 2017 20:56:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbdFNA4b (ORCPT ); Tue, 13 Jun 2017 20:56:31 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1F9622CB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org Date: Tue, 13 Jun 2017 17:56:29 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: Juergen Gross cc: Stefano Stabellini , xen-devel@lists.xen.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, Stefano Stabellini Subject: Re: [PATCH v3 15/18] xen/pvcalls: implement the ioworker functions In-Reply-To: <51e3bbad-d5f2-a3b9-b038-4535cd58ea2a@suse.com> Message-ID: References: <1496431915-20774-1-git-send-email-sstabellini@kernel.org> <1496431915-20774-15-git-send-email-sstabellini@kernel.org> <51e3bbad-d5f2-a3b9-b038-4535cd58ea2a@suse.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2204 Lines: 68 On Tue, 13 Jun 2017, Juergen Gross wrote: > On 02/06/17 21:31, Stefano Stabellini wrote: > > 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 > > --- > > 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 6afe7a0..0283d49 100644 > > --- a/drivers/xen/pvcalls-back.c > > +++ b/drivers/xen/pvcalls-back.c > > @@ -99,8 +99,35 @@ static int pvcalls_back_release_active(struct xenbus_device *dev, > > struct pvcalls_fedata *priv, > > struct sock_mapping *map); > > > > +static void pvcalls_conn_back_read(unsigned long opaque) > > Why not void *opaque? You could drop the cast below then. Good idea > > +{ > > +} > > + > > +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((unsigned long)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, > > >