Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1656816 > unrolled thread
| Started by | Christoph Hellwig <hch@lst.de> |
|---|---|
| First post | 2017-06-03 16:10 +0200 |
| Last post | 2017-06-04 17:20 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
spread MSI(-X) vectors to all possible CPUs V2 Christoph Hellwig <hch@lst.de> - 2017-06-03 16:10 +0200
[PATCH 3/8] genirq/affinity: factor out a irq_affinity_set helper Christoph Hellwig <hch@lst.de> - 2017-06-03 16:10 +0200
Re: [PATCH 3/8] genirq/affinity: factor out a irq_affinity_set helper Sagi Grimberg <sagi@grimberg.me> - 2017-06-04 17:20 +0200
[PATCH 6/8] blk-mq: include all present CPUs in the default queue mapping Christoph Hellwig <hch@lst.de> - 2017-06-03 16:10 +0200
Re: [PATCH 6/8] blk-mq: include all present CPUs in the default queue mapping Sagi Grimberg <sagi@grimberg.me> - 2017-06-04 17:20 +0200
[PATCH 8/8] nvme: allocate queues for all possible CPUs Christoph Hellwig <hch@lst.de> - 2017-06-03 16:10 +0200
Re: [PATCH 8/8] nvme: allocate queues for all possible CPUs Sagi Grimberg <sagi@grimberg.me> - 2017-06-04 17:20 +0200
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-06-03 16:10 +0200 |
| Subject | spread MSI(-X) vectors to all possible CPUs V2 |
| Message-ID | <tOhUB-81i-5@gated-at.bofh.it> |
Hi all, this series changes our automatic MSI-X vector assignment so that it takes all present CPUs into account instead of all online ones. This allows to better deal with cpu hotplug events, which could happen frequently due to power management for example. Changes since V1: - rebase to current Linus' tree - add irq_lock_sparse calls - move memory allocations outside of (raw) spinlocks - make the possible cpus per node mask safe vs physical CPU hotplug - remove the irq_force_complete_move call - factor some common code into helpers - identation fixups
[toc] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-06-03 16:10 +0200 |
| Subject | [PATCH 3/8] genirq/affinity: factor out a irq_affinity_set helper |
| Message-ID | <tOhUC-81i-21@gated-at.bofh.it> |
| In reply to | #1656816 |
Factor out code from the x86 cpu hot plug code to program the affinity
for a vector for a hot plug / hot unplug event.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/x86/kernel/irq.c | 23 ++---------------------
include/linux/interrupt.h | 1 +
kernel/irq/affinity.c | 28 ++++++++++++++++++++++++++++
3 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index f34fe7444836..a54eac5d81b3 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -437,7 +437,6 @@ void fixup_irqs(void)
struct irq_desc *desc;
struct irq_data *data;
struct irq_chip *chip;
- int ret;
for_each_irq_desc(irq, desc) {
int break_affinity = 0;
@@ -482,26 +481,8 @@ void fixup_irqs(void)
continue;
}
- if (!irqd_can_move_in_process_context(data) && chip->irq_mask)
- chip->irq_mask(data);
-
- if (chip->irq_set_affinity) {
- ret = chip->irq_set_affinity(data, affinity, true);
- if (ret == -ENOSPC)
- pr_crit("IRQ %d set affinity failed because there are no available vectors. The device assigned to this IRQ is unstable.\n", irq);
- } else {
- if (!(warned++))
- set_affinity = 0;
- }
-
- /*
- * We unmask if the irq was not marked masked by the
- * core code. That respects the lazy irq disable
- * behaviour.
- */
- if (!irqd_can_move_in_process_context(data) &&
- !irqd_irq_masked(data) && chip->irq_unmask)
- chip->irq_unmask(data);
+ if (!irq_affinity_set(irq, desc, affinity) && !warned++)
+ set_affinity = 0;
raw_spin_unlock(&desc->lock);
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a6fba4804672..afd3aa33e9b0 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -292,6 +292,7 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
struct cpumask *irq_create_affinity_masks(int nvec, const struct irq_affinity *affd);
int irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd);
+bool irq_affinity_set(int irq, struct irq_desc *desc, const cpumask_t *mask);
#else /* CONFIG_SMP */
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index e2d356dd7581..3cec0042fad2 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -1,8 +1,36 @@
#include <linux/interrupt.h>
+#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/cpu.h>
+#include "internals.h"
+
+bool irq_affinity_set(int irq, struct irq_desc *desc, const cpumask_t *mask)
+{
+ struct irq_data *data = irq_desc_get_irq_data(desc);
+ struct irq_chip *chip = irq_data_get_irq_chip(data);
+ bool ret = false;
+
+ if (!irq_can_move_pcntxt(data) && chip->irq_mask)
+ chip->irq_mask(data);
+
+ if (chip->irq_set_affinity) {
+ if (chip->irq_set_affinity(data, mask, true) == -ENOSPC)
+ pr_crit("IRQ %d set affinity failed because there are no available vectors. The device assigned to this IRQ is unstable.\n", irq);
+ ret = true;
+ }
+
+ /*
+ * We unmask if the irq was not marked masked by the core code.
+ * That respects the lazy irq disable behaviour.
+ */
+ if (!irq_can_move_pcntxt(data) &&
+ !irqd_irq_masked(data) && chip->irq_unmask)
+ chip->irq_unmask(data);
+
+ return ret;
+}
static void irq_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk,
int cpus_per_vec)
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Sagi Grimberg <sagi@grimberg.me> |
|---|---|
| Date | 2017-06-04 17:20 +0200 |
| Subject | Re: [PATCH 3/8] genirq/affinity: factor out a irq_affinity_set helper |
| Message-ID | <tOFtT-6QY-17@gated-at.bofh.it> |
| In reply to | #1656817 |
Looks good to me, Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-06-03 16:10 +0200 |
| Subject | [PATCH 6/8] blk-mq: include all present CPUs in the default queue mapping |
| Message-ID | <tOhUC-81i-23@gated-at.bofh.it> |
| In reply to | #1656816 |
This way we get a nice distribution independent of the current cpu
online / offline state.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-mq-cpumap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
index 8e61e8640e17..5eaecd40f701 100644
--- a/block/blk-mq-cpumap.c
+++ b/block/blk-mq-cpumap.c
@@ -35,7 +35,6 @@ int blk_mq_map_queues(struct blk_mq_tag_set *set)
{
unsigned int *map = set->mq_map;
unsigned int nr_queues = set->nr_hw_queues;
- const struct cpumask *online_mask = cpu_online_mask;
unsigned int i, nr_cpus, nr_uniq_cpus, queue, first_sibling;
cpumask_var_t cpus;
@@ -44,7 +43,7 @@ int blk_mq_map_queues(struct blk_mq_tag_set *set)
cpumask_clear(cpus);
nr_cpus = nr_uniq_cpus = 0;
- for_each_cpu(i, online_mask) {
+ for_each_present_cpu(i) {
nr_cpus++;
first_sibling = get_first_sibling(i);
if (!cpumask_test_cpu(first_sibling, cpus))
@@ -54,7 +53,7 @@ int blk_mq_map_queues(struct blk_mq_tag_set *set)
queue = 0;
for_each_possible_cpu(i) {
- if (!cpumask_test_cpu(i, online_mask)) {
+ if (!cpumask_test_cpu(i, cpu_present_mask)) {
map[i] = 0;
continue;
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Sagi Grimberg <sagi@grimberg.me> |
|---|---|
| Date | 2017-06-04 17:20 +0200 |
| Subject | Re: [PATCH 6/8] blk-mq: include all present CPUs in the default queue mapping |
| Message-ID | <tOFtT-6QY-3@gated-at.bofh.it> |
| In reply to | #1656818 |
Looks good, Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-06-03 16:10 +0200 |
| Subject | [PATCH 8/8] nvme: allocate queues for all possible CPUs |
| Message-ID | <tOhUC-81i-37@gated-at.bofh.it> |
| In reply to | #1656816 |
Unlike most drŅvers that simply pass the maximum possible vectors to pci_alloc_irq_vectors NVMe needs to configure the device before allocting the vectors, so it needs a manual update for the new scheme of using all present CPUs. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index d52701df7245..4152d93fbbef 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1525,7 +1525,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) struct pci_dev *pdev = to_pci_dev(dev->dev); int result, nr_io_queues, size; - nr_io_queues = num_online_cpus(); + nr_io_queues = num_present_cpus(); result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues); if (result < 0) return result; -- 2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Sagi Grimberg <sagi@grimberg.me> |
|---|---|
| Date | 2017-06-04 17:20 +0200 |
| Subject | Re: [PATCH 8/8] nvme: allocate queues for all possible CPUs |
| Message-ID | <tOFtT-6QY-1@gated-at.bofh.it> |
| In reply to | #1656823 |
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web