linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
@ 2017-08-17 10:24 Christoph Hellwig
  2017-08-17 20:37 ` Omar Sandoval
  2017-08-18 14:08 ` Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-08-17 10:24 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, stable

While pci_irq_get_affinity should never fail for SMP kernel that
implement the affinity mapping, it will always return NULL in the
UP case, so provide a fallback mapping of all queues to CPU 0 in
that case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org
---
 block/blk-mq-pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c
index 0c3354cf3552..76944e3271bf 100644
--- a/block/blk-mq-pci.c
+++ b/block/blk-mq-pci.c
@@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
 	for (queue = 0; queue < set->nr_hw_queues; queue++) {
 		mask = pci_irq_get_affinity(pdev, queue);
 		if (!mask)
-			return -EINVAL;
+			goto fallback;
 
 		for_each_cpu(cpu, mask)
 			set->mq_map[cpu] = queue;
 	}
 
 	return 0;
+
+fallback:
+	WARN_ON_ONCE(set->nr_hw_queues > 1);
+	for_each_possible_cpu(cpu)
+		set->mq_map[cpu] = 0;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
-- 
2.11.0

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

* Re: [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
  2017-08-17 10:24 [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL Christoph Hellwig
@ 2017-08-17 20:37 ` Omar Sandoval
  2017-08-18 11:24   ` Christoph Hellwig
  2017-08-18 14:08 ` Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Omar Sandoval @ 2017-08-17 20:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-block, stable

On Thu, Aug 17, 2017 at 12:24:47PM +0200, Christoph Hellwig wrote:
> While pci_irq_get_affinity should never fail for SMP kernel that
> implement the affinity mapping, it will always return NULL in the
> UP case, so provide a fallback mapping of all queues to CPU 0 in
> that case.

Reviewed-by: Omar Sandoval <osandov@fb.com>

Has nvme been fixed to not crash if blk_mq_alloc_tag_set() fails?

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Cc: stable@vger.kernel.org
> ---
>  block/blk-mq-pci.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c
> index 0c3354cf3552..76944e3271bf 100644
> --- a/block/blk-mq-pci.c
> +++ b/block/blk-mq-pci.c
> @@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
>  	for (queue = 0; queue < set->nr_hw_queues; queue++) {
>  		mask = pci_irq_get_affinity(pdev, queue);
>  		if (!mask)
> -			return -EINVAL;
> +			goto fallback;
>  
>  		for_each_cpu(cpu, mask)
>  			set->mq_map[cpu] = queue;
>  	}
>  
>  	return 0;
> +
> +fallback:
> +	WARN_ON_ONCE(set->nr_hw_queues > 1);
> +	for_each_possible_cpu(cpu)
> +		set->mq_map[cpu] = 0;
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
> -- 
> 2.11.0
> 

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

* Re: [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
  2017-08-17 20:37 ` Omar Sandoval
@ 2017-08-18 11:24   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-08-18 11:24 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: Christoph Hellwig, axboe, linux-block, stable

On Thu, Aug 17, 2017 at 01:37:42PM -0700, Omar Sandoval wrote:
> On Thu, Aug 17, 2017 at 12:24:47PM +0200, Christoph Hellwig wrote:
> > While pci_irq_get_affinity should never fail for SMP kernel that
> > implement the affinity mapping, it will always return NULL in the
> > UP case, so provide a fallback mapping of all queues to CPU 0 in
> > that case.
> 
> Reviewed-by: Omar Sandoval <osandov@fb.com>
> 
> Has nvme been fixed to not crash if blk_mq_alloc_tag_set() fails?

No - Sagi didn't like the little fix from Max and no one else
has followed up.  I'll take a look.

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

* Re: [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
  2017-08-17 10:24 [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL Christoph Hellwig
  2017-08-17 20:37 ` Omar Sandoval
@ 2017-08-18 14:08 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2017-08-18 14:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block, stable

On 08/17/2017 04:24 AM, Christoph Hellwig wrote:
> While pci_irq_get_affinity should never fail for SMP kernel that
> implement the affinity mapping, it will always return NULL in the
> UP case, so provide a fallback mapping of all queues to CPU 0 in
> that case.

Applied for 4.13.

-- 
Jens Axboe

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

end of thread, other threads:[~2017-08-18 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 10:24 [PATCH] blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL Christoph Hellwig
2017-08-17 20:37 ` Omar Sandoval
2017-08-18 11:24   ` Christoph Hellwig
2017-08-18 14:08 ` Jens Axboe

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).