xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: xen-pciback: Remove create_workqueue
@ 2016-05-27 15:54 Bhaktipriya Shridhar
  0 siblings, 0 replies; 5+ messages in thread
From: Bhaktipriya Shridhar @ 2016-05-27 15:54 UTC (permalink / raw)
  To: tj, boris.ostrovsky, david.vrabel, jgross, konrad.wilk, JBeulich,
	paul.gortmaker, stefano.stabellini, cardoe
  Cc: xen-devel, linux-kernel

With concurrency managed workqueues, use of dedicated workqueues can be
replaced by using system_wq. Drop host->intr_wq by using
system_wq.

Since there is only a single work item, increase of concurrency level by
switching to system_wq should not break anything.

cancel_work_sync() has been used in xen_pcibk_disconnect() to ensure that
work item is not pending or executing by the time exit path runs.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
 drivers/xen/xen-pciback/pciback.h     |  1 -
 drivers/xen/xen-pciback/pciback_ops.c |  2 +-
 drivers/xen/xen-pciback/xenbus.c      | 10 +---------
 3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/xen/xen-pciback/pciback.h b/drivers/xen/xen-pciback/pciback.h
index 4d529f3..7af369b6 100644
--- a/drivers/xen/xen-pciback/pciback.h
+++ b/drivers/xen/xen-pciback/pciback.h
@@ -55,7 +55,6 @@ struct xen_pcibk_dev_data {

 /* Used by XenBus and xen_pcibk_ops.c */
 extern wait_queue_head_t xen_pcibk_aer_wait_queue;
-extern struct workqueue_struct *xen_pcibk_wq;
 /* Used by pcistub.c and conf_space_quirks.c */
 extern struct list_head xen_pcibk_quirks;

diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c
index 2f19dd7..f8c7775 100644
--- a/drivers/xen/xen-pciback/pciback_ops.c
+++ b/drivers/xen/xen-pciback/pciback_ops.c
@@ -310,7 +310,7 @@ void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev)
 	 * already processing a request */
 	if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags)
 	    && !test_and_set_bit(_PDEVF_op_active, &pdev->flags)) {
-		queue_work(xen_pcibk_wq, &pdev->op_work);
+		schedule_work(&pdev->op_work);
 	}
 	/*_XEN_PCIB_active should have been cleared by pcifront. And also make
 	sure xen_pcibk is waiting for ack by checking _PCIB_op_pending*/
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index c252eb3..f70a8e1 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -17,7 +17,6 @@
 #include "pciback.h"

 #define INVALID_EVTCHN_IRQ  (-1)
-struct workqueue_struct *xen_pcibk_wq;

 static bool __read_mostly passthrough;
 module_param(passthrough, bool, S_IRUGO);
@@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
 	/* If the driver domain started an op, make sure we complete it
 	 * before releasing the shared memory */

-	/* Note, the workqueue does not use spinlocks at all.*/
-	flush_workqueue(xen_pcibk_wq);
+	cancel_work_sync(&pdev->op_work);

 	if (pdev->sh_info != NULL) {
 		xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info);
