smtc-proc.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * /proc hooks for SMTC kernel
  3. * Copyright (C) 2005 Mips Technologies, Inc
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/sched.h>
  7. #include <linux/cpumask.h>
  8. #include <linux/interrupt.h>
  9. #include <asm/cpu.h>
  10. #include <asm/processor.h>
  11. #include <linux/atomic.h>
  12. #include <asm/hardirq.h>
  13. #include <asm/mmu_context.h>
  14. #include <asm/mipsregs.h>
  15. #include <asm/cacheflush.h>
  16. #include <linux/proc_fs.h>
  17. #include <linux/seq_file.h>
  18. #include <asm/smtc_proc.h>
  19. /*
  20. * /proc diagnostic and statistics hooks
  21. */
  22. /*
  23. * Statistics gathered
  24. */
  25. unsigned long selfipis[NR_CPUS];
  26. struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
  27. atomic_t smtc_fpu_recoveries;
  28. static int smtc_proc_show(struct seq_file *m, void *v)
  29. {
  30. int i;
  31. extern unsigned long ebase;
  32. seq_printf(m, "SMTC Status Word: 0x%08x\n", smtc_status);
  33. seq_printf(m, "Config7: 0x%08x\n", read_c0_config7());
  34. seq_printf(m, "EBASE: 0x%08lx\n", ebase);
  35. seq_printf(m, "Counter Interrupts taken per CPU (TC)\n");
  36. for (i=0; i < NR_CPUS; i++)
  37. seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].timerints);
  38. seq_printf(m, "Self-IPIs by CPU:\n");
  39. for(i = 0; i < NR_CPUS; i++)
  40. seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
  41. seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
  42. atomic_read(&smtc_fpu_recoveries));
  43. return 0;
  44. }
  45. static int smtc_proc_open(struct inode *inode, struct file *file)
  46. {
  47. return single_open(file, smtc_proc_show, NULL);
  48. }
  49. static const struct file_operations smtc_proc_fops = {
  50. .open = smtc_proc_open,
  51. .read = seq_read,
  52. .llseek = seq_lseek,
  53. .release = single_release,
  54. };
  55. void init_smtc_stats(void)
  56. {
  57. int i;
  58. for (i=0; i<NR_CPUS; i++) {
  59. smtc_cpu_stats[i].timerints = 0;
  60. smtc_cpu_stats[i].selfipis = 0;
  61. }
  62. atomic_set(&smtc_fpu_recoveries, 0);
  63. proc_create("smtc", 0444, NULL, &smtc_proc_fops);
  64. }