blob: b1d9cbe8036aed3c29c111ea936a5d11a21402af (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/system/bin/sh
KBG_MAXINFLIGHT=$1
BG_MAXINFLIGHT=$2
USERDATADIR="/data"
BLKROOT="/dev/blkio"
TOPAPP="$BLKROOT/top-app"
FGDIR="$BLKROOT/foreground"
BGDIR="$BLKROOT/background"
KBGDIR="$BLKROOT/key-background"
SBGDIR="$BLKROOT/system-background"
USERDEVID=`mountpoint -d $USERDATADIR`
if [ -z "$USERDEVID" ]; then
echo "Get userdata devid failed"
exit 1
fi
SYSUSERDEV="/sys/dev/block/$USERDEVID/partition"
if [ -f $SYSUSERDEV ]; then
SYSDEV=`readlink -f /sys/dev/block/$USERDEVID`
SYSDEV=`dirname $SYSDEV`
if [ -z "$SYSDEV" ]; then
echo "Get device failed"
exit 1
fi
USERDEVID=`cat $SYSDEV/dev`
if [ -z "$USERDEVID" ]; then
echo "Get device id failed"
exit 1
fi
fi
echo "$USERDEVID 3" > $BLKROOT/blkio.throttle.mode_device
if [ $? -ne 0 ]; then
echo "open iops weight control failed"
exit 1
fi
echo "$USERDEVID 32" > $BLKROOT/blkio.throttle.iops_slice_device
if [ $? -ne 0 ]; then
echo "set iops slice failed"
exit 1
fi
set_weight()
{
local CGRPNAME=$1
local CGRP=$2
local VALUE=$3
echo "$USERDEVID $VALUE" > $CGRP/blkio.throttle.weight_device
if [ $? -ne 0 ]; then
echo "set $CGRPNAME weight failed"
fi
}
set_weight "top-app" $TOPAPP 800
set_weight "fg" $FGDIR 800
set_weight "sbg" $SBGDIR 400
set_weight "kbg" $KBGDIR 400
set_weight "bg" $BGDIR 100
set_max_inflights()
{
local CGRPNAME=$1
local CGRP=$2
local VALUE=$3
echo "$VALUE" > $CGRP/blkio.throttle.max_inflights
if [ $? -ne 0 ]; then
echo "set $CGRPNAME max inflight failed"
fi
}
echo "$USERDEVID 1" > $BLKROOT/blkio.throttle.enable_max_inflights_device
set_max_inflights "kbg" $KBGDIR $KBG_MAXINFLIGHT
set_max_inflights "bg" $BGDIR $BG_MAXINFLIGHT
set_cgroup_type()
{
local CGRPNAME=$1
local CGRP=$2
local VALUE=$3
echo "$VALUE" > $CGRP/blkio.throttle.type
if [ $? -ne 0 ]; then
echo "set $CGRPNAME type failed"
fi
}
set_cgroup_type "top-app" $TOPAPP 0
set_cgroup_type "fg" $FGDIR 1
set_cgroup_type "kbg" $KBGDIR 2
set_cgroup_type "sbg" $SBGDIR 3
set_cgroup_type "bg" $BGDIR 4
|