Skip to content

Commit c410abb

Browse files
douliyangKAGA-KOKO
authored andcommitted
genirq/affinity: Add is_managed to struct irq_affinity_desc
Devices which use managed interrupts usually have two classes of interrupts: - Interrupts for multiple device queues - Interrupts for general device management Currently both classes are treated the same way, i.e. as managed interrupts. The general interrupts get the default affinity mask assigned while the device queue interrupts are spread out over the possible CPUs. Treating the general interrupts as managed is both a limitation and under certain circumstances a bug. Assume the following situation: default_irq_affinity = 4..7 So if CPUs 4-7 are offlined, then the core code will shut down the device management interrupts because the last CPU in their affinity mask went offline. It's also a limitation because it's desired to allow manual placement of the general device interrupts for various reasons. If they are marked managed then the interrupt affinity setting from both user and kernel space is disabled. That limitation was reported by Kashyap and Sumit. Expand struct irq_affinity_desc with a new bit 'is_managed' which is set for truly managed interrupts (queue interrupts) and cleared for the general device interrupts. [ tglx: Simplify code and massage changelog ] Reported-by: Kashyap Desai <kashyap.desai@broadcom.com> Reported-by: Sumit Saxena <sumit.saxena@broadcom.com> Signed-off-by: Dou Liyang <douliyangs@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-pci@vger.kernel.org Cc: shivasharan.srikanteshwara@broadcom.com Cc: ming.lei@redhat.com Cc: hch@lst.de Cc: bhelgaas@google.com Cc: douliyang1@huawei.com Link: https://lkml.kernel.org/r/20181204155122.6327-3-douliyangs@gmail.com
1 parent bec0403 commit c410abb

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

include/linux/interrupt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ struct irq_affinity {
263263
*/
264264
struct irq_affinity_desc {
265265
struct cpumask mask;
266+
unsigned int is_managed : 1;
266267
};
267268

268269
#if defined(CONFIG_SMP)

kernel/irq/affinity.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
289289
for (; curvec < nvecs; curvec++)
290290
cpumask_copy(&masks[curvec].mask, irq_default_affinity);
291291

292+
/* Mark the managed interrupts */
293+
for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++)
294+
masks[i].is_managed = 1;
295+
292296
outnodemsk:
293297
free_node_to_cpumask(node_to_cpumask);
294298
return masks;

kernel/irq/irqdesc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,27 +453,30 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node,
453453
struct module *owner)
454454
{
455455
struct irq_desc *desc;
456-
unsigned int flags;
457456
int i;
458457

459458
/* Validate affinity mask(s) */
460459
if (affinity) {
461-
for (i = 0; i < cnt; i++) {
460+
for (i = 0; i < cnt; i++, i++) {
462461
if (cpumask_empty(&affinity[i].mask))
463462
return -EINVAL;
464463
}
465464
}
466465

467-
flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0;
468-
469466
for (i = 0; i < cnt; i++) {
470467
const struct cpumask *mask = NULL;
468+
unsigned int flags = 0;
471469

472470
if (affinity) {
473-
node = cpu_to_node(cpumask_first(affinity));
471+
if (affinity->is_managed) {
472+
flags = IRQD_AFFINITY_MANAGED |
473+
IRQD_MANAGED_SHUTDOWN;
474+
}
474475
mask = &affinity->mask;
476+
node = cpu_to_node(cpumask_first(mask));
475477
affinity++;
476478
}
479+
477480
desc = alloc_desc(start + i, node, flags, mask, owner);
478481
if (!desc)
479482
goto err;

0 commit comments

Comments
 (0)