t/one-core-peak: Reporting BLK_CGROUP
[fio.git] / t / one-core-peak.sh
index 8d1e95f0c92700271f4b28cc4629a876f77e5814..54b40668075de64f7e7a1dc0f28d6269376d7038 100755 (executable)
@@ -4,7 +4,7 @@ args=$*
 first_cores=""
 taskset_cores=""
 first_cores_count=0
-nb_threads=4 #default from the benchmark
+nb_threads=1
 drives=""
 
 # Default options
@@ -39,11 +39,22 @@ check_binary() {
   done
 }
 
-
 detect_first_core() {
+  cpu_to_search="0"
+  if [ "${#drives[@]}" -eq 1 ]; then
+    device_name=$(block_dev_name ${drives[0]})
+    device_dir="/sys/block/${device_name}/device/"
+    pci_addr=$(cat ${device_dir}/address)
+    pci_dir="/sys/bus/pci/devices/${pci_addr}/"
+    cpu_to_search=$(cat ${pci_dir}/local_cpulist | cut -d"," -f 1 | cut -d"-" -f 1)
+  else
+    hint 'Passed multiple devices. Running on the first core.'
+  fi
+  core_to_run=$(lscpu  --all -pSOCKET,CORE,CPU | grep ",$cpu_to_search\$" | cut -d"," -f1-2)
+
   # Detect which logical cpus belongs to the first physical core
   # If Hyperthreading is enabled, two cores are returned
-  cpus=$(lscpu  --all -pSOCKET,CORE,CPU |grep "0,0")
+  cpus=$(lscpu  --all -pSOCKET,CORE,CPU | grep "$core_to_run")
   for cpu in ${cpus}; do
     IFS=','
     # shellcheck disable=SC2206
@@ -174,18 +185,28 @@ 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)
   pci_dir="/sys/bus/pci/devices/${pci_addr}/"
   link_speed=$(cat ${pci_dir}/current_link_speed)
   irq=$(cat ${pci_dir}/irq)
-  numa=$(cat ${pci_dir}/numa_node)
+  numa=$([ -f ${pci_dir}/numa_node ] && cat ${pci_dir}/numa_node || echo "off")
   cpus=$(cat ${pci_dir}/local_cpulist)
   model=$(cat ${device_dir}/model | xargs) #xargs for trimming spaces
   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} "
+  which nvme &> /dev/null
+  if [ $? -eq 0 ]; then
+    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}"
+  fi
 }
 
 show_device() {
@@ -217,7 +238,7 @@ show_system() {
   info "system" "CPU: ${CPU_MODEL}"
   info "system" "MEMORY: ${MEMORY_SPEED}"
   info "system" "KERNEL: ${KERNEL}"
-  for config_item in BLK_CGROUP_IOCOST HZ; do
+  for config_item in BLK_CGROUP HZ; do
     info "system" "KERNEL: $(show_kernel_config_item ${config_item})"
   done
   tsc=$(journalctl -k | grep 'tsc: Refined TSC clocksource calibration:' | awk '{print $11}')