Skip to content

Commit 08f417d

Browse files
committed
LoongArch: Add irq_work support via self IPIs
Add irq_work support for LoongArch via self IPIs. This make it possible to run works in hardware interrupt context, which is a prerequisite for NOHZ_FULL. Implement: - arch_irq_work_raise() - arch_irq_work_has_interrupt() Reviewed-by: Guo Ren <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 12d3b55 commit 08f417d

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

arch/loongarch/include/asm/hardirq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
extern void ack_bad_irq(unsigned int irq);
1313
#define ack_bad_irq ack_bad_irq
1414

15-
#define NR_IPI 2
15+
#define NR_IPI 3
1616

1717
enum ipi_msg_type {
1818
IPI_RESCHEDULE,
1919
IPI_CALL_FUNCTION,
20+
IPI_IRQ_WORK,
2021
};
2122

2223
typedef struct {

arch/loongarch/include/asm/irq_work.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_LOONGARCH_IRQ_WORK_H
3+
#define _ASM_LOONGARCH_IRQ_WORK_H
4+
5+
static inline bool arch_irq_work_has_interrupt(void)
6+
{
7+
return IS_ENABLED(CONFIG_SMP);
8+
}
9+
10+
#endif /* _ASM_LOONGARCH_IRQ_WORK_H */

arch/loongarch/include/asm/smp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ extern int __cpu_logical_map[NR_CPUS];
6969
#define ACTION_BOOT_CPU 0
7070
#define ACTION_RESCHEDULE 1
7171
#define ACTION_CALL_FUNCTION 2
72+
#define ACTION_IRQ_WORK 3
7273
#define SMP_BOOT_CPU BIT(ACTION_BOOT_CPU)
7374
#define SMP_RESCHEDULE BIT(ACTION_RESCHEDULE)
7475
#define SMP_CALL_FUNCTION BIT(ACTION_CALL_FUNCTION)
76+
#define SMP_IRQ_WORK BIT(ACTION_IRQ_WORK)
7577

7678
struct secondary_data {
7779
unsigned long stack;

arch/loongarch/kernel/paravirt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/export.h>
33
#include <linux/types.h>
44
#include <linux/interrupt.h>
5+
#include <linux/irq_work.h>
56
#include <linux/jump_label.h>
67
#include <linux/kvm_para.h>
78
#include <linux/static_call.h>
@@ -97,6 +98,11 @@ static irqreturn_t pv_ipi_interrupt(int irq, void *dev)
9798
info->ipi_irqs[IPI_CALL_FUNCTION]++;
9899
}
99100

101+
if (action & SMP_IRQ_WORK) {
102+
irq_work_run();
103+
info->ipi_irqs[IPI_IRQ_WORK]++;
104+
}
105+
100106
return IRQ_HANDLED;
101107
}
102108

arch/loongarch/kernel/smp.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/cpumask.h>
1414
#include <linux/init.h>
1515
#include <linux/interrupt.h>
16+
#include <linux/irq_work.h>
1617
#include <linux/profile.h>
1718
#include <linux/seq_file.h>
1819
#include <linux/smp.h>
@@ -70,6 +71,7 @@ static DEFINE_PER_CPU(int, cpu_state);
7071
static const char *ipi_types[NR_IPI] __tracepoint_string = {
7172
[IPI_RESCHEDULE] = "Rescheduling interrupts",
7273
[IPI_CALL_FUNCTION] = "Function call interrupts",
74+
[IPI_IRQ_WORK] = "IRQ work interrupts",
7375
};
7476

7577
void show_ipi_list(struct seq_file *p, int prec)
@@ -217,6 +219,13 @@ void arch_smp_send_reschedule(int cpu)
217219
}
218220
EXPORT_SYMBOL_GPL(arch_smp_send_reschedule);
219221

222+
#ifdef CONFIG_IRQ_WORK
223+
void arch_irq_work_raise(void)
224+
{
225+
mp_ops.send_ipi_single(smp_processor_id(), ACTION_IRQ_WORK);
226+
}
227+
#endif
228+
220229
static irqreturn_t loongson_ipi_interrupt(int irq, void *dev)
221230
{
222231
unsigned int action;
@@ -234,6 +243,11 @@ static irqreturn_t loongson_ipi_interrupt(int irq, void *dev)
234243
per_cpu(irq_stat, cpu).ipi_irqs[IPI_CALL_FUNCTION]++;
235244
}
236245

246+
if (action & SMP_IRQ_WORK) {
247+
irq_work_run();
248+
per_cpu(irq_stat, cpu).ipi_irqs[IPI_IRQ_WORK]++;
249+
}
250+
237251
return IRQ_HANDLED;
238252
}
239253

0 commit comments

Comments
 (0)