qdio_perf.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * drivers/s390/cio/qdio_perf.c
  3. *
  4. * Copyright IBM Corp. 2008
  5. *
  6. * Author: Jan Glauber (jang@linux.vnet.ibm.com)
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/proc_fs.h>
  10. #include <linux/seq_file.h>
  11. #include <asm/ccwdev.h>
  12. #include "cio.h"
  13. #include "css.h"
  14. #include "device.h"
  15. #include "ioasm.h"
  16. #include "chsc.h"
  17. #include "qdio_debug.h"
  18. #include "qdio_perf.h"
  19. int qdio_performance_stats;
  20. struct qdio_perf_stats perf_stats;
  21. #ifdef CONFIG_PROC_FS
  22. static struct proc_dir_entry *qdio_perf_pde;
  23. #endif
  24. inline void qdio_perf_stat_inc(atomic_long_t *count)
  25. {
  26. if (qdio_performance_stats)
  27. atomic_long_inc(count);
  28. }
  29. inline void qdio_perf_stat_dec(atomic_long_t *count)
  30. {
  31. if (qdio_performance_stats)
  32. atomic_long_dec(count);
  33. }
  34. /*
  35. * procfs functions
  36. */
  37. static int qdio_perf_proc_show(struct seq_file *m, void *v)
  38. {
  39. seq_printf(m, "Number of qdio interrupts\t\t\t: %li\n",
  40. (long)atomic_long_read(&perf_stats.qdio_int));
  41. seq_printf(m, "Number of PCI interrupts\t\t\t: %li\n",
  42. (long)atomic_long_read(&perf_stats.pci_int));
  43. seq_printf(m, "Number of adapter interrupts\t\t\t: %li\n",
  44. (long)atomic_long_read(&perf_stats.thin_int));
  45. seq_printf(m, "\n");
  46. seq_printf(m, "Inbound tasklet runs\t\t\t\t: %li\n",
  47. (long)atomic_long_read(&perf_stats.tasklet_inbound));
  48. seq_printf(m, "Outbound tasklet runs\t\t\t\t: %li\n",
  49. (long)atomic_long_read(&perf_stats.tasklet_outbound));
  50. seq_printf(m, "Adapter interrupt tasklet runs/loops\t\t: %li/%li\n",
  51. (long)atomic_long_read(&perf_stats.tasklet_thinint),
  52. (long)atomic_long_read(&perf_stats.tasklet_thinint_loop));
  53. seq_printf(m, "Adapter interrupt inbound tasklet runs/loops\t: %li/%li\n",
  54. (long)atomic_long_read(&perf_stats.thinint_inbound),
  55. (long)atomic_long_read(&perf_stats.thinint_inbound_loop));
  56. seq_printf(m, "\n");
  57. seq_printf(m, "Number of SIGA In issued\t\t\t: %li\n",
  58. (long)atomic_long_read(&perf_stats.siga_in));
  59. seq_printf(m, "Number of SIGA Out issued\t\t\t: %li\n",
  60. (long)atomic_long_read(&perf_stats.siga_out));
  61. seq_printf(m, "Number of SIGA Sync issued\t\t\t: %li\n",
  62. (long)atomic_long_read(&perf_stats.siga_sync));
  63. seq_printf(m, "\n");
  64. seq_printf(m, "Number of inbound transfers\t\t\t: %li\n",
  65. (long)atomic_long_read(&perf_stats.inbound_handler));
  66. seq_printf(m, "Number of outbound transfers\t\t\t: %li\n",
  67. (long)atomic_long_read(&perf_stats.outbound_handler));
  68. seq_printf(m, "\n");
  69. seq_printf(m, "Number of fast requeues (outg. SBAL w/o SIGA)\t: %li\n",
  70. (long)atomic_long_read(&perf_stats.fast_requeue));
  71. seq_printf(m, "Number of outbound tasklet mod_timer calls\t: %li\n",
  72. (long)atomic_long_read(&perf_stats.debug_tl_out_timer));
  73. seq_printf(m, "Number of stop polling calls\t\t\t: %li\n",
  74. (long)atomic_long_read(&perf_stats.debug_stop_polling));
  75. seq_printf(m, "AI inbound tasklet loops after stop polling\t: %li\n",
  76. (long)atomic_long_read(&perf_stats.thinint_inbound_loop2));
  77. seq_printf(m, "\n");
  78. return 0;
  79. }
  80. static int qdio_perf_seq_open(struct inode *inode, struct file *filp)
  81. {
  82. return single_open(filp, qdio_perf_proc_show, NULL);
  83. }
  84. static struct file_operations qdio_perf_proc_fops = {
  85. .owner = THIS_MODULE,
  86. .open = qdio_perf_seq_open,
  87. .read = seq_read,
  88. .llseek = seq_lseek,
  89. .release = single_release,
  90. };
  91. /*
  92. * sysfs functions
  93. */
  94. static ssize_t qdio_perf_stats_show(struct bus_type *bus, char *buf)
  95. {
  96. return sprintf(buf, "%i\n", qdio_performance_stats ? 1 : 0);
  97. }
  98. static ssize_t qdio_perf_stats_store(struct bus_type *bus,
  99. const char *buf, size_t count)
  100. {
  101. unsigned long i;
  102. if (strict_strtoul(buf, 16, &i) != 0)
  103. return -EINVAL;
  104. if ((i != 0) && (i != 1))
  105. return -EINVAL;
  106. if (i == qdio_performance_stats)
  107. return count;
  108. qdio_performance_stats = i;
  109. /* reset performance statistics */
  110. if (i == 0)
  111. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  112. return count;
  113. }
  114. static BUS_ATTR(qdio_performance_stats, 0644, qdio_perf_stats_show,
  115. qdio_perf_stats_store);
  116. int __init qdio_setup_perf_stats(void)
  117. {
  118. int rc;
  119. rc = bus_create_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  120. if (rc)
  121. return rc;
  122. #ifdef CONFIG_PROC_FS
  123. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  124. qdio_perf_pde = proc_create("qdio_perf", S_IFREG | S_IRUGO,
  125. NULL, &qdio_perf_proc_fops);
  126. #endif
  127. return 0;
  128. }
  129. void qdio_remove_perf_stats(void)
  130. {
  131. #ifdef CONFIG_PROC_FS
  132. remove_proc_entry("qdio_perf", NULL);
  133. #endif
  134. bus_remove_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  135. }