1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-19 10:21:55 +01:00

cgroups: fix support to filter tasks to move into a specified CGroup

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
Patrick Bellasi
2016-08-26 18:13:47 +01:00
parent 3cab786d03
commit 21d18f8b78
2 changed files with 41 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ FIND=${FIND:-$BUSYBOX find}
GREP=${GREP:-$BUSYBOX grep}
SED=${SED:-$BUSYBOX sed}
CAT=${CAT:-$BUSYBOX cat}
AWK=${AWK:-$BUSYBOX awk}
################################################################################
# CPUFrequency Utility Functions
@@ -134,20 +135,21 @@ cgroups_run_into() {
cgroups_tasks_move() {
SRC_GRP=${1}
DST_GRP=${2}
GREP_EXCLUSE=${3:-''}
shift 2
FILTERS=$*
$CAT $SRC_GRP/tasks | while read TID; do
echo $TID > $DST_GRP/cgroup.procs
done
[ "$GREP_EXCLUSE" = "" ] && exit 0
[ "x$FILTERS" = "x" ] && exit 0
PIDS=`ps | $GREP "$GREP_EXCLUSE" | awk '{print $2}'`
PIDS=`ps | $GREP $FILTERS | $AWK '{print $2}'`
PIDS=`echo $PIDS`
echo "PIDs to save: [$PIDS]"
for TID in $PIDS; do
CMDLINE=`$CAT /proc/$TID/cmdline`
echo "$TID : $CMDLINE"
COMM =`$CAT /proc/$TID/comm`
echo "$TID : $COMM"
echo $TID > $SRC_GRP/cgroup.procs
done
}