#!/bin/sh # get core numbers lcores=$(grep "^processor" -c /proc/cpuinfo) htn=$(lscpu | grep "^Thread(s) per core" | awk '{print $NF}') pcores=$(awk 'BEGIN{ x="'$lcores'" / "'$htn'"; printf("%.0f\n", (x == int(x))?x:int(x)+1) }') csets=$((0x$(cat /proc/self/status | grep "^Cpus_allowed:" | awk '{print $NF}'))) cfull=$(((1< 0 || $i > $lcores ]]; do if [ -r /sys/devices/system/cpu/cpu$i/topology/thread_siblings_list ]; then x=$(awk -F, '{print $1}' /sys/devices/system/cpu/cpu$i/topology/thread_siblings_list) y=$(awk -F, '{print $2}' /sys/devices/system/cpu/cpu$i/topology/thread_siblings_list) st=$((y-x)) fi ((i++)) done # calculate logical & physical core number by the toplogy lnums=0; pnums=0; mask=0; n=csets while (( n != 0 )) do m=$((n & (~n + 1))) if (( (m & mask) == 0 )); then mask=$((mask|m|m<