smtc-proc.c 2.0 KB

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