Skip to content

Instantly share code, notes, and snippets.

@iAklis
Last active December 15, 2019 03:11
Show Gist options
  • Select an option

  • Save iAklis/ea544a147f2d3a75ebce3ddf05b03b3e to your computer and use it in GitHub Desktop.

Select an option

Save iAklis/ea544a147f2d3a75ebce3ddf05b03b3e to your computer and use it in GitHub Desktop.

Revisions

  1. iAklis revised this gist Dec 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dying_cgroup.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ prefix=/sys/fs/cgroup/memory/aklis
    for i in {1..1000};
    do
    mkdir $prefix-$i;
    bash -c "echo \$\$ > $prefix-$i/tasks; rm -rfv /tmp/$i; mkdir /tmp/$i; echo 'fubao'>/tmp/$i/pandada8;"
    bash -c "echo \$\$ > $prefix-$i/tasks; mkdir /tmp/$i; echo 'fubao'>/tmp/$i/pandada8;"
    done

    created_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}')
  2. iAklis created this gist Dec 14, 2019.
    35 changes: 35 additions & 0 deletions dying_cgroup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/bin/bash

    old_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}')

    free -m
    slabtop -o | head
    echo "now the number of memory cgroup is $old_memcg_num"
    echo "begin to create cgroups"

    prefix=/sys/fs/cgroup/memory/aklis

    for i in {1..1000};
    do
    mkdir $prefix-$i;
    bash -c "echo \$\$ > $prefix-$i/tasks; rm -rfv /tmp/$i; mkdir /tmp/$i; echo 'fubao'>/tmp/$i/pandada8;"
    done

    created_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}')
    free -m
    slabtop -o | head

    echo "now the number of memory cgroup is $created_memcg_num"
    echo "begin to del cgroups that created by Poc, pddka!"

    for i in {1..1000};
    do
    rmdir $prefix-$i;
    done

    free -m
    slabtop -o | head
    deleted_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}')
    echo "now the number of memory cgroup is $deleted_memcg_num"

    echo "P.S. remember to clear the tmp file (/tmp)"