summaryrefslogtreecommitdiff
path: root/hosts/iroha/libvirt/hooks/cpuset_prepare_common.sh
blob: e4bb35f9fb8eaca93234f4192dd1c74a21e032d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env bash

source "/etc/libvirt/hooks/cpuset.conf"

if test -f $CPUSET_REFCOUNT;
then
  ref=$(tail -1 $CPUSET_REFCOUNT)
  printf "%06d" $(expr $ref + 1) > $CPUSET_REFCOUNT
  exit 0
else
  printf "%06d" 1 > $CPUSET_REFCOUNT
fi

/bin/echo ${TOTAL_CORES} > ${CPUSET}/cpuset.cpus
/bin/echo ${MEMNODES} > ${CPUSET}/cpuset.mems

if test -d ${CPUSET}/machine;
then
  :
else
  mkdir -p ${CPUSET}/machine
fi

/bin/echo ${TOTAL_CORES} > ${CPUSET}/machine/cpuset.cpus
/bin/echo ${MEMNODES} > ${CPUSET}/machine/cpuset.mems

if test -d ${CPUSET}/${SETNAME};
then
  :
else
  mkdir ${CPUSET}/${SETNAME}
fi

/bin/echo ${HOST_CORES} > ${CPUSET}/${SETNAME}/cpuset.cpus
/bin/echo ${MEMNODES} > ${CPUSET}/${SETNAME}/cpuset.mems

for i in blkio cpu cpuacct cpuset devices freezer memory net_cls perf_event;
do
  mkdir -p ${CGROUP}/$i/machine/${PARTNAME0}.partition
done

/bin/echo ${VIRT_CORES0} > ${CPUSET}/machine/${PARTNAME0}.partition/cpuset.cpus
/bin/echo ${MEMNODES} > ${CPUSET}/machine/${PARTNAME0}.partition/cpuset.mems

for i in `cat ${CPUSET}/tasks`;
do
  /bin/echo ${i} > ${CPUSET}/${SETNAME}/tasks || :
done

# (pgrep kthreadd) = 2
taskset -pc ${HOST_CORES} 2