Re: [PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
On Tue, 4 Jul 2017, Juergen Gross wrote: > On 03/07/17 23:08, 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> > Reviewed-by: Boris Ostrovsky > > CC: boris.ostrov...@oracle.com > > CC: jgr...@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 71a42fc..d59c2e4 100644 > > --- a/drivers/xen/pvcalls-back.c > > +++ b/drivers/xen/pvcalls-back.c > > @@ -96,8 +96,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; > > +} > > Any reason for letting this function return int? I haven't spotted any > use of the return value in this or any later patch. No reason. I'll change it to void.
Re: [PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
On Tue, 4 Jul 2017, Juergen Gross wrote: > On 03/07/17 23:08, 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 > > Reviewed-by: Boris Ostrovsky > > CC: boris.ostrov...@oracle.com > > CC: jgr...@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 71a42fc..d59c2e4 100644 > > --- a/drivers/xen/pvcalls-back.c > > +++ b/drivers/xen/pvcalls-back.c > > @@ -96,8 +96,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; > > +} > > Any reason for letting this function return int? I haven't spotted any > use of the return value in this or any later patch. No reason. I'll change it to void.
Re: [PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
On 03/07/17 23:08, 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> Reviewed-by: Boris Ostrovsky > CC: boris.ostrov...@oracle.com > CC: jgr...@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 71a42fc..d59c2e4 100644 > --- a/drivers/xen/pvcalls-back.c > +++ b/drivers/xen/pvcalls-back.c > @@ -96,8 +96,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; > +} Any reason for letting this function return int? I haven't spotted any use of the return value in this or any later patch. Juergen
Re: [PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
On 03/07/17 23:08, 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 > Reviewed-by: Boris Ostrovsky > CC: boris.ostrov...@oracle.com > CC: jgr...@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 71a42fc..d59c2e4 100644 > --- a/drivers/xen/pvcalls-back.c > +++ b/drivers/xen/pvcalls-back.c > @@ -96,8 +96,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; > +} Any reason for letting this function return int? I haven't spotted any use of the return value in this or any later patch. Juergen
[PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
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 StabelliniReviewed-by: Boris Ostrovsky CC: boris.ostrov...@oracle.com CC: jgr...@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 71a42fc..d59c2e4 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -96,8 +96,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(>io) > 0) { + if (atomic_read(>release) > 0) { + atomic_set(>release, 0); + return; + } + + if (atomic_read(>read) > 0) + pvcalls_conn_back_read(map); + if (atomic_read(>write) > 0) + pvcalls_conn_back_write(map); + + atomic_dec(>io); + } } static int pvcalls_back_socket(struct xenbus_device *dev, -- 1.9.1
[PATCH v6 15/18] xen/pvcalls: implement the ioworker functions
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 Reviewed-by: Boris Ostrovsky CC: boris.ostrov...@oracle.com CC: jgr...@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 71a42fc..d59c2e4 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -96,8 +96,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(>io) > 0) { + if (atomic_read(>release) > 0) { + atomic_set(>release, 0); + return; + } + + if (atomic_read(>read) > 0) + pvcalls_conn_back_read(map); + if (atomic_read(>write) > 0) + pvcalls_conn_back_write(map); + + atomic_dec(>io); + } } static int pvcalls_back_socket(struct xenbus_device *dev, -- 1.9.1