Whamcloud - gitweb
LU-5396 lov: (and ldlm) make some functions static
[fs/lustre-release.git] / lustre-iokit / sgpdd-survey / sgpdd-survey
index 5c2af8a..8edd1e8 100755 (executable)
@@ -38,12 +38,26 @@ boundary=${boundary:-1024}
 thrlo=${thrlo:-1}
 thrhi=${thrhi:-4096}
 
+# NUMA support
+# User provided script that returns a cpu list from a specified device.
+# Implementation depends on the type of device (scsi/raw, with/without
+# multipath, technology fc/sas/ib)
+# For example:
+#   $ cat bin/dev2cpus
+#   #!/bin/bash
+#   dev=$(basename $1)
+#   pci=$(readlink -f /sys/class/block/$dev | cut -d/ -f1-5)
+#   cat ${pci}/local_cpulist
+dev2cpus=${dev2cpus:-""}
+
 #####################################################################
 # leave the rest of this alone unless you know what you're doing...
 
 # and max # threads one instance will spawn
 SG_MAX_QUEUE=16
 
+# numactl command
+NUMACTL=${NUMACTL:-"/usr/bin/numactl"}
 
 unique () {
     echo "$@" | xargs -n1 echo | sort -u
@@ -124,6 +138,14 @@ for d in $scsidevs $rawdevs; do
 done
 unique_hosts=(`unique ${hosts[@]}`)
 
+# get device cpu list
+devcpus=()
+if [ -n "$dev2cpus" ]; then
+    for ((i=0; i < $ndevs; i++)); do
+       devcpus[$i]=$(remote_shell ${hosts[$i]} $dev2cpus ${devs[$i]})
+    done
+fi
+
 # map given device names into SG device names
 if [ "$scsidevs" ]; then
     # make sure sg kernel module is loaded
@@ -138,27 +160,28 @@ if [ "$scsidevs" ]; then
     done
 
     for ((i=0; i < $ndevs; i++)); do
-       # resolv symbolic link if any
+       # resolve symbolic link if any
        devs[$i]=$(remote_shell ${hosts[$i]} readlink -f ${devs[$i]})
 
        # retrieve associated sg device
        # we will test for a LUN, the test for a partition
        # if the partition number is > 9 this will fail
-       devs[$i]=$(remote_shell ${hosts[$i]} sg_map | \
-                  awk -v dev=${devs[$i]} '{if ($2 == dev) print $1}')
-       if [ -z "${devs[i]}" ]; then
+       tmp=$(remote_shell ${hosts[$i]} sg_map | \
+             awk -v dev=${devs[$i]} '{if ($2 == dev) print $1}')
+       if [ -z "$tmp" ]; then
            echo "Can't find SG device for ${hosts[$i]}:${devs[$i]}, " \
                 "testing for partition"
            pt=`echo ${devs[$i]} | sed 's/[0-9]*$//'`
            # Try again
-           devs[$i]=$(remote_shell ${hosts[$i]} sg_map | \
-                      awk -v dev=$pt '{if ($2 == dev) print $1}')
-           if [ -z "${devs[i]}" ]; then
+           tmp=$(remote_shell ${hosts[$i]} sg_map | \
+                 awk -v dev=$pt '{if ($2 == dev) print $1}')
+           if [ -z "$tmp" ]; then
                echo -e "Can't find SG device ${hosts[$i]}:$pt.\n" \
                        "Do you have the sg module configured for your kernel?"
                exit 1
           fi
        fi
+       devs[$i]=$tmp
     done
 elif [ "$rawdevs" ]; then
     for ((i=0; i < $ndevs; i++)); do
@@ -277,8 +300,14 @@ for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
                        outf="of=$dev"
                        skip=seek
                    fi
+                   if [ -n "${devcpus[$i]}" -a -x "$NUMACTL" ]; then
+                       numacmd="$NUMACTL --physcpubind=${devcpus[$i]} --localalloc"
+                   else
+                       numacmd=""
+                   fi
                    for ((j=0;j<crg;j++)); do 
                        echo >> ${cmdsf}_${host} \
+                               "$numacmd " \
                                "sgp_dd 2> ${tmpf}_${i}_${j} $inf $outf " \
                                "${skip}=$((boundary+j*blocks)) " \
                                "thr=$((thr/crg)) count=$count bs=${bs[$i]} " \
@@ -330,15 +359,17 @@ for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
                if ((ok != ndevs*crg)); then
                    print_summary -n "$((ndevs*crg - ok)) failed "
                else
-                   # compute MB/sec from elapsed
-                   bw=`awk "BEGIN {printf \"%7.2f MB/s\", \
+                   # compute bandwidth in MiB/s from total data / elapsed time
+                   bw=`awk "BEGIN {printf \"%7.2f \", \
                                    $total_size / (( $t1 - $t0 ) * 1024); exit}"`
-                   # compute MB/sec from nregions*slowest
-                   check=`awk < $tmpf \
+                   # compute global min/max stats
+                   minmax=`awk < $tmpf \
                        '/time to transfer data/ {mb=$8/1.048576; \
-                                                 if (n == 0 || mb < min) min = mb; n++}\
-                       END {printf "%5d x %6.2f = %7.2f MB/s", n, min, min * n}'`
-                   print_summary -n "$bw $check "
+                                                 if (n == 0 || mb < min) min = mb; \
+                                                 if (n == 0 || mb > max) max = mb; \
+                                                 n++} \
+                       END {printf "[ %7.2f, %7.2f] ",min,max;}'`
+                   print_summary -n "$bw $minmax "
                fi
                rm $tmpf
            done