Reputation: 19
I'm testing linux cpu hotpluging on normal 4-core ARM based on Android 8.1 kernel 4.4 sys. Problem seems that after onlining a CPU again taskset and kernel refuses to move and/or schedule any tasks on the core. E.g. doing:
echo 0 > /sys/devices/system/cpu/cpu3/online
echo 1 > /sys/devices/system/cpu/cpu3/online
taskset -c 3 bash
Fails... I don't know why taskset refuses to migrate any threads to the hotpluged cores. I have intend to use this to improve the kernel NO_HZ tickless operation by forcing Local timer interupts (LOC) off from cores 1-3. The kernel NO_HZ documentation suggests this possibility.
I also run it on upstream kernerl 4.18.4 on Linux qemu. it is also exist. please give me some help,thanks~
Upvotes: 1
Views: 253
Reputation: 47
Use this for hotplug and add CPU and RAM without rebooting.
#!/bin/bash
# Bring CPUs online
for CPU_DIR in /sys/devices/system/cpu/cpu[0-9]*
do
CPU=${CPU_DIR##*/}
echo "Found cpu: '${CPU_DIR}' ..."
CPU_STATE_FILE="${CPU_DIR}/online"
if [ -f "${CPU_STATE_FILE}" ]; then
if grep -qx 1 "${CPU_STATE_FILE}"; then
echo -e "\t${CPU} already online"
else
echo -e "\t${CPU} is new cpu, onlining cpu ..."
echo 1 > "${CPU_STATE_FILE}"
fi
else
echo -e "\t${CPU} already configured prior to hot-add"
fi
done
# Bring all new Memory online
for RAM in $(grep line /sys/devices/system/memory/*/state)
do
echo "Found ram: ${RAM} ..."
if [[ "${RAM}" == *":offline" ]]; then
echo "Bringing online"
echo $RAM | sed "s/:offline$//"|sed "s/^/echo online > /"|source /dev/stdin
else
echo "Already online"
fi
done
Upvotes: 0