@@ -733,11 +731,6 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;

 int __init xen_pcibk_xenbus_register(void)
 {
-	xen_pcibk_wq = create_workqueue("xen_pciback_workqueue");
-	if (!xen_pcibk_wq) {
-		pr_err("%s: create xen_pciback_workqueue failed\n", __func__);
-		return -EFAULT;
-	}
 	xen_pcibk_backend = &xen_pcibk_vpci_backend;
 	if (passthrough)
 		xen_pcibk_backend = &xen_pcibk_passthrough_backend;
@@ -747,6 +740,5 @@ int __init xen_pcibk_xenbus_register(void)

 void __exit xen_pcibk_xenbus_unregister(void)
 {
-	destroy_workqueue(xen_pcibk_wq);
 	xenbus_unregister_driver(&xen_pcibk_driver);
 }
--
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen: xen-pciback: Remove create_workqueue
  2016-05-27 16:32     ` Konrad Rzeszutek Wilk
@ 2016-05-31 10:11       ` David Vrabel
  0 siblings, 0 replies; 5+ messages in thread
From: David Vrabel @ 2016-05-31 10:11 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Tejun Heo
  Cc: jgross, stefano.stabellini, Bhaktipriya Shridhar, cardoe,
	linux-kernel, paul.gortmaker, JBeulich, xen-devel,
	boris.ostrovsky

On 27/05/16 17:32, Konrad Rzeszutek Wilk wrote:
> On Fri, May 27, 2016 at 12:08:22PM -0400, Tejun Heo wrote:
>> Hello,
>>
>> On Fri, May 27, 2016 at 12:01:14PM -0400, Konrad Rzeszutek Wilk wrote:
>>> On Fri, May 27, 2016 at 09:24:11PM +0530, Bhaktipriya Shridhar wrote:
>>>> With concurrency managed workqueues, use of dedicated workqueues can be
>>>> replaced by using system_wq. Drop host->intr_wq by using
>>                                       ^
>> 				      xen_pcibk_wq
>>>> system_wq.
>>>>
>>>> Since there is only a single work item, increase of concurrency level by
>>>> switching to system_wq should not break anything.
>>>
>>> _should_ not? Hehe. I presume this has not been tested?
>>
>> Yeah, this is a part of sweeping conversions and it's challenging (and
>> often impossible for specific drivers) to setup test environments.
>> xen isn't as bad but can still be a pretty specialized setup.  The
>> conversions aren't high risk and shouldn't be too difficult to root
>> cause when something goes south.  We'd greatly appreciate any helps
>> with reviewing and testing.
>>
>>>> cancel_work_sync() has been used in xen_pcibk_disconnect() to ensure that
>>>> work item is not pending or executing by the time exit path runs.
>>>>
>>>> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
>>>> @@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
>>>>  	/* If the driver domain started an op, make sure we complete it
>>>>  	 * before releasing the shared memory */
>>>>
>>>> -	/* Note, the workqueue does not use spinlocks at all.*/
>>>> -	flush_workqueue(xen_pcibk_wq);
>>>> +	cancel_work_sync(&pdev->op_work);
>>
>> Should it be flush_work() instead?  Is it okay for a pdev->op_work to
>> be queued and canceled without actually getting executed?
> 
> It should really flush them. The comment above says so, but in reality it
> does not matter that much as we tearing down the communication. As long as
> the pdev->op_work either completes or is never executed - we are fine.

The comment should be updated to reflect this.

David

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen: xen-pciback: Remove create_workqueue
       [not found]   ` <20160527160822.GO23194@mtj.duckdns.org>
@ 2016-05-27 16:32     ` Konrad Rzeszutek Wilk
  2016-05-31 10:11       ` David Vrabel
  0 siblings, 1 reply; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-05-27 16:32 UTC (permalink / raw)
  To: Tejun Heo
  Cc: jgross, stefano.stabellini, Bhaktipriya Shridhar, cardoe,
	linux-kernel, paul.gortmaker, david.vrabel, JBeulich, xen-devel,
	boris.ostrovsky

On Fri, May 27, 2016 at 12:08:22PM -0400, Tejun Heo wrote:
> Hello,
> 
> On Fri, May 27, 2016 at 12:01:14PM -0400, Konrad Rzeszutek Wilk wrote:
> > On Fri, May 27, 2016 at 09:24:11PM +0530, Bhaktipriya Shridhar wrote:
> > > With concurrency managed workqueues, use of dedicated workqueues can be
> > > replaced by using system_wq. Drop host->intr_wq by using
>                                       ^
> 				      xen_pcibk_wq
> > > system_wq.
> > > 
> > > Since there is only a single work item, increase of concurrency level by
> > > switching to system_wq should not break anything.
> > 
> > _should_ not? Hehe. I presume this has not been tested?
> 
> Yeah, this is a part of sweeping conversions and it's challenging (and
> often impossible for specific drivers) to setup test environments.
> xen isn't as bad but can still be a pretty specialized setup.  The
> conversions aren't high risk and shouldn't be too difficult to root
> cause when something goes south.  We'd greatly appreciate any helps
> with reviewing and testing.
> 
> > > cancel_work_sync() has been used in xen_pcibk_disconnect() to ensure that
> > > work item is not pending or executing by the time exit path runs.
> > > 
> > > Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> > > @@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
> > >  	/* If the driver domain started an op, make sure we complete it
> > >  	 * before releasing the shared memory */
> > > 
> > > -	/* Note, the workqueue does not use spinlocks at all.*/
> > > -	flush_workqueue(xen_pcibk_wq);
> > > +	cancel_work_sync(&pdev->op_work);
> 
> Should it be flush_work() instead?  Is it okay for a pdev->op_work to
> be queued and canceled without actually getting executed?

It should really flush them. The comment above says so, but in reality it
does not matter that much as we tearing down the communication. As long as
the pdev->op_work either completes or is never executed - we are fine.

> 
> Thanks.
> 
> -- 
> tejun

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen: xen-pciback: Remove create_workqueue
       [not found] ` <20160527160114.GB1842@char.us.oracle.com>
