qdio_perf.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. /*
  25. * procfs functions
  26. */
  27. static int qdio_perf_proc_show(struct seq_file *m, void *v)
  28. {
  29. seq_printf(m, "Number of qdio interrupts\t\t\t: %li\n",
  30. (long)atomic_long_read(&perf_stats.qdio_int));
  31. seq_printf(m, "Number of PCI interrupts\t\t\t: %li\n",
  32. (long)atomic_long_read(&perf_stats.pci_int));
  33. seq_printf(m, "Number of adapter interrupts\t\t\t: %li\n",
  34. (long)atomic_long_read(&perf_stats.thin_int));
  35. seq_printf(m, "\n");
  36. seq_printf(m, "Inbound tasklet runs\t\t\t\t: %li\n",
  37. (long)atomic_long_read(&perf_stats.tasklet_inbound));
  38. seq_printf(m, "Outbound tasklet runs\t\t\t\t: %li\n",
  39. (long)atomic_long_read(&perf_stats.tasklet_outbound));
  40. seq_printf(m, "Adapter interrupt tasklet runs/loops\t\t: %li/%li\n",
  41. (long)atomic_long_read(&perf_stats.tasklet_thinint),
  42. (long)atomic_long_read(&perf_stats.tasklet_thinint_loop));
  43. seq_printf(m, "Adapter interrupt inbound tasklet runs/loops\t: %li/%li\n",
  44. (long)atomic_long_read(&perf_stats.thinint_inbound),
  45. (long)atomic_long_read(&perf_stats.thinint_inbound_loop));
  46. seq_printf(m, "\n");
  47. seq_printf(m, "Number of SIGA In issued\t\t\t: %li\n",
  48. (long)atomic_long_read(&perf_stats.siga_in));
  49. seq_printf(m, "Number of SIGA Out issued\t\t\t: %li\n",
  50. (long)atomic_long_read(&perf_stats.siga_out));
  51. seq_printf(m, "Number of SIGA Sync issued\t\t\t: %li\n",
  52. (long)atomic_long_read(&perf_stats.siga_sync));
  53. seq_printf(m, "\n");
  54. seq_printf(m, "Number of inbound transfers\t\t\t: %li\n",
  55. (long)atomic_long_read(&perf_stats.inbound_handler));
  56. seq_printf(m, "Number of outbound transfers\t\t\t: %li\n",
  57. (long)atomic_long_read(&perf_stats.outbound_handler));
  58. seq_printf(m, "\n");
  59. seq_printf(m, "Number of fast requeues (outg. SBAL w/o SIGA)\t: %li\n",
  60. (long)atomic_long_read(&perf_stats.fast_requeue));
  61. seq_printf(m, "Number of outbound target full condition\t: %li\n",
  62. (long)atomic_long_read(&perf_stats.outbound_target_full));
  63. seq_printf(m, "Number of inbound queue full condition\t\t: %li\n",
  64. (long)atomic_long_read(&perf_stats.inbound_queue_full));
  65. seq_printf(m, "Number of outbound tasklet mod_timer calls\t: %li\n",
  66. (long)atomic_long_read(&perf_stats.debug_tl_out_timer));
  67. seq_printf(m, "Number of stop polling calls\t\t\t: %li\n",
  68. (long)atomic_long_read(&perf_stats.debug_stop_polling));
  69. seq_printf(m, "AI inbound tasklet loops after stop polling\t: %li\n",
  70. (long)atomic_long_read(&perf_stats.thinint_inbound_loop2));
  71. seq_printf(m, "QEBSM EQBS total/incomplete\t\t\t: %li/%li\n",
  72. (long)atomic_long_read(&perf_stats.debug_eqbs_all),
  73. (long)atomic_long_read(&perf_stats.debug_eqbs_incomplete));
  74. seq_printf(m, "QEBSM SQBS total/incomplete\t\t\t: %li/%li\n",
  75. (long)atomic_long_read(&perf_stats.debug_sqbs_all),
  76. (long)atomic_long_read(&perf_stats.debug_sqbs_incomplete));
  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 const 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. }