MIPS: Collect FPU emulator statistics per-CPU.
PATCH 1/1 MIPS: Collect FPU emulator statistics per-CPU.
On SMP systems, the collection of statistics can cause cache line bouncing in the lines associated with the counters. Also there are races incrementing the counters on multiple CPUs.
To fix both problems, we collect the statistics in per-CPU variables, and add them up in the debugfs read operation.
As a test I ran the LTP float_bessel test on a 12 CPU Octeon system.
Without CONFIG_DEBUG_FS : 2602 seconds. With CONFIG_DEBUG_FS: 2640 seconds.
With non-cpu-local atomic statistics: 14569 seconds.
Signed-off-by David Daney <[email protected]>
--- arch/mips/include/asm/fpu_emulator.h | 24 ++++++-- arch/mips/math-emu/cp1emu.c | 102 ++++++++++++++++++++-------------- arch/mips/math-emu/dsemul.c | 4 +- 3 files changed, 80 insertions(+), 50 deletions(-)
arch/mips/include/asm/fpu_emulator.h +17 -7
@@ -25,17 +25,27 @@#include <asm/break.h> #include <asm/inst.h> +#include <asm/local.h> + +#ifdef CONFIG_DEBUG_FS struct mips_fpu_emulator_stats { -unsigned int emulated; -unsigned int loads; -unsigned int stores; -unsigned int cp1ops; -unsigned int cp1xops; -unsigned int errors; +local_t emulated; +local_t loads; +local_t stores; +local_t cp1ops; +local_t cp1xops; +local_t errors; }; -extern struct mips_fpu_emulator_stats fpuemustats; +DECLARE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats); + +#define MIPS_FPU_EMU_INC_STATS (M ) \ + cpu_local_wrap(__local_inc(&__get_cpu_var(fpuemustats).M)) + +#else +#define MIPS_FPU_EMU_INC_STATS (M ) do { } while (0) +#endif /* CONFIG_DEBUG_FS */ extern int mips_dsemul (struct pt_regs *regs,mips_instruction ir,unsigned long cpc);
arch/mips/math-emu/cp1emu.c +61 -41
233 lines not on this page · raw message
arch/mips/math-emu/dsemul.c +2 -2
@@ -98,7 +98,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) err |=__put_user (cpc, &fr->epc);if (unlikely (err)) { - fpuemustats.errors++; +MIPS_FPU_EMU_INC_STATS (errors);return SIGBUS ; }
@@ -136,7 +136,7 @@ int do_dsemulret(struct pt_regs *xcp) err |=__get_user (cookie, &fr->cookie);if (unlikely (err || (insn !=BREAK_MATH ) || (cookie !=BD_COOKIE ))) { - fpuemustats.errors++; +MIPS_FPU_EMU_INC_STATS (errors);return 0 ; }
Signature · 1 line
1.6.0.6
On Thu, Nov 05, 2009 at 11:34:26AM -0800, David Daney wrote:
Thanks, queued for 2.6.33.
Ralf