@ 2016-05-27 16:08   ` Tejun Heo
       [not found]   ` <20160527160822.GO23194@mtj.duckdns.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2016-05-27 16:08 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: jgross, stefano.stabellini, Bhaktipriya Shridhar, cardoe,
	linux-kernel, paul.gortmaker, david.vrabel, JBeulich, xen-devel,
	boris.ostrovsky

Hello,

On Fri, May 27, 2016 at 12:01:14PM -0400, Konrad Rzeszutek Wilk wrote:
> On Fri, May 27, 2016 at 09:24:11PM +0530, Bhaktipriya Shridhar wrote:
> > With concurrency managed workqueues, use of dedicated workqueues can be
> > replaced by using system_wq. Drop host->intr_wq by using
                                      ^
				      xen_pcibk_wq
> > system_wq.
> > 
> > Since there is only a single work item, increase of concurrency level by
> > switching to system_wq should not break anything.
> 
> _should_ not? Hehe. I presume this has not been tested?

Yeah, this is a part of sweeping conversions and it's challenging (and
often impossible for specific drivers) to setup test environments.
xen isn't as bad but can still be a pretty specialized setup.  The
conversions aren't high risk and shouldn't be too difficult to root
cause when something goes south.  We'd greatly appreciate any helps
with reviewing and testing.

> > cancel_work_sync() has been used in xen_pcibk_disconnect() to ensure that
> > work item is not pending or executing by the time exit path runs.
> > 
> > Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> > @@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
> >  	/* If the driver domain started an op, make sure we complete it
> >  	 * before releasing the shared memory */
> > 
> > -	/* Note, the workqueue does not use spinlocks at all.*/
> > -	flush_workqueue(xen_pcibk_wq);
> > +	cancel_work_sync(&pdev->op_work);

Should it be flush_work() instead?  Is it okay for a pdev->op_work to
be queued and canceled without actually getting executed?

Thanks.

-- 
tejun

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen: xen-pciback: Remove create_workqueue
       [not found] <20160527155411.GA18039@Karyakshetra>
@ 2016-05-27 16:01 ` Konrad Rzeszutek Wilk
       [not found] ` <20160527160114.GB1842@char.us.oracle.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-05-27 16:01 UTC (permalink / raw)
  To: Bhaktipriya Shridhar
  Cc: jgross, stefano.stabellini, cardoe, linux-kernel, paul.gortmaker,
	david.vrabel, JBeulich, tj, xen-devel, boris.ostrovsky

On Fri, May 27, 2016 at 09:24:11PM +0530, Bhaktipriya Shridhar wrote:
> With concurrency managed workqueues, use of dedicated workqueues can be
> replaced by using system_wq. Drop host->intr_wq by using
> system_wq.
> 
> Since there is only a single work item, increase of concurrency level by
> switching to system_wq should not break anything.

