All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] wireless: Use complete() instead complete_all()
@ 2016-09-13  8:58 Daniel Wagner
  2016-09-13  8:58 ` [PATCH 1/3] csiostor: fix completion usage Daniel Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Daniel Wagner @ 2016-09-13  8:58 UTC (permalink / raw)
  To: linux-scsi
  Cc: James E.J. Bottomley, Martin K. Petersen, Matthew Wilcox,
	linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

Hi,

Using complete_all() is not wrong per se but it suggest that there
might be more than one waiter. For -rt I am reviewing all
complete_all() users and would like to leave only the real ones in the
tree. The main problem for -rt about complete_all() is that it can be
uses inside IRQ context and that can lead to unbounded amount work
inside the interrupt handler. That is a no no for -rt.

The patches grouped per subsystem and in small batches to allow
reviewing.

Patch #1 fixes a minor bug in the completion API usage. The current code
works but it could work better.

cheers,
daniel

Daniel Wagner (3):
  csiostor: fix completion usage
  sym53c8xx_2: use complete() instead complete_all()
  virtio_scsi: use complete() instead complete_all()

 drivers/scsi/csiostor/csio_scsi.c   | 5 ++---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
 drivers/scsi/virtio_scsi.c          | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] csiostor: fix completion usage
  2016-09-13  8:58 [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner
@ 2016-09-13  8:58 ` Daniel Wagner
  2016-09-14  7:26   ` Christoph Hellwig
  2016-09-13  8:58 ` [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all() Daniel Wagner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2016-09-13  8:58 UTC (permalink / raw)
  To: linux-scsi
  Cc: James E.J. Bottomley, Martin K. Petersen, Matthew Wilcox,
	linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

The (re)initialzing of the completion object should be done before we
trigger the transfer. Doing this after triggering the hardware opens up
a race window. Without the timeout we would problaly even deadlock. Use
also reinit_completion because we initalize the whole data structure in
csio_scscim_init().

There is only one waiter for the completion, therefore there is no need
to use complete_all(). Let's make that clear by using complete() instead
of complete_all().

The usage pattern of the completion is:

waiter context                          waker context

csio_eh_abort_handler()
  reinit_completion()
  wait_for_completion_timeout()

                                        csio_scsi_err_handler()
                                          complete()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/csiostor/csio_scsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index c2a6f9f..89a52b9 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -1721,7 +1721,7 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req)
 
 	/* Wake up waiting threads */
 	csio_scsi_cmnd(req) = NULL;
-	complete_all(&req->cmplobj);
+	complete(&req->cmplobj);
 }
 
 /*
@@ -1945,6 +1945,7 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd)
 	ready = csio_is_lnode_ready(ln);
 	tmo = CSIO_SCSI_ABRT_TMO_MS;
 
+	reinit_completion(&ioreq->cmplobj);
 	spin_lock_irq(&hw->lock);
 	rv = csio_do_abrt_cls(hw, ioreq, (ready ? SCSI_ABORT : SCSI_CLOSE));
 	spin_unlock_irq(&hw->lock);
@@ -1964,8 +1965,6 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd)
 		goto inval_scmnd;
 	}
 
-	/* Wait for completion */
-	init_completion(&ioreq->cmplobj);
 	wait_for_completion_timeout(&ioreq->cmplobj, msecs_to_jiffies(tmo));
 
 	/* FW didnt respond to abort within our timeout */
-- 
2.7.4

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

