Skip to content

Commit

Permalink
makes use of threadgroup/proces moving atomicity in cgroups
Browse files Browse the repository at this point in the history
more reliable and MUCH faster
  • Loading branch information
Zviratko committed Jul 13, 2015
1 parent d2001bd commit 0c9d1c1
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions pincpus
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#!/bin/bash

CFGFILE=/etc/prz-pincpus.conf
LOCKFILE=/var/run/prz-pincpus.pid

if [ -f $LOCKFILE ]; then
echo "- lockfile exists"
ps -p $(cat $LOCKFILE) | grep pincpus >/dev/null && exit || rm $LOCKFILE
echo "- but no running process - continuing...";
fi

echo $$ > $LOCKFILE

if [ ! -f $CFGFILE ]; then
echo "ERROR: Missing configuration file ($CFGFILE)";
Expand Down Expand Up @@ -57,8 +48,10 @@ if [ $osds -gt 0 ]; then
cpuset="`cat /proc/$pid/cpuset`";

# get group# from cpuset (9999 = no cgroup assigned)

echo $cpuset | grep '^/osd-group-' >/dev/null && group="`echo $cpuset|cut -f3-3 -d\-`" || group="9999";


count_osds[$group]=$((${count_osds[$group]}+1));

# we want to migrate any OSD with matches any of these conditions:
Expand Down Expand Up @@ -89,14 +82,16 @@ if [ $osds -gt 0 ]; then

# migrate to the least utilized group
echo " - migrating $pid to the least utilized cgroup #$lu_cgroup_id (qty $lu_count)";
echo $pid > /cgroup/cpuset/osd-group-$lu_cgroup_id/tasks
for pid_task in `ls -1 /proc/$pid/task`; do
echo $pid_task > /cgroup/cpuset/osd-group-$lu_cgroup_id/tasks
done;
echo $pid > /cgroup/cpuset/osd-group-$lu_cgroup_id/cgroup.procs

# zviratko - unneeded
# for pid_task in `ls -1 /proc/$pid/task`; do
# echo $pid_task > /cgroup/cpuset/osd-group-$lu_cgroup_id/tasks
# done;
# need to do this twice (some task may have created another thread during the execution)
for pid_task in `ls -1 /proc/$pid/task`; do
echo $pid_task > /cgroup/cpuset/osd-group-$lu_cgroup_id/tasks
done;
# for pid_task in `ls -1 /proc/$pid/task`; do
# echo $pid_task > /cgroup/cpuset/osd-group-$lu_cgroup_id/tasks
# done;

# increase group utilization count
count_osds[$lu_cgroup_id]=$((${count_osds[$lu_cgroup_id]}+1));
Expand Down Expand Up @@ -127,6 +122,3 @@ cat /cgroup/cpuset/libvirt/cpuset.cpus | grep "^${cgroup_libvirt_cpus}$" >/dev/n
echo '- done';

)

rm $LOCKFILE

0 comments on commit 0c9d1c1

Please sign in to comment.