_should_ not? Hehe. I presume this has not been tested?
> 
> cancel_work_sync() has been used in xen_pcibk_disconnect() to ensure that
> work item is not pending or executing by the time exit path runs.
> 
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
>  drivers/xen/xen-pciback/pciback.h     |  1 -
>  drivers/xen/xen-pciback/pciback_ops.c |  2 +-
>  drivers/xen/xen-pciback/xenbus.c      | 10 +---------
>  3 files changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/xen/xen-pciback/pciback.h b/drivers/xen/xen-pciback/pciback.h
> index 4d529f3..7af369b6 100644
> --- a/drivers/xen/xen-pciback/pciback.h
> +++ b/drivers/xen/xen-pciback/pciback.h
> @@ -55,7 +55,6 @@ struct xen_pcibk_dev_data {
> 
>  /* Used by XenBus and xen_pcibk_ops.c */
>  extern wait_queue_head_t xen_pcibk_aer_wait_queue;
> -extern struct workqueue_struct *xen_pcibk_wq;
>  /* Used by pcistub.c and conf_space_quirks.c */
>  extern struct list_head xen_pcibk_quirks;
> 
> diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c
> index 2f19dd7..f8c7775 100644
> --- a/drivers/xen/xen-pciback/pciback_ops.c
> +++ b/drivers/xen/xen-pciback/pciback_ops.c
> @@ -310,7 +310,7 @@ void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev)
>  	 * already processing a request */
>  	if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags)
>  	    && !test_and_set_bit(_PDEVF_op_active, &pdev->flags)) {
> -		queue_work(xen_pcibk_wq, &pdev->op_work);
> +		schedule_work(&pdev->op_work);
>  	}
>  	/*_XEN_PCIB_active should have been cleared by pcifront. And also make
>  	sure xen_pcibk is waiting for ack by checking _PCIB_op_pending*/
> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
> index c252eb3..f70a8e1 100644
> --- a/drivers/xen/xen-pciback/xenbus.c
> +++ b/drivers/xen/xen-pciback/xenbus.c
> @@ -17,7 +17,6 @@
>  #include "pciback.h"
> 
>  #define INVALID_EVTCHN_IRQ  (-1)
> -struct workqueue_struct *xen_pcibk_wq;
> 
>  static bool __read_mostly passthrough;
>  module_param(passthrough, bool, S_IRUGO);
> @@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
>  	/* If the driver domain started an op, make sure we complete it
>  	 * before releasing the shared memory */
> 
> -	/* Note, the workqueue does not use spinlocks at all.*/
> -	flush_workqueue(xen_pcibk_wq);
> +	cancel_work_sync(&pdev->op_work);
> 
>  	if (pdev->sh_info != NULL) {
>  		xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info);
> @@ -733,11 +731,6 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;
> 
>  int __init xen_pcibk_xenbus_register(void)
>  {
> -	xen_pcibk_wq = create_workqueue("xen_pciback_workqueue");
> -	if (!xen_pcibk_wq) {
> -		pr_err("%s: create xen_pciback_workqueue failed\n", __func__);
> -		return -EFAULT;
> -	}
>  	xen_pcibk_backend = &xen_pcibk_vpci_backend;
>  	if (passthrough)
>  		xen_pcibk_backend = &xen_pcibk_passthrough_backend;
> @@ -747,6 +740,5 @@ int __init xen_pcibk_xenbus_register(void)
> 
>  void __exit xen_pcibk_xenbus_unregister(void)
>  {
> -	destroy_workqueue(xen_pcibk_wq);
>  	xenbus_unregister_driver(&xen_pcibk_driver);
>  }
> --
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-31 10:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-27 15:54 [PATCH] xen: xen-pciback: Remove create_workqueue Bhaktipriya Shridhar
     [not found] <20160527155411.GA18039@Karyakshetra>
2016-05-27 16:01 ` Konrad Rzeszutek Wilk
     [not found] ` <20160527160114.GB1842@char.us.oracle.com>
2016-05-27 16:08   ` Tejun Heo
     [not found]   ` <20160527160822.GO23194@mtj.duckdns.org>
2016-05-27 16:32     ` Konrad Rzeszutek Wilk
2016-05-31 10:11       ` David Vrabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).