* [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all()
  2016-09-13  8:58 [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner
  2016-09-13  8:58 ` [PATCH 1/3] csiostor: fix completion usage Daniel Wagner
@ 2016-09-13  8:58 ` Daniel Wagner
  2016-09-14  7:26   ` Christoph Hellwig
  2016-09-13  8:58 ` [PATCH 3/3] virtio_scsi: " Daniel Wagner
  2016-09-14 17:23 ` [PATCH 0/3] wireless: Use " Martin K. Petersen
  3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2016-09-13  8:58 UTC (permalink / raw)
  To: linux-scsi
  Cc: James E.J. Bottomley, Martin K. Petersen, Matthew Wilcox,
	linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

There is only one waiter for the completion, therefore there is no need
to use complete_all(). Let's make that clear by using complete() instead
of complete_all().

The usage pattern of the completion is:

waiter context                          waker context

sym_eh_handler()
  struct completion eh_done
  init_completion(eh_done)
  pci_channel_offline()
  wait_for_completion_timeout(eh_done)

                                        sym2_io_resume()
                                          complete(eh_done)

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 5d00e51..d32e3ba 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -1874,7 +1874,7 @@ static void sym2_io_resume(struct pci_dev *pdev)
 
 	spin_lock_irq(shost->host_lock);
 	if (sym_data->io_reset)
-		complete_all(sym_data->io_reset);
+		complete(sym_data->io_reset);
 	spin_unlock_irq(shost->host_lock);
 }
 
-- 
2.7.4

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

* [PATCH 3/3] virtio_scsi: use complete() instead complete_all()
  2016-09-13  8:58 [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner
  2016-09-13  8:58 ` [PATCH 1/3] csiostor: fix completion usage Daniel Wagner
  2016-09-13  8:58 ` [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all() Daniel Wagner
@ 2016-09-13  8:58 ` Daniel Wagner
  2016-09-14  7:27   ` Christoph Hellwig
  2016-09-14 17:23 ` [PATCH 0/3] wireless: Use " Martin K. Petersen
  3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2016-09-13  8:58 UTC (permalink / raw)
  To: linux-scsi
  Cc: James E.J. Bottomley, Martin K. Petersen, Matthew Wilcox,
	linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

There is only one waiter for the completion, therefore there is no need
to use complete_all(). Let's make that clear by using complete() instead
of complete_all().

The usage pattern of the completion is:

waiter context                          waker context

virtscsi_tmf()
  DECLARE_COMPLETION_ONSTACK()
  virtscsi_kick_cmd()
  wait_for_completion()

                                        virtscsi_complete_free()
                                          complete()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/virtio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29..86924ff 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -258,7 +258,7 @@ static void virtscsi_complete_free(struct virtio_scsi *vscsi, void *buf)
 	struct virtio_scsi_cmd *cmd = buf;
 
 	if (cmd->comp)
-		complete_all(cmd->comp);
+		complete(cmd->comp);
 }
 
 static void virtscsi_ctrl_done(struct virtqueue *vq)
-- 
2.7.4

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

* Re: [PATCH 1/3] csiostor: fix completion usage
  2016-09-13  8:58 ` [PATCH 1/3] csiostor: fix completion usage Daniel Wagner
@ 2016-09-14  7:26   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2016-09-14  7:26 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: linux-scsi, James E.J. Bottomley, Martin K. Petersen,
	Matthew Wilcox, linux-kernel, Daniel Wagner

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all()
  2016-09-13  8:58 ` [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all() Daniel Wagner
@ 2016-09-14  7:26   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2016-09-14  7:26 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: linux-scsi, James E.J. Bottomley, Martin K. Petersen,
	Matthew Wilcox, linux-kernel, Daniel Wagner

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 3/3] virtio_scsi: use complete() instead complete_all()
  2016-09-13  8:58 ` [PATCH 3/3] virtio_scsi: " Daniel Wagner
@ 2016-09-14  7:27   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2016-09-14  7:27 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: linux-scsi, James E.J. Bottomley, Martin K. Petersen,
	Matthew Wilcox, linux-kernel, Daniel Wagner

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 0/3] wireless: Use complete() instead complete_all()
  2016-09-13  8:58 [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner
                   ` (2 preceding siblings ...)
  2016-09-13  8:58 ` [PATCH 3/3] virtio_scsi: " Daniel Wagner
@ 2016-09-14 17:23 ` Martin K. Petersen
  3 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2016-09-14 17:23 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: linux-scsi, James E.J. Bottomley, Martin K. Petersen,
	Matthew Wilcox, linux-kernel, Daniel Wagner

>>>>> "Daniel" == Daniel Wagner <wagi@monom.org> writes:

Daniel> Using complete_all() is not wrong per se but it suggest that
Daniel> there might be more than one waiter. For -rt I am reviewing all
Daniel> complete_all() users and would like to leave only the real ones
Daniel> in the tree. The main problem for -rt about complete_all() is
Daniel> that it can be uses inside IRQ context and that can lead to
Daniel> unbounded amount work inside the interrupt handler. That is a no
Daniel> no for -rt.

Daniel> The patches grouped per subsystem and in small batches to allow
Daniel> reviewing.

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2016-09-14 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13  8:58 [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner
2016-09-13  8:58 ` [PATCH 1/3] csiostor: fix completion usage Daniel Wagner
2016-09-14  7:26   ` Christoph Hellwig
2016-09-13  8:58 ` [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all() Daniel Wagner
2016-09-14  7:26   ` Christoph Hellwig
2016-09-13  8:58 ` [PATCH 3/3] virtio_scsi: " Daniel Wagner
2016-09-14  7:27   ` Christoph Hellwig
2016-09-14 17:23 ` [PATCH 0/3] wireless: Use " Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.