Merge branch 'onecore' of https://github.com/ByteHamster/fio
[fio.git] / t / one-core-peak.sh
index c391dcd5eb60ada2bb7a0ebfe9d3b97cb7c01e8b..57c454510e654850e4696df05b5a30dae181d18c 100755 (executable)
@@ -86,7 +86,7 @@ usage() {
 }
 
 check_args() {
-  local OPTIND option
+  local OPTIND option
   while getopts "hl" option; do
     case "${option}" in
         h) # Show help
@@ -102,7 +102,7 @@ check_args() {
   done
   shift $((OPTIND-1))
   [ $# -eq 0 ] && fatal "Missing drive(s) as argument"
-  drives="$@"
+  drives="$*"
 }
 
 check_drive_exists() {
@@ -185,6 +185,7 @@ check_idle_governor() {
 }
 
 show_nvme() {
+  device="$1"
   device_name=$(block_dev_name $1)
   device_dir="/sys/block/${device_name}/device/"
   pci_addr=$(cat ${device_dir}/address)
@@ -197,6 +198,12 @@ show_nvme() {
   fw=$(cat ${device_dir}/firmware_rev | xargs) #xargs for trimming spaces
   serial=$(cat ${device_dir}/serial | xargs) #xargs for trimming spaces
   info ${device_name} "MODEL=${model} FW=${fw} serial=${serial} PCI=${pci_addr}@${link_speed} IRQ=${irq} NUMA=${numa} CPUS=${cpus} "
+  NCQA=$(nvme get-feature -H -f 0x7 ${device} |grep NCQA |cut -d ':' -f 2 | xargs)
+  NSQA=$(nvme get-feature -H -f 0x7 ${device} |grep NSQA |cut -d ':' -f 2 | xargs)
+  power_state=$(nvme get-feature -H -f 0x2 ${device} | grep PS |cut -d ":" -f 2 | xargs)
+  apste=$(nvme get-feature -H -f 0xc ${device} | grep APSTE |cut -d ":" -f 2 | xargs)
+  temp=$(nvme smart-log ${device} |grep 'temperature' |cut -d ':' -f 2 |xargs)
+  info ${device_name} "Temp:${temp}, Autonomous Power State Transition:${apste}, PowerState:${power_state}, Completion Queues:${NCQA}, Submission Queues:${NSQA}"
 }
 
 show_device() {
@@ -204,6 +211,23 @@ show_device() {
   is_nvme $1 && show_nvme $1
 }
 
+show_kernel_config_item() {
+  config_item="CONFIG_$1"
+  config_file="/boot/config-$(uname -r)"
+  if [ ! -f "${config_file}" ]; then
+    config_file='/proc/config.gz'
+    if [ ! -f "${config_file}" ]; then
+      return
+    fi
+  fi
+  status=$(zgrep ${config_item}= ${config_file})
+  if [ -z "${status}" ]; then
+    echo "${config_item}=N"
+  else
+    echo "${config_item}=$(echo ${status} | cut -d '=' -f 2)"
+  fi
+}
+
 show_system() {
   CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo | awk '{print substr($0, index($0,$4))}')
   MEMORY_SPEED=$(dmidecode -t 17 -q | grep -m 1 "Configured Memory Speed: [0-9]" | awk '{print substr($0, index($0,$4))}')
@@ -211,7 +235,10 @@ show_system() {
   info "system" "CPU: ${CPU_MODEL}"
   info "system" "MEMORY: ${MEMORY_SPEED}"
   info "system" "KERNEL: ${KERNEL}"
-  tsc=$(journalctl -k | grep 'tsc: Refined TSC clocksource calibration:' | awk '{print $11'})
+  for config_item in BLK_CGROUP_IOCOST HZ; do
+    info "system" "KERNEL: $(show_kernel_config_item ${config_item})"
+  done
+  tsc=$(journalctl -k | grep 'tsc: Refined TSC clocksource calibration:' | awk '{print $11}')
   if [ -n "${tsc}" ]; then
     info "system" "TSC: ${tsc} Mhz"
     tsc=$(echo ${tsc} | tr -d '.')
@@ -222,7 +249,7 @@ show_system() {
 ### MAIN
 check_args ${args}
 check_root
-check_binary t/io_uring lscpu grep taskset cpupower awk tr xargs dmidecode
+check_binary t/io_uring lscpu grep taskset cpupower awk tr xargs dmidecode nvme
 detect_first_core
 
 info "##################################################"