File: cpu_offline

package info (click to toggle)
clonezilla 5.9.9-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,516 kB
  • sloc: sh: 40,222; perl: 193; python: 59; makefile: 26
file content (23 lines) | stat: -rwxr-xr-x 775 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# A mechanism to mitigate block devices naming in random order.
# i.e., make only 1 CPU online when udev art started.
if [ -z "$(grep -Ew ocs_1_cpu_udev /proc/cmdline)" ]; then
  # Skip if ocs_1_cpu_udev does not exist.
  exit 6
fi
echo "Disabling SMP-like behavior before udev is started..."
for cpu in `ls -dv /sys/devices/system/cpu/cpu[1-9]*`; do
    if [ -e "$cpu/online" ]; then
        echo -n "$(basename $cpu), "
	(echo 0 > "$cpu/online" 2>/dev/null || echo "Failed to disable $cpu")&
    fi
done
echo
# Delay to avoid contention
echo -n "Waiting for single CPU status... "
exit_cond="false"
while [ "$exit_cond" = "false" ]; do
  cpu_no="$(LC_ALL=C grep -iE "^processor" /proc/cpuinfo | wc -l)"
  [ "$cpu_no" -eq 1 ] && exit_cond="true"
done
echo "done!"