kvm-recheck-rcuperf-ftrace.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. #
  3. # Analyze a given results directory for rcuperf performance measurements,
  4. # looking for ftrace data. Exits with 0 if data was found, analyzed, and
  5. # printed. Intended to be invoked from kvm-recheck-rcuperf.sh after
  6. # argument checking.
  7. #
  8. # Usage: kvm-recheck-rcuperf-ftrace.sh resdir
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program; if not, you can access it online at
  22. # http://www.gnu.org/licenses/gpl-2.0.html.
  23. #
  24. # Copyright (C) IBM Corporation, 2016
  25. #
  26. # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  27. i="$1"
  28. . tools/testing/selftests/rcutorture/bin/functions.sh
  29. if test "`grep -c 'rcu_exp_grace_period.*start' < $i/console.log`" -lt 100
  30. then
  31. exit 10
  32. fi
  33. sed -e 's/^\[[^]]*]//' < $i/console.log |
  34. grep 'us : rcu_exp_grace_period' |
  35. sed -e 's/us : / : /' |
  36. tr -d '\015' |
  37. awk '
  38. $8 == "start" {
  39. if (starttask != "")
  40. nlost++;
  41. starttask = $1;
  42. starttime = $3;
  43. startseq = $7;
  44. }
  45. $8 == "end" {
  46. if (starttask == $1 && startseq == $7) {
  47. curgpdur = $3 - starttime;
  48. gptimes[++n] = curgpdur;
  49. gptaskcnt[starttask]++;
  50. sum += curgpdur;
  51. if (curgpdur > 1000)
  52. print "Long GP " starttime "us to " $3 "us (" curgpdur "us)";
  53. starttask = "";
  54. } else {
  55. # Lost a message or some such, reset.
  56. starttask = "";
  57. nlost++;
  58. }
  59. }
  60. $8 == "done" {
  61. piggybackcnt[$1]++;
  62. }
  63. END {
  64. newNR = asort(gptimes);
  65. if (newNR <= 0) {
  66. print "No ftrace records found???"
  67. exit 10;
  68. }
  69. pct50 = int(newNR * 50 / 100);
  70. if (pct50 < 1)
  71. pct50 = 1;
  72. pct90 = int(newNR * 90 / 100);
  73. if (pct90 < 1)
  74. pct90 = 1;
  75. pct99 = int(newNR * 99 / 100);
  76. if (pct99 < 1)
  77. pct99 = 1;
  78. div = 10 ** int(log(gptimes[pct90]) / log(10) + .5) / 100;
  79. print "Histogram bucket size: " div;
  80. last = gptimes[1] - 10;
  81. count = 0;
  82. for (i = 1; i <= newNR; i++) {
  83. current = div * int(gptimes[i] / div);
  84. if (last == current) {
  85. count++;
  86. } else {
  87. if (count > 0)
  88. print last, count;
  89. count = 1;
  90. last = current;
  91. }
  92. }
  93. if (count > 0)
  94. print last, count;
  95. print "Distribution of grace periods across tasks:";
  96. for (i in gptaskcnt) {
  97. print "\t" i, gptaskcnt[i];
  98. nbatches += gptaskcnt[i];
  99. }
  100. ngps = nbatches;
  101. print "Distribution of piggybacking across tasks:";
  102. for (i in piggybackcnt) {
  103. print "\t" i, piggybackcnt[i];
  104. ngps += piggybackcnt[i];
  105. }
  106. print "Average grace-period duration: " sum / newNR " microseconds";
  107. print "Minimum grace-period duration: " gptimes[1];
  108. print "50th percentile grace-period duration: " gptimes[pct50];
  109. print "90th percentile grace-period duration: " gptimes[pct90];
  110. print "99th percentile grace-period duration: " gptimes[pct99];
  111. print "Maximum grace-period duration: " gptimes[newNR];
  112. print "Grace periods: " ngps + 0 " Batches: " nbatches + 0 " Ratio: " ngps / nbatches " Lost: " nlost + 0;
  113. print "Computed from ftrace data.";
  114. }'
  115. exit 0