Commit 1676c86d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm.sh: add ability to use a freezer cgroup

It allows to freeze processes faster
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8ea02038
......@@ -10,6 +10,7 @@ all:
$(MAKE) zdtm-pre-dump
$(MAKE) zdtm-snapshot
$(MAKE) zdtm-iter
$(MAKE) zdtm-freezer
.PHONY: all
......@@ -38,6 +39,10 @@ zdtm-snapshot: zdtm-tst-list
zdtm-iter: zdtm-tst-list
ZDTM_ARGS="-i 3 -C" $(MAKE) -f Makefile.zdtm ns/static/pipe00
zdtm-freezer:
ZDTM_ARGS="--freeze-cgroup /sys/fs/cgroup/freezer/test -i 3" $(MAKE) -f Makefile.zdtm transition/thread-bomb
ZDTM_ARGS="--freeze-cgroup /sys/fs/cgroup/freezer/test -d --frozen" $(MAKE) -f Makefile.zdtm transition/thread-bomb
.PHONY: zdtm
fault-injection: .FORCE
......
......@@ -373,6 +373,7 @@ BATCH_TEST=0
SPECIFIED_NAME_USED=0
START_FROM="."
RESTORE_SIBLING=""
FREEZE_CGROUP=""
zdtm_sep()
{ (
......@@ -565,6 +566,12 @@ start_test()
fi
(
if [ -n "$FREEZE_CGROUP" ]; then
mkdir -p $FREEZE_CGROUP
echo 0 > $FREEZE_CGROUP/tasks || exit 1
else
export ZDTM_THREAD_BOMB=100
fi
# Here is no way to set FD_CLOEXEC on 3
exec 3>&-
make -C $tdir $tname.pid
......@@ -575,6 +582,10 @@ start_test()
return 1
fi
if [ -n "$FREEZE_CGROUP" ] && [ -n "$FREEZER_STATE" ]; then
echo $FREEZER_STATE > $FREEZE_CGROUP/freezer.state
fi
[ -z "$PIDNS" ] || cd -
PID=`cat "$TPID"` || return 1
......@@ -755,6 +766,10 @@ EOF
fi
[ -n "$snappdir" ] && cpt_args="$cpt_args --prev-images-dir=$snappdir"
fi
if [ -n "$FREEZE_CGROUP" ]; then
cpt_args="$cpt_args --freeze-cgroup $FREEZE_CGROUP --manage-cgroups"
rst_args="$rst_args --manage-cgroups"
fi
[ -n "$dump_only" ] && cpt_args="$cpt_args $POSTDUMP"
......@@ -806,6 +821,15 @@ EOF
diff_maps $ddump/dump.maps $ddump/dump.maps.after || return 1
}
if [ -n "$FREEZE_CGROUP" ] && [ -n "$FREEZER_STATE" ]; then
while :; do
echo freezer.state=`cat $FREEZE_CGROUP/freezer.state`
cat $FREEZE_CGROUP/freezer.state | grep -q $FREEZER_STATE && break;
sleep 0.1
done
fi
echo THAWED > $FREEZE_CGROUP/freezer.state
rm -f ./$tdir/link_remap.*
else
# Wait while tasks are dying, otherwise PIDs would be busy.
......@@ -1056,6 +1080,15 @@ while :; do
AUTO_DEDUP=1
shift
;;
--freeze-cgroup)
shift
FREEZE_CGROUP=$1
shift
;;
--frozen)
FREEZER_STATE=FROZEN
shift
;;
-g)
COMPILE_ONLY=1
shift
......
......@@ -4,11 +4,13 @@
#include <syscall.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include "zdtmtst.h"
static int p[2];
static char buf[100]; /* the size is equal to the limit of threads */
static char *buf;
static int buf_size = 1024;
#define exit_group(code) \
syscall(__NR_exit_group, code)
......@@ -40,11 +42,21 @@ err:
int main(int argc, char **argv)
{
char *val;
val = getenv("ZDTM_THREAD_BOMB");
if (val)
buf_size = atoi(val);
test_msg("%d\n", buf_size);
buf = malloc(buf_size);
if (!buf)
return 1;
if (pipe(p))
return 1;
fcntl(p[0], F_SETFL, O_NONBLOCK);
if (write(p[1], buf, sizeof(buf)) != sizeof(buf))
if (write(p[1], buf, buf_size) != buf_size)
return 1;
test_init(argc, argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment