me-debugfs.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <linux/cpumask.h>
  2. #include <linux/debugfs.h>
  3. #include <linux/fs.h>
  4. #include <linux/init.h>
  5. #include <linux/percpu.h>
  6. #include <linux/types.h>
  7. #include <asm/debug.h>
  8. #include <asm/fpu_emulator.h>
  9. #include <asm/local.h>
  10. DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
  11. static int fpuemu_stat_get(void *data, u64 *val)
  12. {
  13. int cpu;
  14. unsigned long sum = 0;
  15. for_each_online_cpu(cpu) {
  16. struct mips_fpu_emulator_stats *ps;
  17. local_t *pv;
  18. ps = &per_cpu(fpuemustats, cpu);
  19. pv = (void *)ps + (unsigned long)data;
  20. sum += local_read(pv);
  21. }
  22. *val = sum;
  23. return 0;
  24. }
  25. DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
  26. static int __init debugfs_fpuemu(void)
  27. {
  28. struct dentry *d, *dir;
  29. if (!mips_debugfs_dir)
  30. return -ENODEV;
  31. dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
  32. if (!dir)
  33. return -ENOMEM;
  34. #define FPU_EMU_STAT_OFFSET(m) \
  35. offsetof(struct mips_fpu_emulator_stats, m)
  36. #define FPU_STAT_CREATE(m) \
  37. do { \
  38. d = debugfs_create_file(#m , S_IRUGO, dir, \
  39. (void *)FPU_EMU_STAT_OFFSET(m), \
  40. &fops_fpuemu_stat); \
  41. if (!d) \
  42. return -ENOMEM; \
  43. } while (0)
  44. FPU_STAT_CREATE(emulated);
  45. FPU_STAT_CREATE(loads);
  46. FPU_STAT_CREATE(stores);
  47. FPU_STAT_CREATE(cp1ops);
  48. FPU_STAT_CREATE(cp1xops);
  49. FPU_STAT_CREATE(errors);
  50. FPU_STAT_CREATE(ieee754_inexact);
  51. FPU_STAT_CREATE(ieee754_underflow);
  52. FPU_STAT_CREATE(ieee754_overflow);
  53. FPU_STAT_CREATE(ieee754_zerodiv);
  54. FPU_STAT_CREATE(ieee754_invalidop);
  55. FPU_STAT_CREATE(ds_emul);
  56. return 0;
  57. }
  58. arch_initcall(debugfs_fpuemu);