我在包裹自己cgroups
和tc
.
我正在尝试为特定进程添加延迟。下面的代码不起作用。但我不知道什么是错的(甚至什么是对的)。
# Set up net_cls to make
modprobe cls_cgroup
mount -t cgroup -o net_cls none /sys/fs/cgroup/net_cls
# Create a new CGroup called 'high-latency'
mkdir /sys/fs/cgroup/high-latency
# All packets originating from this CG have their packers
# marked as class 1:11 / 0x1_0011
echo 0x100011 > /sys/fs/cgroup/high-latency/net_cls.classid
# Delete old rules, just in case
tc qdisc del dev eth0 root
# New root
tc qdisc add dev eth0 handle 1: root htb
# Class for filtered packets 1:11 == 0x10011
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100Mbps
# Apply delay to class 1:11
tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 1000ms
# Don't understand this line at all! Why does tc need to know
# about 'cgroup', when net_cls is already putting them in class 1:11
tc filter add dev eth0 parent 1:11 protocol ip prio 10 handle 1: cgroup
# Add my process to the cgroup
echo 1234 > /sys/fs/cgroup/high-latency/tasks
另一个有趣的事情是,在运行它之后,cat 会/sys/fs/cgroup/high-latency/tasks
打印出一大堆进程(全部?),包括 pid 1。
知道我做错了什么,更重要的是 - 在尝试使用 tc 和 cgroups 时我可以使用哪些调试工具?