qdio_perf.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 target full condition\t: %li\n",
  72. (long)atomic_long_read(&perf_stats.outbound_target_full));
  73. seq_printf(m, "Number of outbound tasklet mod_timer calls\t: %li\n",
  74. (long)atomic_long_read(&perf_stats.debug_tl_out_timer));
  75. seq_printf(m, "Number of stop polling calls\t\t\t: %li\n",
  76. (long)atomic_long_read(&perf_stats.debug_stop_polling));
  77. seq_printf(m, "AI inbound tasklet loops after stop polling\t: %li\n",
  78. (long)atomic_long_read(&perf_stats.thinint_inbound_loop2));
  79. seq_printf(m, "QEBSM EQBS total/incomplete\t\t\t: %li/%li\n",
  80. (long)atomic_long_read(&perf_stats.debug_eqbs_all),
  81. (long)atomic_long_read(&perf_stats.debug_eqbs_incomplete));
  82. seq_printf(m, "QEBSM SQBS total/incomplete\t\t\t: %li/%li\n",
  83. (long)atomic_long_read(&perf_stats.debug_sqbs_all),
  84. (long)atomic_long_read(&perf_stats.debug_sqbs_incomplete));
  85. seq_printf(m, "\n");
  86. return 0;
  87. }
  88. static int qdio_perf_seq_open(struct inode *inode, struct file *filp)
  89. {
  90. return single_open(filp, qdio_perf_proc_show, NULL);
  91. }
  92. static struct file_operations qdio_perf_proc_fops = {
  93. .owner = THIS_MODULE,
  94. .open = qdio_perf_seq_open,
  95. .read = seq_read,
  96. .llseek = seq_lseek,
  97. .release = single_release,
  98. };
  99. /*
  100. * sysfs functions
  101. */
  102. static ssize_t qdio_perf_stats_show(struct bus_type *bus, char *buf)
  103. {
  104. return sprintf(buf, "%i\n", qdio_performance_stats ? 1 : 0);
  105. }
  106. static ssize_t qdio_perf_stats_store(struct bus_type *bus,
  107. const char *buf, size_t count)
  108. {
  109. unsigned long i;
  110. if (strict_strtoul(buf, 16, &i) != 0)
  111. return -EINVAL;
  112. if ((i != 0) && (i != 1))
  113. return -EINVAL;
  114. if (i == qdio_performance_stats)
  115. return count;
  116. qdio_performance_stats = i;
  117. /* reset performance statistics */
  118. if (i == 0)
  119. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  120. return count;
  121. }
  122. static BUS_ATTR(qdio_performance_stats, 0644, qdio_perf_stats_show,
  123. qdio_perf_stats_store);
  124. int __init qdio_setup_perf_stats(void)
  125. {
  126. int rc;
  127. rc = bus_create_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  128. if (rc)
  129. return rc;
  130. #ifdef CONFIG_PROC_FS
  131. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  132. qdio_perf_pde = proc_create("qdio_perf", S_IFREG | S_IRUGO,
  133. NULL, &qdio_perf_proc_fops);
  134. #endif
  135. return 0;
  136. }
  137. void qdio_remove_perf_stats(void)
  138. {
  139. #ifdef CONFIG_PROC_FS
  140. remove_proc_entry("qdio_perf", NULL);
  141. #endif
  142. bus_remove_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  143. }