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 28i="$1" 29. functions.sh 30 31if test "`grep -c 'rcu_exp_grace_period.*start' < $i/console.log`" -lt 100 32then 33 exit 10 34fi 35 36sed -e 's/^\[[^]]*]//' < $i/console.log | 37grep 'us : rcu_exp_grace_period' | 38sed -e 's/us : / : /' | 39tr -d '\015' | 40awk ' 41$8 == "start" { 42 if (startseq != "") 43 nlost++; 44 starttask = $1; 45 starttime = $3; 46 startseq = $7; 47 seqtask[startseq] = starttask; 48} 49 50$8 == "end" { 51 if (startseq == $7) { 52 curgpdur = $3 - starttime; 53 gptimes[++n] = curgpdur; 54 gptaskcnt[starttask]++; 55 sum += curgpdur; 56 if (curgpdur > 1000) 57 print "Long GP " starttime "us to " $3 "us (" curgpdur "us)"; 58 startseq = ""; 59 } else { 60 # Lost a message or some such, reset. 61 startseq = ""; 62 nlost++; 63 } 64} 65 66$8 == "done" && seqtask[$7] != $1 { 67 piggybackcnt[$1]++; 68} 69 70END { 71 newNR = asort(gptimes); 72 if (newNR <= 0) { 73 print "No ftrace records found???" 74 exit 10; 75 } 76 pct50 = int(newNR * 50 / 100); 77 if (pct50 < 1) 78 pct50 = 1; 79 pct90 = int(newNR * 90 / 100); 80 if (pct90 < 1) 81 pct90 = 1; 82 pct99 = int(newNR * 99 / 100); 83 if (pct99 < 1) 84 pct99 = 1; 85 div = 10 ** int(log(gptimes[pct90]) / log(10) + .5) / 100; 86 print "Histogram bucket size: " div; 87 last = gptimes[1] - 10; 88 count = 0; 89 for (i = 1; i <= newNR; i++) { 90 current = div * int(gptimes[i] / div); 91 if (last == current) { 92 count++; 93 } else { 94 if (count > 0) 95 print last, count; 96 count = 1; 97 last = current; 98 } 99 } 100 if (count > 0) 101 print last, count; 102 print "Distribution of grace periods across tasks:"; 103 for (i in gptaskcnt) { 104 print "\t" i, gptaskcnt[i]; 105 nbatches += gptaskcnt[i]; 106 } 107 ngps = nbatches; 108 print "Distribution of piggybacking across tasks:"; 109 for (i in piggybackcnt) { 110 print "\t" i, piggybackcnt[i]; 111 ngps += piggybackcnt[i]; 112 } 113 print "Average grace-period duration: " sum / newNR " microseconds"; 114 print "Minimum grace-period duration: " gptimes[1]; 115 print "50th percentile grace-period duration: " gptimes[pct50]; 116 print "90th percentile grace-period duration: " gptimes[pct90]; 117 print "99th percentile grace-period duration: " gptimes[pct99]; 118 print "Maximum grace-period duration: " gptimes[newNR]; 119 print "Grace periods: " ngps + 0 " Batches: " nbatches + 0 " Ratio: " ngps / nbatches " Lost: " nlost + 0; 120 print "Computed from ftrace data."; 121}' 122exit 0 123