[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210915175848.162260-4-me@ilammy.net>
Date: Thu, 16 Sep 2021 02:58:39 +0900
From: Alexei Lozovsky <me@...mmy.net>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Alexey Dobriyan <adobriyan@...il.com>,
Christoph Lameter <cl@...ux.com>,
LKML <linux-kernel@...r.kernel.org>,
linux-fsdevel@...r.kernel.org
Subject: [PATCH v2 03/12] powerpc/irq: Use READ_ONCE for IRQ counter reads
Just like with generic IRQ counters in the previous commit,
wrap accesses to per-CPU counters from irq_cpustat_t in READ_ONCE.
Grab that one "hmi_irqs" oddball from struct paca_struct as well.
These memory loads should not be torn, let's make it explicit.
Signed-off-by: Alexei Lozovsky <me@...mmy.net>
---
arch/powerpc/kernel/irq.c | 40 +++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 551b653228c4..e5082d8be700 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -581,52 +581,52 @@ int arch_show_interrupts(struct seq_file *p, int prec)
seq_printf(p, "%*s: ", prec, "LOC");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).timer_irqs_event);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).timer_irqs_event));
seq_printf(p, " Local timer interrupts for timer event device\n");
seq_printf(p, "%*s: ", prec, "BCT");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).broadcast_irqs_event);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).broadcast_irqs_event));
seq_printf(p, " Broadcast timer interrupts for timer event device\n");
seq_printf(p, "%*s: ", prec, "LOC");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).timer_irqs_others);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).timer_irqs_others));
seq_printf(p, " Local timer interrupts for others\n");
seq_printf(p, "%*s: ", prec, "SPU");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).spurious_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).spurious_irqs));
seq_printf(p, " Spurious interrupts\n");
seq_printf(p, "%*s: ", prec, "PMI");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).pmu_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).pmu_irqs));
seq_printf(p, " Performance monitoring interrupts\n");
seq_printf(p, "%*s: ", prec, "MCE");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).mce_exceptions);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).mce_exceptions));
seq_printf(p, " Machine check exceptions\n");
#ifdef CONFIG_PPC_BOOK3S_64
if (cpu_has_feature(CPU_FTR_HVMODE)) {
seq_printf(p, "%*s: ", prec, "HMI");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", paca_ptrs[j]->hmi_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(paca_ptrs[j]->hmi_irqs));
seq_printf(p, " Hypervisor Maintenance Interrupts\n");
}
#endif
seq_printf(p, "%*s: ", prec, "NMI");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).sreset_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).sreset_irqs));
seq_printf(p, " System Reset interrupts\n");
#ifdef CONFIG_PPC_WATCHDOG
seq_printf(p, "%*s: ", prec, "WDG");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).soft_nmi_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).soft_nmi_irqs));
seq_printf(p, " Watchdog soft-NMI interrupts\n");
#endif
@@ -634,7 +634,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
if (cpu_has_feature(CPU_FTR_DBELL)) {
seq_printf(p, "%*s: ", prec, "DBL");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat, j).doorbell_irqs);
+ seq_printf(p, "%10u ", READ_ONCE(per_cpu(irq_stat, j).doorbell_irqs));
seq_printf(p, " Doorbell interrupts\n");
}
#endif
@@ -647,22 +647,22 @@ int arch_show_interrupts(struct seq_file *p, int prec)
*/
u64 arch_irq_stat_cpu(unsigned int cpu)
{
- u64 sum = per_cpu(irq_stat, cpu).timer_irqs_event;
+ u64 sum = READ_ONCE(per_cpu(irq_stat, cpu).timer_irqs_event);
- sum += per_cpu(irq_stat, cpu).broadcast_irqs_event;
- sum += per_cpu(irq_stat, cpu).pmu_irqs;
- sum += per_cpu(irq_stat, cpu).mce_exceptions;
- sum += per_cpu(irq_stat, cpu).spurious_irqs;
- sum += per_cpu(irq_stat, cpu).timer_irqs_others;
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).broadcast_irqs_event);
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).pmu_irqs);
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).mce_exceptions);
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).spurious_irqs);
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).timer_irqs_others);
#ifdef CONFIG_PPC_BOOK3S_64
- sum += paca_ptrs[cpu]->hmi_irqs;
+ sum += READ_ONCE(paca_ptrs[cpu]->hmi_irqs);
#endif
- sum += per_cpu(irq_stat, cpu).sreset_irqs;
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).sreset_irqs);
#ifdef CONFIG_PPC_WATCHDOG
- sum += per_cpu(irq_stat, cpu).soft_nmi_irqs;
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).soft_nmi_irqs);
#endif
#ifdef CONFIG_PPC_DOORBELL
- sum += per_cpu(irq_stat, cpu).doorbell_irqs;
+ sum += READ_ONCE(per_cpu(irq_stat, cpu).doorbell_irqs);
#endif
return sum;
--
2.25.1
Powered by blists - more mailing lists