smtc-proc.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <asm/atomic.h>
  12. #include <asm/system.h>
  13. #include <asm/hardirq.h>
  14. #include <asm/mmu_context.h>
  15. #include <asm/smp.h>
  16. #include <asm/mipsregs.h>
  17. #include <asm/cacheflush.h>
  18. #include <linux/proc_fs.h>
  19. #include <asm/smtc_proc.h>
  20. /*
  21. * /proc diagnostic and statistics hooks
  22. */
  23. /*
  24. * Statistics gathered
  25. */
  26. unsigned long selfipis[NR_CPUS];
  27. struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
  28. static struct proc_dir_entry *smtc_stats;
  29. atomic_t smtc_fpu_recoveries;
  30. static int proc_read_smtc(char *page, char **start, off_t off,
  31. int count, int *eof, void *data)
  32. {
  33. int totalen = 0;
  34. int len;
  35. int i;
  36. extern unsigned long ebase;
  37. len = sprintf(page, "SMTC Status Word: 0x%08x\n", smtc_status);
  38. totalen += len;
  39. page += len;
  40. len = sprintf(page, "Config7: 0x%08x\n", read_c0_config7());
  41. totalen += len;
  42. page += len;
  43. len = sprintf(page, "EBASE: 0x%08lx\n", ebase);
  44. totalen += len;
  45. page += len;
  46. len = sprintf(page, "Counter Interrupts taken per CPU (TC)\n");
  47. totalen += len;
  48. page += len;
  49. for (i=0; i < NR_CPUS; i++) {
  50. len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].timerints);
  51. totalen += len;
  52. page += len;
  53. }
  54. len = sprintf(page, "Self-IPIs by CPU:\n");
  55. totalen += len;
  56. page += len;
  57. for(i = 0; i < NR_CPUS; i++) {
  58. len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
  59. totalen += len;
  60. page += len;
  61. }
  62. len = sprintf(page, "%d Recoveries of \"stolen\" FPU\n",
  63. atomic_read(&smtc_fpu_recoveries));
  64. totalen += len;
  65. page += len;
  66. return totalen;
  67. }
  68. void init_smtc_stats(void)
  69. {
  70. int i;
  71. for (i=0; i<NR_CPUS; i++) {
  72. smtc_cpu_stats[i].timerints = 0;
  73. smtc_cpu_stats[i].selfipis = 0;
  74. }
  75. atomic_set(&smtc_fpu_recoveries, 0);
  76. smtc_stats = create_proc_read_entry("smtc", 0444, NULL,
  77. proc_read_smtc, NULL);
  78. }