kvm-recheck-rcuscale-ftrace.sh (2680B)
1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0+ 3# 4# Analyze a given results directory for rcuscale performance measurements, 5# looking for ftrace data. Exits with 0 if data was found, analyzed, and 6# printed. Intended to be invoked from kvm-recheck-rcuscale.sh after 7# argument checking. 8# 9# Usage: kvm-recheck-rcuscale-ftrace.sh resdir 10# 11# Copyright (C) IBM Corporation, 2016 12# 13# Authors: Paul E. McKenney <paulmck@linux.ibm.com> 14 15i="$1" 16. functions.sh 17 18if test "`grep -c 'rcu_exp_grace_period.*start' < $i/console.log`" -lt 100 19then 20 exit 10 21fi 22 23sed -e 's/^\[[^]]*]//' < $i/console.log | 24grep 'us : rcu_exp_grace_period' | 25sed -e 's/us : / : /' | 26tr -d '\015' | 27awk ' 28$8 == "start" { 29 if (startseq != "") 30 nlost++; 31 starttask = $1; 32 starttime = $3; 33 startseq = $7; 34 seqtask[startseq] = starttask; 35} 36 37$8 == "end" { 38 if (startseq == $7) { 39 curgpdur = $3 - starttime; 40 gptimes[++n] = curgpdur; 41 gptaskcnt[starttask]++; 42 sum += curgpdur; 43 if (curgpdur > 1000) 44 print "Long GP " starttime "us to " $3 "us (" curgpdur "us)"; 45 startseq = ""; 46 } else { 47 # Lost a message or some such, reset. 48 startseq = ""; 49 nlost++; 50 } 51} 52 53$8 == "done" && seqtask[$7] != $1 { 54 piggybackcnt[$1]++; 55} 56 57END { 58 newNR = asort(gptimes); 59 if (newNR <= 0) { 60 print "No ftrace records found???" 61 exit 10; 62 } 63 pct50 = int(newNR * 50 / 100); 64 if (pct50 < 1) 65 pct50 = 1; 66 pct90 = int(newNR * 90 / 100); 67 if (pct90 < 1) 68 pct90 = 1; 69 pct99 = int(newNR * 99 / 100); 70 if (pct99 < 1) 71 pct99 = 1; 72 div = 10 ** int(log(gptimes[pct90]) / log(10) + .5) / 100; 73 print "Histogram bucket size: " div; 74 last = gptimes[1] - 10; 75 count = 0; 76 for (i = 1; i <= newNR; i++) { 77 current = div * int(gptimes[i] / div); 78 if (last == current) { 79 count++; 80 } else { 81 if (count > 0) 82 print last, count; 83 count = 1; 84 last = current; 85 } 86 } 87 if (count > 0) 88 print last, count; 89 print "Distribution of grace periods across tasks:"; 90 for (i in gptaskcnt) { 91 print "\t" i, gptaskcnt[i]; 92 nbatches += gptaskcnt[i]; 93 } 94 ngps = nbatches; 95 print "Distribution of piggybacking across tasks:"; 96 for (i in piggybackcnt) { 97 print "\t" i, piggybackcnt[i]; 98 ngps += piggybackcnt[i]; 99 } 100 print "Average grace-period duration: " sum / newNR " microseconds"; 101 print "Minimum grace-period duration: " gptimes[1]; 102 print "50th percentile grace-period duration: " gptimes[pct50]; 103 print "90th percentile grace-period duration: " gptimes[pct90]; 104 print "99th percentile grace-period duration: " gptimes[pct99]; 105 print "Maximum grace-period duration: " gptimes[newNR]; 106 print "Grace periods: " ngps + 0 " Batches: " nbatches + 0 " Ratio: " ngps / nbatches " Lost: " nlost + 0; 107 print "Computed from ftrace data."; 108}' 109exit 0