Skip to content

Commit 258e7d2

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
genirq: Add affinity to percpu_devid interrupt requests
Add an affinity field to both the irqaction structure and the interrupt request primitives. Nothing is making use of it yet, and the only value used it NULL, which is used as a shorthand for cpu_possible_mask. This will shortly get used with actual affinities. Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Will Deacon <will@kernel.org> Link: https://patch.msgid.link/20251020122944.3074811-15-maz@kernel.org
1 parent 9047a39 commit 258e7d2

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

include/linux/interrupt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct irqaction {
125125
void *dev_id;
126126
void __percpu *percpu_dev_id;
127127
};
128+
const struct cpumask *affinity;
128129
struct irqaction *next;
129130
irq_handler_t thread_fn;
130131
struct task_struct *thread;
@@ -181,7 +182,7 @@ request_any_context_irq(unsigned int irq, irq_handler_t handler,
181182
extern int __must_check
182183
__request_percpu_irq(unsigned int irq, irq_handler_t handler,
183184
unsigned long flags, const char *devname,
184-
void __percpu *percpu_dev_id);
185+
const cpumask_t *affinity, void __percpu *percpu_dev_id);
185186

186187
extern int __must_check
187188
request_nmi(unsigned int irq, irq_handler_t handler, unsigned long flags,
@@ -192,7 +193,7 @@ request_percpu_irq(unsigned int irq, irq_handler_t handler,
192193
const char *devname, void __percpu *percpu_dev_id)
193194
{
194195
return __request_percpu_irq(irq, handler, 0,
195-
devname, percpu_dev_id);
196+
devname, NULL, percpu_dev_id);
196197
}
197198

198199
extern int __must_check

kernel/irq/manage.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,10 +2444,14 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)
24442444

24452445
static
24462446
struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long flags,
2447-
const char *devname, void __percpu *dev_id)
2447+
const char *devname, const cpumask_t *affinity,
2448+
void __percpu *dev_id)
24482449
{
24492450
struct irqaction *action;
24502451

2452+
if (!affinity)
2453+
affinity = cpu_possible_mask;
2454+
24512455
action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
24522456
if (!action)
24532457
return NULL;
@@ -2456,6 +2460,7 @@ struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long f
24562460
action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND;
24572461
action->name = devname;
24582462
action->percpu_dev_id = dev_id;
2463+
action->affinity = affinity;
24592464

24602465
return action;
24612466
}
@@ -2466,6 +2471,7 @@ struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long f
24662471
* @handler: Function to be called when the IRQ occurs.
24672472
* @flags: Interrupt type flags (IRQF_TIMER only)
24682473
* @devname: An ascii name for the claiming device
2474+
* @affinity: A cpumask describing the target CPUs for this interrupt
24692475
* @dev_id: A percpu cookie passed back to the handler function
24702476
*
24712477
* This call allocates interrupt resources, but doesn't enable the interrupt
@@ -2478,7 +2484,7 @@ struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long f
24782484
*/
24792485
int __request_percpu_irq(unsigned int irq, irq_handler_t handler,
24802486
unsigned long flags, const char *devname,
2481-
void __percpu *dev_id)
2487+
const cpumask_t *affinity, void __percpu *dev_id)
24822488
{
24832489
struct irqaction *action;
24842490
struct irq_desc *desc;
@@ -2495,7 +2501,7 @@ int __request_percpu_irq(unsigned int irq, irq_handler_t handler,
24952501
if (flags && flags != IRQF_TIMER)
24962502
return -EINVAL;
24972503

2498-
action = create_percpu_irqaction(handler, flags, devname, dev_id);
2504+
action = create_percpu_irqaction(handler, flags, devname, affinity, dev_id);
24992505
if (!action)
25002506
return -ENOMEM;
25012507

@@ -2560,7 +2566,7 @@ int request_percpu_nmi(unsigned int irq, irq_handler_t handler,
25602566
return -EINVAL;
25612567

25622568
action = create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALANCING,
2563-
name, dev_id);
2569+
name, NULL, dev_id);
25642570
if (!action)
25652571
return -ENOMEM;
25662572

0 commit comments

Comments
 (0)