Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!

Ogłoszenie

Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

#1  2013-07-02 16:42:34

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

[SOLVED] Cgroup

Próbowałem skonfigurować cgroup, ale coś to nie działa jak powinno.

Zainstalowałem pierw:

Kod:

dpkg -l | grep cgroup
ii  cgroup-bin                                    0.38-1                             i386         Tools to control and monitor control groups
ii  libcgroup1                                    0.38-1                             i386         Library to control and monitor control groups

Dodałem do /etc/fstab

Kod:

cgroup  /sys/fs/cgroup  cgroup  defaults  0   0

i dałem mount -a . W katalogu /sys/fs/ się pojawił cgroup i ma zawartość:

Kod:

root:/sys/fs/cgroup# ls -al
total 0
drwxr-xr-x 6 root root 0 Jul  2 15:47 ./
drwxr-xr-x 7 root root 0 Jul  2 15:47 ../
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_merged
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_merged_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_queued
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_queued_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_service_bytes
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_service_bytes_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_service_time
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_service_time_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_serviced
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_serviced_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_wait_time
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.io_wait_time_recursive
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.leaf_weight
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.leaf_weight_device
--w------- 1 root root 0 Jul  2 15:47 blkio.reset_stats
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.sectors
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.sectors_recursive
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.io_service_bytes
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.io_serviced
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.read_bps_device
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.read_iops_device
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.write_bps_device
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.throttle.write_iops_device
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.time
-r--r--r-- 1 root root 0 Jul  2 15:47 blkio.time_recursive
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.weight
-rw-r--r-- 1 root root 0 Jul  2 15:47 blkio.weight_device
-rw-r--r-- 1 root root 0 Jul  2 15:47 cgroup.clone_children
--w--w--w- 1 root root 0 Jul  2 15:47 cgroup.event_control
-rw-r--r-- 1 root root 0 Jul  2 15:47 cgroup.procs
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpu.shares
-r--r--r-- 1 root root 0 Jul  2 15:47 cpuacct.stat
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuacct.usage
-r--r--r-- 1 root root 0 Jul  2 15:47 cpuacct.usage_percpu
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.cpu_exclusive
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.cpus
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.mem_exclusive
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.mem_hardwall
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.memory_migrate
-r--r--r-- 1 root root 0 Jul  2 15:47 cpuset.memory_pressure
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.memory_pressure_enabled
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.memory_spread_page
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.memory_spread_slab
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.mems
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.sched_load_balance
-rw-r--r-- 1 root root 0 Jul  2 15:47 cpuset.sched_relax_domain_level
--w------- 1 root root 0 Jul  2 15:47 devices.allow
--w------- 1 root root 0 Jul  2 15:47 devices.deny
-r--r--r-- 1 root root 0 Jul  2 15:47 devices.list
-rw-r--r-- 1 root root 0 Jul  2 15:47 net_cls.classid
-rw-r--r-- 1 root root 0 Jul  2 15:47 notify_on_release
-rw-r--r-- 1 root root 0 Jul  2 15:47 release_agent
-rw-r--r-- 1 root root 0 Jul  2 15:47 tasks

Próbowałem ograniczyć wykorzystanie RAM operze. Na archwiki jest wpis https://wiki.archlinux.org/index.php/Cgroups , w którym czytamy:

One of the powers of cgroups is that you can create "ad-hoc" groups on the fly. In fact, you can even grant the privileges to create custom groups to regular users. Run this as root (replace $USER with your user name and groupname with the name you want to give to the cgroup):
sudo cgcreate -a $USER -g memory,cpu:groupname

To mu zmieniłem $USER na morfik i groupname na morfiki . :] Ale to polecenie zwróciło błąd:

Kod:

cgcreate: can't create cgroup morfiki: Cgroup one of the needed subsystems is not mounted

Szukając info, trafiłem na wiki debiana i tam było z kolei o lxc. Dopatrzyłem się tego polecenia:

Kod:

lxc-checkconfig

Miało pokazać konfiguracje kernela, jako że używałem jajka aptosida to zainstalowałem ten lxc, tylko on byłw konflikcie z cgroup-bin i wywalil mi go. xD Ale sprawdziłem config i się okazało, że:

Kod:

Cgroup memory controller: /usr/bin/lxc-checkconfig: 93: [: #: unexpected operator
missing

Dociągnąłem debianowskiego kernela — 3.9-1-686-pae - ten komunikat został poprawiony. To zainstalowałem znowu cgroup-bin i próbowałem znowu wydać linijkę:

Kod:

cgcreate -a morfik -g memory,cpu:morfiki

ale to nic nie pomogło. No to zacząłem wpisywać linijki od opery z tego linku http://jacekalex.sh.dug.net.pl/cgstart xD

Kod:

root:/sys/fs/cgroup# CGDIR='/sys/fs/cgroup/'
root:/sys/fs/cgroup# mkdir -p $CGDIR/cpu/users/opera
root:/sys/fs/cgroup# echo '1'> $CGDIR/cpu/users/opera/cgroup.clone_children
root:/sys/fs/cgroup# echo '300' > $CGDIR/cpu/users/opera/cpu.shares
root:/sys/fs/cgroup# mkdir -p $CGDIR/cpuacct/users/opera
root:/sys/fs/cgroup# mkdir -p $CGDIR/cpuset/users/opera
root:/sys/fs/cgroup# mkdir -p $CGDIR/memory/users/opera
root:/sys/fs/cgroup# echo '1'> $CGDIR/memory/users/opera/cgroup.clone_children
root:/sys/fs/cgroup# echo '512m' >   $CGDIR/memory/users/opera/memory.limit_in_bytes
-su: /sys/fs/cgroup//memory/users/opera/memory.limit_in_bytes: Permission denied

Tam nie ma czegoś takiego jak memory.limit_in_bytes . Więc co robię źle? xD

Ostatnio edytowany przez morfik (2013-07-06 13:08:03)

Offline

 

#2  2013-07-02 18:05:23

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Kod:

mount | grep memory
memory on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)

Kod:

find /sys/fs/cgroup/memory -iname memory.limit*
/sys/fs/cgroup/memory/voip/skype/memory.limit_in_bytes
/sys/fs/cgroup/memory/voip/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/rtmpdump/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/curl/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/axel/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/wget/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/totem/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/akregator/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/firefox/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/liferea/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/kaffeine/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/mplayer/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/thunderbird/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/vlc/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/pidgin/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/opera/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/chrome/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/tvtime/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/nautilus/memory.limit_in_bytes
/sys/fs/cgroup/memory/users/memory.limit_in_bytes
/sys/fs/cgroup/memory/kvm/debkvm/memory.limit_in_bytes
/sys/fs/cgroup/memory/kvm/fbsd/memory.limit_in_bytes
/sys/fs/cgroup/memory/kvm/memory.limit_in_bytes
/sys/fs/cgroup/memory/system/emerge/memory.limit_in_bytes
/sys/fs/cgroup/memory/system/memory.limit_in_bytes
/sys/fs/cgroup/memory/memory.limit_in_bytes

SOA#1

Albo grupa memory nie jest zamontowana, albo cośtam masz spartolone.
Może nie wszystkie moduły załadowane?

U mnie cgconfig , cgcreate i inne polecenia nie bardzo działały, dlatego z całego libccgroup używam tylko demona cgred,
i konfiguracji w cgrules.conf.
Resztę wywaliłem do skrypta, - bash działa, a w takim skrypcie nie da się czegoś spieprzyć.
Wszystkie zamontowane grupy?

Kod:

 mount | grep cgroup
cgroup_root on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755)
cpuset on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
debug on /sys/fs/cgroup/debug type cgroup (rw,nosuid,nodev,noexec,relatime,debug)
cpu on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)
cpuacct on /sys/fs/cgroup/cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct)
memory on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
devices on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
freezer on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
net_cls on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
blkio on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
perf_event on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
net_prio on /sys/fs/cgroup/net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio)
hugetlb on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)

I nie ustawiałem cgroup w fstab (nie było takiej potrzeby), mam moduły zaznaczone na sztywno w kernelu, i po prostu dzięki temu zawsze po starcie jest kompletny /sys/fs/cgroup.

Moduły?

Kod:

zgrep -i cgroup /proc/config.gz 
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NET_CLS_CGROUP=y
CONFIG_NETPRIO_CGROUP=y

Edyta:
U mnie w Debku Jessie,  Aptosidowe jajo ma  wszystko, co trzeba:

Kod:

grep -i cgroup /Debian/boot/config-3.9-7.slh.1-aptosid-amd64
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
# CONFIG_CGROUP_HUGETLB is not set
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NET_CLS_CGROUP=y
CONFIG_NETPRIO_CGROUP=m

Zobacz lepiej ręcznie, co siedzi w

Kod:

/sys/fs/cgroup/*

zamiast kombinować z fstabem, lxc-*, cgcreate  i podobnymi ustrojstwami.

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-02 18:16:01)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#3  2013-07-02 21:38:58

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Mam taki sam konfig na aptosidzie.

Kod:

grep -i cgroup /boot/config-3.9-7.slh.3-aptosid-686 
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
# CONFIG_CGROUP_HUGETLB is not set
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NET_CLS_CGROUP=y
CONFIG_NETPRIO_CGROUP=m

Zakomentowałem na obecną chwilę wpis w fstabie i po reboocie w /sys/fs/cgroup/ nic nie ma:

Kod:

root:/sys/fs# ls -al
total 0
drwxr-xr-x  7 root root 0 Jul  2 21:21 ./
dr-xr-xr-x 12 root root 0 Jul  2 21:21 ../
drwxr-xr-x  2 root root 0 Jul  2 21:22 btrfs/
drwxr-xr-x  2 root root 0 Jul  2 21:21 cgroup/
drwxr-xr-x 11 root root 0 Jul  2 21:22 ext4/
drwxr-xr-x  3 root root 0 Jul  2 21:21 fuse/
drwxr-xr-x  2 root root 0 Jul  2 21:22 pstore/
root:/sys/fs# cd cgroup/
root:/sys/fs/cgroup# ls -al
total 0
drwxr-xr-x 2 root root 0 Jul  2 21:21 ./
drwxr-xr-x 7 root root 0 Jul  2 21:21 ../

Tego cgred też nie mam. I nie mam pojęcia w którym to pakiecie siedzi

A jak próbuje stworzyć grupę, do dostaję:

Kod:

cgcreate -a morfik -g memory,cpu:morfiki
cgcreate: libcgroup initialization failed: Cgroup is not mounted

Hmmm? xD

Offline

 

#4  2013-07-03 13:46:08

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Próbuje robić według tego: http://www.oracle.com/technetwork/articles/servers- … -1506602.html

ale brakuje memory:

Kod:

root:~# lssubsys -am 
cpuset
cpu
cpuacct
devices
freezer
net_cls
blkio
perf_event

To powyższe było na jaju aptosida, na jaju debiana już jest memory tam wylistowane, także ten lxc-checkconfig dobrze pokazał.

Ostatnio edytowany przez morfik (2013-07-03 13:49:42)

Offline

 

#5  2013-07-03 13:53:03

  enether - wiecznie niewyspany

enether
wiecznie niewyspany
Zarejestrowany: 2012-05-01

Re: [SOLVED] Cgroup

W /etc/default/grub dopisz sobie do listy argumentów dla jądra

Kod:

cgroup_enable=memory

potem update-grub i reboot.

Pytanie do osoby najbardziej obeznanej z Cgroups, tzn. Jacekalexa: Ostatnio też się zainteresowałem i chciałem potraktować jedną ze swoich KVMowych wirtualek jako środowisko laboratoryjne. Debian Wheezy. Pytanie: nigdzie nie mogę znaleźć usługi daemona cgred który z tego co czytałem jako config wykorzystuje cgconfig.conf

Jakieś sugestie? ;)


[EDIT]
OK, wyczaiłem w jednym ze skryptów startowych CentOS'a że cgred to nic innego jak odpowiednie wywołanie cgrulesngd

Ostatnio edytowany przez enether (2013-07-03 19:29:19)

Offline

 

#6  2013-07-03 13:54:38

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Nie mam gruba, jadę na extlinux :) Ale zobaczę czy da radę.

EDIT:
Dopisałem to do linijki kernela w extlinux ale nadal jest bez memory.

Z tego co pisali na debian wiki musiałbym rekompilować kernel i powłączać tam odpowiednie opcje. To już wolę jechać na tym debianowym kernelu, przynajmniej póki mi się tego nie uda uruchomić.

EDIT:
Próbuje robić według http://www.oracle.com/technetwork/articles/servers- … -1506602.html ale:

Kod:

root:~# mkdir -p /cgroup/cpu-n-ram
root:~# mount -t cgroup -o cpu,cpuset,memory - /cgroup/cpu-n-ram
mount: special device - does not exist

Co to jest ten special device? xD Btw, jakieś skrypty w /etc/init.d/ powinny się pojawić?

Ostatnio edytowany przez morfik (2013-07-03 15:37:35)

Offline

 

#7  2013-07-03 21:36:55

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Pokaż wynik:

Kod:

cat /proc/cgroups

i spróbuj tej gimnastyki:
http://hydra.geht.net/tino/english/faq/debian/squeeze/cgroups/

I tu chyba jedziesz po bandzie:

Kod:

root:~# mount -t cgroup -o cpu,cpuset,memory - /cgroup/cpu-n-ram

Spróbuj:

Kod:

awk 'NR>1 {print $1}' /proc/cgroups |
while read -r a
do
  b="/cgroups/$a"
  mkdir -p "$b"
  mount -tcgroup -o"$a" "cgroup:$a" "$b"
done

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-03 21:52:02)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#8  2013-07-03 21:47:22

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Ok już wiem chyba w czym problem.

Potrzebna jest rekompilacja kernela, ten z aptosida nie da rady. Druga rzecz to jak już się ma odpowiednie opcje w kernelu (testowane na tym debianowym), trzeba dodać parametr cgroup_enable=memory do linijki w bootloaderze i zamontować ręcznie cgroup -- w moim przypadku przez fstab z automatu.

Efektem jest:

Kod:

root:~# cat /proc/cgroups
#subsys_name    hierarchy    num_cgroups    enabled
cpuset    1    1    1
cpu    1    1    1
cpuacct    1    1    1
memory    1    1    1
devices    1    1    1
freezer    1    1    1
net_cls    1    1    1
blkio    1    1    1
perf_event    1    1    1
root:~# ls -a /sys/fs/cgroup/
./                                blkio.sectors                     cpuacct.usage                    memory.failcnt
../                               blkio.sectors_recursive           cpuacct.usage_percpu             memory.force_empty
blkio.io_merged                   blkio.throttle.io_service_bytes   cpuset.cpu_exclusive             memory.limit_in_bytes
blkio.io_merged_recursive         blkio.throttle.io_serviced        cpuset.cpus                      memory.max_usage_in_bytes
blkio.io_queued                   blkio.throttle.read_bps_device    cpuset.mem_exclusive             memory.move_charge_at_immigrate
blkio.io_queued_recursive         blkio.throttle.read_iops_device   cpuset.mem_hardwall              memory.oom_control
blkio.io_service_bytes            blkio.throttle.write_bps_device   cpuset.memory_migrate            memory.soft_limit_in_bytes
blkio.io_service_bytes_recursive  blkio.throttle.write_iops_device  cpuset.memory_pressure           memory.stat
blkio.io_service_time             blkio.time                        cpuset.memory_pressure_enabled   memory.swappiness
blkio.io_service_time_recursive   blkio.time_recursive              cpuset.memory_spread_page        memory.usage_in_bytes
blkio.io_serviced                 blkio.weight                      cpuset.memory_spread_slab        memory.use_hierarchy
blkio.io_serviced_recursive       blkio.weight_device               cpuset.mems                      net_cls.classid
blkio.io_wait_time                cgroup.clone_children             cpuset.sched_load_balance        notify_on_release
blkio.io_wait_time_recursive      cgroup.event_control              cpuset.sched_relax_domain_level  release_agent
blkio.leaf_weight                 cgroup.procs                      devices.allow                    tasks
blkio.leaf_weight_device          cpu.shares                        devices.deny
blkio.reset_stats                 cpuacct.stat                      devices.list 
root:~# lssubsys -am 
cpuset,cpu,cpuacct,memory,devices,freezer,net_cls,blkio,perf_event /sys/fs/cgroup

Pojawiły się wpisy od memory. To może teraz się uda. xD

Ok udało się zrobić grupę:

Kod:

root:~# cgcreate -a morfik -g memory,cpu:morfiki
root:~# ls -a /sys/fs/cgroup/morfiki/
./                                blkio.sectors                     cpuacct.usage                    freezer.self_freezing
../                               blkio.sectors_recursive           cpuacct.usage_percpu             freezer.state
blkio.io_merged                   blkio.throttle.io_service_bytes   cpuset.cpu_exclusive             memory.failcnt
blkio.io_merged_recursive         blkio.throttle.io_serviced        cpuset.cpus                      memory.force_empty
blkio.io_queued                   blkio.throttle.read_bps_device    cpuset.mem_exclusive             memory.limit_in_bytes
blkio.io_queued_recursive         blkio.throttle.read_iops_device   cpuset.mem_hardwall              memory.max_usage_in_bytes
blkio.io_service_bytes            blkio.throttle.write_bps_device   cpuset.memory_migrate            memory.move_charge_at_immigrate
blkio.io_service_bytes_recursive  blkio.throttle.write_iops_device  cpuset.memory_pressure           memory.oom_control
blkio.io_service_time             blkio.time                        cpuset.memory_spread_page        memory.soft_limit_in_bytes
blkio.io_service_time_recursive   blkio.time_recursive              cpuset.memory_spread_slab        memory.stat
blkio.io_serviced                 blkio.weight                      cpuset.mems                      memory.swappiness
blkio.io_serviced_recursive       blkio.weight_device               cpuset.sched_load_balance        memory.usage_in_bytes
blkio.io_wait_time                cgroup.clone_children             cpuset.sched_relax_domain_level  memory.use_hierarchy
blkio.io_wait_time_recursive      cgroup.event_control              devices.allow                    net_cls.classid
blkio.leaf_weight                 cgroup.procs                      devices.deny                     notify_on_release
blkio.leaf_weight_device          cpu.shares                        devices.list                     tasks
blkio.reset_stats                 cpuacct.stat                      freezer.parent_freezing

No to teraz tylko muszę doczytać jak tworzyć regułki i może w końcu ograniczę operze wykorzystanie ramu :)

Ostatnio edytowany przez morfik (2013-07-03 21:53:26)

Offline

 

#9  2013-07-03 21:58:58

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Nie wiem, co tam nagrzmocili w tych jajkach, u mnie mam na sztywno zaznaczone cgroup  w jaju, mam też w jaju devtmpfs, i jajo montuje cgroup jeszcze przed startem udeva.

Kod:

zgrep -i devtmp /proc/config.gz 
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

W dmesg wygląda to tak:

Kod:

dmesg | grep -iA3 -B3 cgroup
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.9.8-gr1 (root@localhost) (gcc version 4.6.3 (Gentoo Hardened 4.6.3 p1.5, pie-0.5.2) ) #2 SMP PREEMPT Fri Jun 28 16:51:05 CEST 2013
[    0.000000] Command line: root=/dev/sda1 rootflags=i_version rootfstype=ext4  ima_appraise=enforce evm=enforce vga=792  ro quiet   init=/sbin/e4rat-preload acpi_osi=Linux elevator=cfq  security=apparmor 
[    0.000000] e820: BIOS-provided physical RAM map:
--
[    0.000000] NR_IRQS:4352 nr_irqs:712 16
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [tty0] enabled
[    0.000000] allocated 16777216 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] hpet clockevent registered
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 2663.909 MHz processor
--
[    0.002056] Security Framework initialized
[    0.002070] AppArmor: AppArmor initialized
[    0.002086] Mount-cache hash table entries: 256
[    0.002349] Initializing cgroup subsys debug
[    0.002353] Initializing cgroup subsys cpuacct
[    0.002355] Initializing cgroup subsys memory
[    0.002366] Initializing cgroup subsys devices
[    0.002368] Initializing cgroup subsys freezer
[    0.002370] Initializing cgroup subsys net_cls
[    0.002372] Initializing cgroup subsys blkio
[    0.002374] Initializing cgroup subsys perf_event
[    0.002378] Initializing cgroup subsys net_prio
[    0.002381] Initializing cgroup subsys hugetlb
[    0.002413] CPU: Physical Processor ID: 0
[    0.002415] CPU: Processor Core ID: 0
[    0.002417] mce: CPU supports 6 MCE banks
--
[   22.352474] grsec: mount of securityfs to /sys/kernel/security by /bin/mount[mount:240] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.373021] grsec: mount of debugfs to /sys/kernel/debug by /bin/mount[mount:245] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.458200] grsec: mount of configfs to /sys/kernel/config by /bin/mount[mount:251] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.471354] grsec: mount of cgroup_root to /sys/fs/cgroup by /bin/mount[mount:258] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.616443] grsec: mount of openrc to /sys/fs/cgroup/openrc by /bin/mount[mount:262] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.619607] grsec: mount of cpuset to /sys/fs/cgroup/cpuset by /bin/mount[mount:267] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.622284] grsec: mount of debug to /sys/fs/cgroup/debug by /bin/mount[mount:269] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.624920] grsec: mount of cpu to /sys/fs/cgroup/cpu by /bin/mount[mount:271] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.627613] grsec: mount of cpuacct to /sys/fs/cgroup/cpuacct by /bin/mount[mount:273] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.630302] grsec: mount of memory to /sys/fs/cgroup/memory by /bin/mount[mount:275] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.632954] grsec: mount of devices to /sys/fs/cgroup/devices by /bin/mount[mount:277] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.635606] grsec: mount of freezer to /sys/fs/cgroup/freezer by /bin/mount[mount:279] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.638486] grsec: mount of net_cls to /sys/fs/cgroup/net_cls by /bin/mount[mount:283] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.641412] grsec: mount of blkio to /sys/fs/cgroup/blkio by /bin/mount[mount:288] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.644303] grsec: mount of perf_event to /sys/fs/cgroup/perf_event by /bin/mount[mount:290] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.648117] grsec: mount of net_prio to /sys/fs/cgroup/net_prio by /bin/mount[mount:292] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.650970] grsec: mount of hugetlb to /sys/fs/cgroup/hugetlb by /bin/mount[mount:298] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:225] uid/euid:0/0 gid/egid:0/0
[   22.663247] grsec: mount of devpts to /dev/pts by /bin/mount[mount:305] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:281] uid/euid:0/0 gid/egid:0/0
[   22.679965] grsec: mount of shm to /dev/shm by /bin/mount[mount:311] uid/euid:0/0 gid/egid:0/0, parent /lib64/rc/sh/runscript.sh[runscript.sh:281] uid/euid:0/0 gid/egid:0/0

I nie czaję, dlaczego jajo z Aptosida nie styka, podejrzewam raczej, ze to jakieś chore pomysły w systemd.

Pozdro
;-)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#10  2013-07-03 22:18:33

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

To jest aptosid

Kod:

# grep -i devtmp /boot/config-3.9-7.slh.3-aptosid-686 
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

A to jest debian

Kod:

# grep -i devtmp /boot/config-3.9-1-686-pae 
CONFIG_DEVTMPFS=y
# CONFIG_DEVTMPFS_MOUNT is not set

Jak ustawie CONFIG_DEVTMPFS_MOUNT , to się zamontuje z automatu ? Choć ani na kernelu z aptosida ani na tym z debiana się automatycznie nie montuje.

To jest przy ręcznym ustawieniu:

Kod:

# dmesg | grep -iA3 -B3 cgroup
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys cpuset
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys cpu
[Wed Jul  3 21:40:40 2013] Linux version 3.9-1-686-pae (debian-kernel@lists.debian.org) (gcc version 4.7.3 (Debian 4.7.3-4) ) #1 SMP Debian 3.9.6-1
[Wed Jul  3 21:40:40 2013] e820: BIOS-provided physical RAM map:
[Wed Jul  3 21:40:40 2013] BIOS-e820: [mem 0x0000000000000000-0x000000000009f7ff] usable
--
[Wed Jul  3 21:40:40 2013] pcpu-alloc: s34176 r0 d23168 u57344 alloc=14*4096
[Wed Jul  3 21:40:40 2013] pcpu-alloc: [0] 0 [0] 1 
[Wed Jul  3 21:40:40 2013] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260250
[Wed Jul  3 21:40:40 2013] Kernel command line: root=/dev/mapper/debian_crypt-root vga=795 cgroup_enable=memory quiet ro initrd=../initrd.img-3.9-1-686-pae BOOT_IMAGE=../vmlinuz-3.9-1-686-pae 
[Wed Jul  3 21:40:40 2013] Enabling memory control group subsystem
[Wed Jul  3 21:40:40 2013] PID hash table entries: 4096 (order: 2, 16384 bytes)
[Wed Jul  3 21:40:40 2013] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[Wed Jul  3 21:40:40 2013] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[Wed Jul  3 21:40:40 2013] __ex_table already sorted, skipping sort
[Wed Jul  3 21:40:40 2013] Initializing CPU#0
[Wed Jul  3 21:40:40 2013] allocated 2097016 bytes of page_cgroup
[Wed Jul  3 21:40:40 2013] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[Wed Jul  3 21:40:40 2013] Initializing HighMem for node 0 (000379fe:0003fff0)
[Wed Jul  3 21:40:40 2013] Memory: 1018784k/1048512k available (3078k kernel code, 29336k reserved, 1538k data, 436k init, 137160k highmem)
[Wed Jul  3 21:40:40 2013] virtual kernel memory layout:
--
[Wed Jul  3 21:40:40 2013] AppArmor: AppArmor disabled by boot time parameter
[Wed Jul  3 21:40:40 2013] Yama: becoming mindful.
[Wed Jul  3 21:40:40 2013] Mount-cache hash table entries: 512
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys cpuacct
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys memory
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys devices
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys freezer
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys net_cls
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys blkio
[Wed Jul  3 21:40:40 2013] Initializing cgroup subsys perf_event
[Wed Jul  3 21:40:40 2013] CPU: Physical Processor ID: 0
[Wed Jul  3 21:40:40 2013] CPU: Processor Core ID: 0
[Wed Jul  3 21:40:40 2013] mce: CPU supports 4 MCE banks
--
[Wed Jul  3 21:41:52 2013] EXT4-fs (dm-7): mounted filesystem with ordered data mode. Opts: (null)
[Wed Jul  3 21:41:55 2013] EXT4-fs (dm-8): mounted filesystem with ordered data mode. Opts: (null)
[Wed Jul  3 21:46:33 2013] mail-notificati[3792]: segfault at 4c ip 0805df43 sp bfec93a0 error 4 in mail-notification[8048000+5a000]
[Wed Jul  3 21:59:46 2013] cgroup: cgcreate (6018) created nested cgroup for controller "perf_event" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.
[Wed Jul  3 21:59:46 2013] cgroup: cgcreate (6018) created nested cgroup for controller "blkio" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.
[Wed Jul  3 21:59:46 2013] cgroup: cgcreate (6018) created nested cgroup for controller "devices" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.
[Wed Jul  3 21:59:46 2013] cgroup: cgcreate (6018) created nested cgroup for controller "memory" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.
[Wed Jul  3 21:59:46 2013] cgroup: "memory" requires setting use_hierarchy to 1 on the root.

Końcówka zastanawia.

EDIT:

Ten komunikat na końcu występuje przy wydawaniu polecenia typu:

Kod:

cgcreate -g memory,cpu:morfiki/browser

Różnica między aptosidem i debianem polega głównie na braku w aptosidzie:

Kod:

Enabling memory control group subsystem
...
Initializing cgroup subsys memory

Ostatnio edytowany przez morfik (2013-07-03 22:50:59)

Offline

 

#11  2013-07-03 23:06:43

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Jak ustawie CONFIG_DEVTMPFS_MOUNT , to się zamontuje z automatu ? Choć ani na kernelu z aptosida ani na tym z debiana się automatycznie nie montuje.

U mnie montuje, w Debianie nie chce mi się sprawdzać w tej chwili.
Możliwe, ze to różnica miedzy Gentowym OpenRC, a Debianowym Systemd.
Te problemy nie wyglądają mi na kernel, tylko raczej systemd.

Spróbuj w $CGROUP nie majstrować cgcreate, tylko użyć basha, jak ja w skrypcie cgstart.
U mnie w tych narzędziach cgcreate, cgexec  i cgconfig mam tonę błędów, skrypt sobie radzi o wiele lepiej,
a taka łopatologia jest też opisana w każdej dokumentacji, także to chyba żaden obciach.

Jedyny niezastąpiony dla mnie jest demon /usr/sbin/cgrulesengd - bo to on, podnoszony skryptem /etc/init.d/cgred automatycznie dodaje programy do konkretnych grup, razem z egzekwowaniem cgroup.clone.children.
Łopatologicznie ciężko byłoby taką robotę ogarnąć skryptem.

Ostatnio edytowany przez Jacekalex (2013-07-03 23:14:54)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#12  2013-07-03 23:13:02

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Powinienem mieć w systemie ten systemd? Bo:

Kod:

# dpkg -l |grep systemd
ii  libsystemd-daemon0:i386                       44-12                            i386         systemd utility library
ii  libsystemd-login0:i386                        44-12                            i386         systemd login utility library

Zastanawia mnie jeszcze to, że po wydaniu:

Kod:

cgcreate -a morfik -g memory,cpu:morfiki

nie zostały utworzone katalogi memory i cpu. Bo analizując to co jest na archwiki to mamy 2 linijki:

Kod:

sudo cgcreate -a $USER -g memory,cpu:groupname
$ ls -l /sys/fs/cgroup/memory/groupname

i ten groupname siedzi w memory , a u mnie siedzi bezpośrednio w /sys/fs/cgroup/ . To tak powinno być?

Ostatnio edytowany przez morfik (2013-07-03 23:18:38)

Offline

 

#13  2013-07-03 23:23:13

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

U mnie Jessie w ogóle nie chciał się podnieść na systemd, działa na sysvinit.

Kod:

dpkg -l | egrep 'sysv|systemd'
rc  libsystemd-daemon0:amd64                44-11                              amd64        systemd utility library
rc  libsystemd-id128-0:amd64                44-11                              amd64        systemd 128 bit ID utility library
rc  libsystemd-journal0:amd64               44-11                              amd64        systemd journal utility library
ii  libsystemd-login0:amd64                 44-11                              amd64        systemd login utility library
ii  live-config-sysvinit                    3.0.23-1                           all          Live System Configuration Scripts (sysvinit backend)
rc  systemd                                 44-11                              amd64        system and service manager
ii  sysv-rc                                 2.88dsf-41                         all          System-V-like runlevel change mechanism
ii  sysv-rc-conf                            0.99-7                             all          SysV init runlevel configuration tool for the terminal
ii  sysvinit                                2.88dsf-41                         amd64        System-V-like init utilities
ii  sysvinit-utils                          2.88dsf-41                         amd64        System-V-like utilities

W przyczyny się nie zagłębiałem, sysvinit jest stabilniejszy i bardziej przewidywalny.
Wygodniej też mi się go konfiguruje.

U ciebie natomiast grupy już są na swoim miejscu, cgcreate coś pieprzy, spróbuj tak:

Kod:

mkdir -p /sys/fs/cgroup/memory/morfikownia/browsers
mkdir -p /sys/fs/cgroup/cpu/morfikownia/browsers

To da taki sam efekt, jak cgcreate, i zazwyczaj działa bez problemu.

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-03 23:24:05)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#14  2013-07-03 23:36:47

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Ok wrzuciłem linijki od opery z tego skryptu:

Kod:

root:~# CGDIR='/sys/fs/cgroup/'
root:~# mkdir -p $CGDIR/cpu/users/opera
root:~# echo '1'> $CGDIR/cpu/users/opera/cgroup.clone_children
root:~# echo '300' > $CGDIR/cpu/users/opera/cpu.shares
root:~# mkdir -p $CGDIR/cpuacct/users/opera
root:~# mkdir -p $CGDIR/cpuset/users/opera
root:~# mkdir -p $CGDIR/memory/users/opera
root:~# echo '1'> $CGDIR/memory/users/opera/cgroup.clone_children
root:~# echo '200m' >   $CGDIR/memory/users/opera/memory.limit_in_bytes
root:~# echo '200m' >   $CGDIR/memory/users/opera/memory.soft_limit_in_bytes
root:~# echo '32m' > $CGDIR/memory/users/opera/memory.kmem.tcp.limit_in_bytes
-su: /sys/fs/cgroup//memory/users/opera/memory.kmem.tcp.limit_in_bytes: Permission denied
root:~# echo '32m' > $CGDIR/memory/users/opera/memory.kmem.tcp.limit_in_bytes
-su: /sys/fs/cgroup//memory/users/opera/memory.kmem.tcp.limit_in_bytes: Permission denied
root:~# echo  '200m' >$CGDIR/memory/users/opera/memory.memsw.limit_in_bytes
-su: /sys/fs/cgroup//memory/users/opera/memory.memsw.limit_in_bytes: Permission denied
root:~# echo  '200m' >$CGDIR/memory/users/opera/memory.memsw.limit_in_bytes
-su: /sys/fs/cgroup//memory/users/opera/memory.memsw.limit_in_bytes: Permission denied
root:~# mkdir -p $CGDIR/net_cls/users/opera
root:~# echo '1' > $CGDIR/net_cls/users/opera/cgroup.clone_children
root:~# echo '0x1004' > $CGDIR/net_cls/users/opera/net_cls.classid
root:~# cat $CGDIR/memory/users/opera/memory.limit_in_bytes
209715200

Ale to nie zadziałało coś. To zrobiłem:

Kod:

mkdir -p /sys/fs/cgroup/memory/morfikownia/browsers
mkdir -p /sys/fs/cgroup/cpu/morfikownia/browsers

ale nie mam pojęcia co mam dalej robić xD

EDIT:

Znalazłem coś takiego: http://pic.dhe.ibm.com/infocenter/lnxinfo/v3r0m0/in … gaddtasks.htm

tylko tam każą

Kod:

/etc/init.d/cgconfig restart

tyle, że ja nie mam czegoś takiego :]

Ostatnio edytowany przez morfik (2013-07-03 23:48:15)

Offline

 

#15  2013-07-03 23:54:27

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Jak ustawisz parametry w $CGDIR, to one zazwyczja tam są zapisane. :D
Potem jeszcze coś musi dodać PID programu do $CGDIR/memory/cośtam/cośtam/tasks

Do tego właśnie jest demon cgrulesengd, który się konfiguruje u mnie przez /etc/cgroup/cgrules.conf

U mnie:

Kod:

egrep -v '^$|#' /etc/cgroup/cgrules.conf 
*:firefox*                                  cpu,memory,net_cls    users/firefox/
*:plugin-container                         cpu,memory,net_cls    users/firefox/
*:opera*                                   cpu,memory,net_cls    users/opera/
*:/opt/firefox25 /firefox                  cpu,memory,net_cls   users/firefox/
*:/opt/firefox25/plugin-container         cpu,memory,net_cls   users/firefox/
*:rtmpdump                                 cpu,memory,net_cls   users/rtmpdump/
*:skype*                                   cpu,memory,net_cls    voip/skype/
*:/opt/bin/skype2235                      cpu,memory,net_cls   voip/skype/
*:pidgin                                   cpu,memory,net_cls   users/pidgin/     
*:akregator                                cpu,memory,net_cls   users/akregator/ 
*:kio_http                                 cpu,memory,net_cls   users/akregator/    
*:liferea                                  cpu,memory,net_cls   users/liferea/
*:vlc                                      cpu,memory,net_cls   users/vlc/
*:mplayer*                                 cpu,memory,net_cls   users/mplayer/
*:/opt/google/chrome/chrome                cpu,memory,blkio,net_cls   users/chrome/
*:opera                                    cpu,memory,net_cls   users/opera/
*:totem                                    cpu,memory,net_cls   users/totem/
*:tvtime                                   cpu,memory           users/tvtime/
*:kaffeine                                 cpu,memory,net_cls   users/kaffeine/
*:/bin/cat                                 cpu,memory            system/cat/
*:thunderbird-bin                          cpu,memory,net_cls   users/thunderbird/
*:thunderbird                              cpu,memory,net_cls   users/thunderbird/
*:emerge                                    cpu,memory,blkio,net_cls      system/emerge  
*:ebuild                                    cpu,memory,blkio,net_cls      system/emerge
*:make                                      cpu,memory,blkio,net_cls      system/emerge 
*:cmake                                     cpu,memory,blkio,net_cls      system/emerge 
*:qemu-system*                              cpu,memory,blkio,net_cls      kvm/fbsd
*:/usr/bin/filezilla                        net_cls      users/wget/
*:wget                                      net_cls      users/wget/
*:axel                                      net_cls      users/axel/
*:curl                                      net_cls      users/axel/

Jak widać:

Kod:

cat /proc/`pidof thunderbird`/cgroup
13:hugetlb:/
12:net_prio:/
11:perf_event:/
10:blkio:/
9:net_cls:/users/thunderbird
8:freezer:/
7:devices:/
6:memory:/users/thunderbird
5:cpuacct:/
4:cpu:/users/thunderbird
3:debug:/
2:cpuset:/

Działa ;)

Ostatnio edytowany przez Jacekalex (2013-07-04 03:39:15)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#16  2013-07-04 00:09:37

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Ok, dodałem 2 linijki od opery do /etc/cgrules.conf

Kod:

*:opera*                                   cpu,memory,net_cls    users/opera/
*:opera                                    cpu,memory,net_cls   users/opera/

bo jak wpisałem do tego drugiego pliki co podałeś to dostałem:

Kod:

# cgrulesengd 
Error: libcgroup failed to initialize rulescache from /etc/cgrules.conf. No such file or directory

Po zmianie chyba wszystko powinno być ok ale:

Kod:

cat /proc/`pidof opera`/cgroup
2:perf_event,blkio,net_cls,freezer,devices,memory,cpuacct,cpu,cpuset:/

I limit 200M

Kod:

root:/sys/fs/cgroup/memory/users/opera# cat memory.limit_in_bytes 
209715200

nie wpływa na nic, i opera zjada dalej 480M. xD Restart opery też nie pomaga.

EDIT:

Odpaliłem ten cgrulesengd przy pomocy:

Kod:

cgrulesengd -v -f /var/log/cgrulesengd

I dostałem taki log:

Kod:

Proceeding with PID 6330
Rule: *:opera*
  UID: any
  GID: any
  DEST: users/opera/
  CONTROLLERS:
    cpu
    memory
    net_cls

Rule: *:opera
  UID: any
  GID: any
  DEST: users/opera/
  CONTROLLERS:
    cpu
    memory
    net_cls

Started the CGroup Rules Engine Daemon.
....
Cgroup change for PID: 6583, UID: 1000, GID: 1000, PROCNAME: /usr/bin/opera FAILED! (Error Code: 50002)
Cgroup change for PID: 6583, UID: 1000, GID: 1000, PROCNAME: /usr/bin/opera FAILED! (Error Code: 50002)
Cgroup change for PID: 6583, UID: 1000, GID: 1000, PROCNAME: /usr/lib/opera/opera FAILED! (Error Code: 50002)

Ostatnio edytowany przez morfik (2013-07-04 00:20:53)

Offline

 

#17  2013-07-04 04:23:28

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Czemu w Debianowym libcgroup i cgroup-bin nie ma normalnych skryptów startowych?

Nawet apt-file nie znajduje żadnego /etc/init.d/cgred ani /etc/init.d/cgconfig

Opera?
SOA#1

Kod:

cat /proc/`pidof opera`/cgroup
13:hugetlb:/
12:net_prio:/
11:perf_event:/
10:blkio:/
9:net_cls:/users/opera
8:freezer:/
7:devices:/
6:memory:/users/opera
5:cpuacct:/
4:cpu:/users/opera
3:debug:/
2:cpuset:/

Może zobacz na bugzilli Debiana?
Na wiki Debiana o cgroup nie znalazłem ani jednej strony.
Może brak plików startowych, to ten błąd:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588494

W Jessim mam tylko przykładowy plik startowy z Red Hata:

Kod:

/usr/share/doc/cgroup-bin/examples/cgred

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-04 04:38:32)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#18  2013-07-04 10:15:29

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Jacekalex napisał(-a):

Na wiki Debiana o cgroup nie znalazłem ani jednej strony.

Ja znalazłem tylko to to o lxc — http://wiki.debian.org/LXC

Tych skryptów /etc/init.d/cgred , /etc/init.d/cgconfig nie ma. Ale jest:

Kod:

root:~# find / -iname *cgconfig*
/usr/sbin/cgconfigparser
/usr/share/man/man8/cgconfigparser.8.gz
/usr/share/man/man5/cgconfig.conf.5.gz
/usr/share/doc/cgroup-bin/examples/cgconfig.sysconfig
/usr/share/doc/cgroup-bin/examples/cgconfig.gz
/usr/share/doc/cgroup-bin/examples/cgconfig.conf
root:~# find / -iname *cgred*
/usr/share/man/man5/cgred.conf.5.gz
/usr/share/doc/cgroup-bin/examples/cgred
/usr/share/doc/cgroup-bin/examples/cgred.conf

I przeglądając te pliki po kolei to są 2 skrypty:

W  /usr/share/doc/cgroup-bin/examples/cgconfig.gz jest :

Kod:

#!/bin/bash
#
# Start/Stop the workload manager
#
# Copyright IBM Corporation. 2008
#
# Authors:     Balbir Singh <balbir@linux.vnet.ibm.com>
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# cgconfig Control Groups Configuration Startup
# chkconfig: - 5 95
# description: This script runs the cgconfigparser utility to parse and setup
#              the control group filesystem. It uses /etc/cgconfig.conf
#              and parses the configuration specified in there.

### BEGIN INIT INFO
# Provides:             cgconfig
# Required-Start:
# Required-Stop:
# Should-Start:         ypbind
# Should-Stop:          ypbind
# Short-Description:    Create and setup control group filesystem(s)
# Description:          Create and setup control group filesystem(s)
### END INIT INFO

# get correct location of binaries from configure
prefix=/usr;exec_prefix=${prefix};sbindir=${exec_prefix}/sbin
CGCONFIGPARSER_BIN=$sbindir/cgconfigparser
CONFIG_FILE=/etc/cgconfig.conf
servicename=cgconfig
lockfile=/var/lock/subsys/$servicename

#
# Source LSB routines
#
. /lib/lsb/init-functions

# read the config
CREATE_DEFAULT=yes
if [ -e /etc/sysconfig/cgconfig ]; then
        . /etc/sysconfig/cgconfig
fi

create_default_groups() {
    defaultcgroup=

        if [ -f /etc/cgrules.conf ]; then
        grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf | \
            read user ctrl defaultcgroup
            if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then
                log_warning_msg "/etc/cgrules.conf incorrect"
                log_warning_msg "Overriding it"
                defaultcgroup=
            fi
        fi

        if [ -z $defaultcgroup ]
        then
            defaultcgroup=sysdefault/
        fi

        #
        # Find all mounted subsystems and create comma-separated list
        # of controllers.
        #
        controllers=`lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//`

        #
        # Create the default group, ignore errors when the default group
        # already exists.
        #
        cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null

        #
        # special rule for cpusets
        #
        if echo $controllers | grep -q -w cpuset; then
                cpus=`cgget -nv -r cpuset.cpus /`
                cgset -r cpuset.cpus=$cpus $defaultcgroup
                mems=`cgget -nv -r cpuset.mems /`
                cgset -r cpuset.mems=$mems $defaultcgroup
        fi

        #
        # Classify everything to default cgroup. Ignore errors, some processes
        # may exit after ps is run and before cgclassify moves them.
        #
        cgclassify -g $controllers:$defaultcgroup `ps --no-headers -eL o tid` \
                 2>/dev/null || :
}

start() {
        echo -n "Starting cgconfig service: "
    if [ -f "$lockfile" ]; then
            log_warning_msg "lock file already exists"
            return 0
        fi

        if [ $? -eq 0 ]; then
                if [ ! -s $CONFIG_FILE ]; then
                    log_failure_msg $CONFIG_FILE "is not configured"
                    return 6
                fi

                $CGCONFIGPARSER_BIN -l $CONFIG_FILE
                retval=$?
                if [ $retval -ne 0 ]; then
                    log_failure_msg "Failed to parse " $CONFIG_FILE
                    return 1
                fi
        fi

        if [ $CREATE_DEFAULT = "yes" ]; then
                create_default_groups
        fi

        touch "$lockfile"
        retval=$?
        if [ $retval -ne 0 ]; then
            log_failure_msg "Failed to touch $lockfile"
            return 1
        fi
        log_success_msg
        return 0
}

stop() {
    echo -n "Stopping cgconfig service: "
    cgclear
    rm -f "$lockfile"
    log_success_msg
    return 0
}

trapped() {
    #
    # Do nothing
    #
    true
}

usage() {
    echo "$0 <start|stop|restart|condrestart|status>"
    exit 2
}

common() {
    #
    # main script work done here
    #
    trap "trapped ABRT" ABRT
    trap "trapped QUIT" QUIT
    trap "trapped TERM" TERM
    trap "trapped INT"   INT
}

restart() {
    common
    stop
    start
}

RETVAL=0

case $1 in
    'stop')
        common
        stop
        RETVAL=$?
        ;;
    'start')
        common
        start
        RETVAL=$?
        ;;
    'restart'|'reload')
    restart
        RETVAL=$?
        ;;
    'condrestart')
        if [ -f "$lockfile" ]; then
            restart
            RETVAL=$?
        fi
        ;;
    'status')
        if [ -f "$lockfile" ]; then
            echo "Running"
            exit 0
        else
            echo "Stopped"
            exit 3
        fi
    ;;
    *)
        usage
        ;;
esac

exit $RETVAL

A w /usr/share/doc/cgroup-bin/examples/cgred jest :

Kod:

#!/bin/bash
#
# Start/Stop the CGroups Rules Engine Daemon
#
# Copyright Red Hat Inc. 2008
#
# Authors:    Steve Olivieri <sjo@redhat.com>
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
# 
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# cgred        CGroups Rules Engine Daemon
# chkconfig:    - 14 86
# description:    This is a daemon for automatically classifying processes \
#        into cgroups based on UID/GID.
#
# processname: cgrulesengd
# pidfile: /var/run/cgred.pid
#
### BEGIN INIT INFO
# Provides:        cgrulesengd
# Required-Start:    $local_fs $syslog $cgconfig
# Required-Stop:    $local_fs $syslog
# Should-Start:        
# Should-Stop:        
# Short-Description:    start and stop the cgroups rules engine daemon
# Description:        CGroup Rules Engine is a tool for automatically using \
#            cgroups to classify processes
### END INIT INFO

prefix=/usr;exec_prefix=${prefix};sbindir=${exec_prefix}/sbin
CGRED_BIN=$sbindir/cgrulesengd
CGRED_CONF=/etc/cgrules.conf

# Sanity checks
[ -x $CGRED_BIN ] || exit 1

# Source function library & LSB routines
. /etc/rc.d/init.d/functions
. /lib/lsb/init-functions

# Read in configuration options.
if [ -f "/etc/sysconfig/cgred.conf" ] ; then
    . /etc/sysconfig/cgred.conf
    OPTIONS="$NODAEMON $LOG"
    if [ -n "$LOG_FILE" ]; then
        OPTIONS="$OPTIONS --logfile=$LOG_FILE"
    fi
    if [ -n "$SOCKET_USER" ]; then
        OPTIONS="$OPTIONS -u $SOCKET_USER"
    fi
    if [ -n "$SOCKET_GROUP" ]; then
        OPTIONS="$OPTIONS -g $SOCKET_GROUP"
    fi
else
    OPTIONS=""
fi

# For convenience
processname=cgrulesengd
servicename=cgred
lockfile="/var/lock/subsys/$servicename"
pidfile=/var/run/cgred.pid

start()
{
    echo -n $"Starting CGroup Rules Engine Daemon: "
    if [ -f "$lockfile" ]; then
        log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
        return 0
    fi
    if [ ! -s $CGRED_CONF ]; then
        log_failure_msg "not configured"
        return 6
    fi
    if ! grep "^cgroup" /proc/mounts &>/dev/null; then
        echo
        log_failure_msg $"Cannot find cgroups, is cgconfig service running?"
        return 1
    fi
    daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
    retval=$?
    echo
    if [ $retval -ne 0 ]; then
        return 7
    fi
    touch "$lockfile"
    if [ $? -ne 0 ]; then
        return 1
    fi
    echo "`pidof $processname`" > $pidfile
    return 0
}

stop()
{
    echo -n $"Stopping CGroup Rules Engine Daemon..."
    if [ ! -f $pidfile ]; then
        log_success_msg
        return 0
    fi
    killproc -p $pidfile -TERM "$processname"
    retval=$?
    echo
    if [ $retval -ne 0 ]; then
        return 1
    fi
    rm -f "$lockfile" "$pidfile"
    return 0
}

RETVAL=0

# See how we are called
case "$1" in
    start)
        start
        RETVAL=$?
        ;;
    stop)
        stop
        RETVAL=$?
        ;;
    status)
        status -p $pidfile $servicename
        RETVAL=$?
        ;;
    restart)
        stop
        start
        RETVAL=$?
        ;;
    condrestart)
        if [ -f "$lockfile" ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
    reload|flash)
        if [ -f "$lockfile" ]; then
            echo $"Reloading rules configuration..."
            kill -s 12 `cat ${pidfile}`
            RETVAL=$?
            if [ $RETVAL -eq 0 ] ; then
                log_success_msg
            else
                log_failure_msg
            fi
        else
            log_failure_msg "$servicename is not running."
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        RETVAL=2
        ;;
esac

exit $RETVAL

Może trzeba z nich manualnie zrobić skrypty startowe?

W linki jest:

Also, assigning processes under "/sysdefault" has a side-effect of
making "/etc/init.d/cgconfig stop" to fail when namespace ("ns")
subsystem is in use.

  # grep cgroup /proc/mounts
  # /etc/init.d/cgconfig start
  Starting cgconfig service: .
  # cat /proc/$$/cgroup
  2:devices,ns:/sysdefault
  # /etc/init.d/cgconfig stop
  Stopping cgconfig service: cgclear failed with Operation not permitted

także oni mają xD

Zrobię te skrypty ręcznie i dorzucę cgconfig.conf do /etc/cgconfig.conf i może coś się zmieni.

EDIT:

Wgrałem te skrypty i domyślny konfig i przy montowaniu cgroup ręcznie przez /etc/fstab można dostać takie coś:

Kod:

root:/etc/init.d# ./cgconfig restart
Stopping cgconfig service: cgclear failed with Device or resource busy
. ok 
Starting cgconfig service: parsing failed at line number 17
/usr/sbin/cgconfigparser; error loading /etc/cgconfig.conf: End of File or iterator
[FAIL] Failed to parse /etc/cgconfig.conf ... failed!

Przy odmontowaniu, wszystko z cgclear jest ok ale coś nie przyjmuje tego konfigu, trochę to dziwne bo domyślny. xD

Tak wygląda póki co ten plik:

Kod:

#
#  Copyright IBM Corporation. 2007
#
#  Authors:    Balbir Singh <balbir@linux.vnet.ibm.com>
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of version 2.1 of the GNU Lesser General Public License
#  as published by the Free Software Foundation.
#
#  This program is distributed in the hope that it would be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
group daemons/www {
    perm {
        task {
            uid = root;
            gid = webmaster;
        }
        admin {
            uid = root;
            gid = root;
        }
    }
    cpu {
        cpu.shares = 1000;
    }
}

group daemons/ftp {
    perm {
        task {
            uid = root;
            gid = ftpmaster;
        }
        admin {
            uid = root;
            gid = root;
        }
    }
    cpu {
        cpu.shares = 500;
    }
}

mount {
    cpu = /mnt/cgroups/cpu;
    cpuacct = /mnt/cgroups/cpuacct;
}

Ostatnio edytowany przez morfik (2013-07-04 10:48:35)

Offline

 

#19  2013-07-04 11:21:34

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Ok udało mi się odpalić ten skrypt /etc/init.d/cgconfig . Póki co, plik /etc/cgconfig.conf wygląda tak:

Kod:

mount {
    cpu = /mnt/cgroups/cpu;
    cpuacct = /mnt/cgroups/cpuacct;
}

Potem dałem:

Kod:

root:/# cd /mnt/
root:/mnt# ls -a
./  ../
root:/mnt# cd /etc/init.d/
root:/etc/init.d# chmod +x cg
cgconfig  cgred     
root:/etc/init.d# chmod +x cgconfig cgred 
root:/etc/init.d# ./cgconfig restart
[ ok ing cgconfig service: .
Starting cgconfig service: touch: cannot touch `/var/lock/subsys/cgconfig': No such file or directory
[FAIL] Failed to touch /var/lock/subsys/cgconfig ... failed!
root:/etc/init.d# mkdir /var/lock/subsys/
root:/etc/init.d# ./cgconfig restart
[ ok ing cgconfig service: .
[ ok ing cgconfig service: .
root:/etc/init.d# cat /var/lock/subsys/cgconfig
root:/etc/init.d# cd /mnt/
root:/mnt# ls -a
./  ../  cgroups/
root:/mnt# cd cgroups/
root:/mnt/cgroups# ls -a
./  ../  cpu/  cpuacct/
root:/mnt/cgroups# cd cpu
cpu/     cpuacct/ 
root:/mnt/cgroups# cd cpu
root:/mnt/cgroups/cpu# ls -a
./  ../  sysdefault/  cgroup.clone_children  cgroup.event_control  cgroup.procs  cpu.shares  notify_on_release  release_agent  tasks
root:/mnt/cgroups/cpu# cd sysdefault/
root:/mnt/cgroups/cpu/sysdefault# ls -a
./  ../  cgroup.clone_children  cgroup.event_control  cgroup.procs  cpu.shares  notify_on_release  tasks
root:/mnt/cgroups/cpu/sysdefault#

Po dopisaniu do pliku /etc/cgconfig.conf :

Kod:

memory = /mnt/cgroups/memory;

I zresetowaniu usługi:

Kod:

root:/mnt/cgroups# ls -a
./  ../  cpu/  cpuacct/  memory/
root:/mnt/cgroups# cd memory/
root:/mnt/cgroups/memory# ls -a
./                     cgroup.event_control  memory.limit_in_bytes            memory.soft_limit_in_bytes  memory.use_hierarchy
../                    cgroup.procs          memory.max_usage_in_bytes        memory.stat                 notify_on_release
sysdefault/            memory.failcnt        memory.move_charge_at_immigrate  memory.swappiness           release_agent
cgroup.clone_children  memory.force_empty    memory.oom_control               memory.usage_in_bytes       tasks

Czyli chyba jest dobrze, jak na razie. xD Mniejsza na razie z tym gdzie to jest montowane.

Chciałem odpalić cgred ale:

Kod:

root:/etc/init.d# ./cgred restart
./cgred: line 43: /etc/rc.d/init.d/functions: No such file or directory
[ ok ing CGroup Rules Engine Daemon....
Starting CGroup Rules Engine Daemon: ./cgred: line 85: daemon: command not found

Próbowałem stworzyć plik /etc/default/cgconfig o treści:

Kod:

# Service cgconfig can create a default group in all mounted hierarchies and
# move all processes there on boot. If no default rule is specified in
# /etc/cgrules.conf, the default group is named '/sysdefault'.
# This automatically created group(s) can be useful e.g. when using 'cpu'
# controller to limit cpu.shares of this default group and allowing some more
# important group take most of the CPU.
#
# By default, create these groups:
#CREATE_DEFAULT=yes

# Uncomment following line to disable creation of the default group on startup:
 CREATE_DEFAULT=no

ale on nic nie robi. To zrobiłem /etc/sysconfig/cgconfig  i on już blokuje tworzenie domyślnej grupy.

Ostatnio edytowany przez morfik (2013-07-04 11:38:36)

Offline

 

#20  2013-07-04 12:15:54

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Kod:

root      2885  0.0  0.0  13148  2004 ?        Ss   08:47   0:02 /usr/sbin/cgrulesengd --nodaemon --nolog

/etc/init.d/cgred podnosi dokładnie taki proces.

Te przykładowe pliki cgred i cgconfig , który tobie się wywala, są nie z Debiana, tylko z RedHata.
Nic dziwnego, że na Debianie nie chodzą.

Ale zawsze możesz sobie sam zrobić skrypt do systemd, który podniesie taki proces.

To jest gentusiowy /etc/init.d/cgred  od OpenRC:

Kod:

#!/sbin/runscript
#
# CGroups Rules Engine Daemon
#
# This is a daemon for automatically classifying processes into cgroups based
# on UID/GID.
#
opts="${opts} reload"

CGRULESENGD="/usr/sbin/cgrulesengd"
PID_FILE=${PID_FILE:-"/var/run/cgred.pid"}

depend() {
    need cgconfig
    use logger
}

start() {
    local options="${NODAEMON} ${LOG}"
    if [[ -n "${LOG_FILE}" ]]; then
        options="${options} --log-file=${LOG_FILE}"
    fi

    ebegin "Starting CGroup Rules Engine Daemon"
    start-stop-daemon --start --pidfile "${PID_FILE}" --make-pidfile \
        --background --exec "${CGRULESENGD}" -- ${options} >/dev/null
    eend $?
}

stop() {
    ebegin "Stopping CGroup Rules Engine Daemon"
    start-stop-daemon --stop --pidfile "${PID_FILE}" --exec "${CGRULESENGD}"
    eend $?
}

reload() {
    ebegin "Reloading CGroup Rules Engine Daemon"
    start-stop-daemon --stop --signal USR2 --oknodo --background \
        --pidfile "${PID_FILE}" --make-pidfile --exec "${CGRULESENGD}"
    eend $?
}

Jak widać, żadne czary.
Do tego konfig:

Kod:

# /etc/conf.d/cgred.conf: config file for /etc/init.d/cgred

# Uncomment the following line to log to specified file instead of syslog
#LOG_FILE="/var/log/cgrulesengd.log"

# Uncomment the second line to run CGroup Rules Engine in non-daemon mode
#NODAEMON=""
NODAEMON="--nodaemon"

# Uncomment the second line to disable logging for CGroup Rules Engine
# Uncomment the third line to enable more verbose logging.
#LOG=""
LOG="--nolog"
#LOG="-v"

# PID file
PID_FILE=/var/run/cgred.pid

Cgconfig u mnie nie umiał czytać własnego konfigu, więc dałem spokój, zamiast z nim kombinować, naskrobałem skrypta, a cgconfig startuje z czystym (pustym) configiem.

I wsio działa.

Za uwagę dziękuje:

Kod:

qlist -ICvUq libcgroup
dev-libs/libcgroup-0.39_rc1-r1 daemon debug pam tools

Do Debiana obczaj te pliki:
http://packages.ubuntu.com/precise/amd64/cgroup-bin/filelist

Z jakiegoś powodu w najnowszej wersji (w Debianie i Ubuntu) nie ma połowy skryptów i konfigów.
Może jakiś developer dostał kataru, i skompilował libcgoup bez opcji daemon i tools.

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-04 12:29:44)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#21  2013-07-04 12:53:29

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Ten domyślny skrypt to chyba by nawet szło przerobić. np:

Kod:

# Source function library & LSB routines
#. /etc/rc.d/init.d/functions
. /lib/lsb/init-functions

Zgodnie z tym http://unix.stackexchange.com/questions/9314/no-suc … t-d-functions , w debianie jest ten drugi, także jeden problem z głowy. W skrypcie jest wzmianka o

Kod:

# Read in configuration options.
if [ -f "/etc/sysconfig/cgred.conf" ] ; then
    . /etc/sysconfig/cgred.conf
    OPTIONS="$NODAEMON $LOG"
    if [ -n "$LOG_FILE" ]; then
        OPTIONS="$OPTIONS --logfile=$LOG_FILE"
    fi
    if [ -n "$SOCKET_USER" ]; then
        OPTIONS="$OPTIONS -u $SOCKET_USER"
    fi
    if [ -n "$SOCKET_GROUP" ]; then
        OPTIONS="$OPTIONS -g $SOCKET_GROUP"
    fi
else
    OPTIONS=""
fi

To dorobiłem plik /etc/sysconfig/cgred.conf :

Kod:

# /etc/sysconfig/cgred.conf - CGroup Rules Engine Daemon configuration file
# 
# The four options listed below (CONFIG_FILE, LOG_FILE, NODAEMON, LOG) are
# the only valid ones.  Defining anything else in this file will cause the
# CGroup Rules Engine program to fail.  So, don't do it.

# The pathname to the configuration file for CGroup Rules Engine
CONFIG_FILE="/etc/cgrules.conf"

# Uncomment the following line to log to specified file instead of syslog
LOG_FILE="/var/log/cgrulesengd.log"

# Uncomment the second line to run CGroup Rules Engine in non-daemon mode
NODAEMON=""
#NODAEMON="--nodaemon"

# Set owner of cgred socket. 'cgexec' tool should have write access there
# (either using suid and/or sgid permissions or Linux capabilities).
SOCKET_USER=""
SOCKET_GROUP="cgred"

# Uncomment the second line to disable logging for CGroup Rules Engine
# Uncomment the third line to enable more verbose logging.
#LOG=""
#LOG="--nolog"
LOG="-v"

Ale to nic nie zmienia przy wywoływaniu skryptu. Nie wiem po co to jest:

Kod:

daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS

bo to ta linijka generuje błąd

Generalnie jeśli ten cgconfig działa, pliki są tworzone + odpowiednie wartości powpisywane i jeśli jest obecny proces cgrulesengd + odpowiednie reguły, to powinno wszystko działać? Bo jak ręcznie odpalę cgrulesengd to mi przy znalezieniu pasującego procesu wyrzuca błąd.

Kod:

Cgroup change for PID: 10114, UID: 1000, GID: 1000, PROCNAME: /usr/bin/opera FAILED! (Error Code: 50004) 
Cgroup change for PID: 10114, UID: 1000, GID: 1000, PROCNAME: /usr/bin/opera FAILED! (Error Code: 50004) 
Cgroup change for PID: 10114, UID: 1000, GID: 1000, PROCNAME: /usr/lib/opera/opera FAILED! (Error Code: 50004)

I co z tym zrobić?

Offline

 

#22  2013-07-04 13:25:59

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Właśnie dokładnie obejrzałem u mnie konfigurację, i okazuje się, że u mnie OpenRC aktywuje cgroup, a kernel automatycznie tylko tworzy /sys/fs/cgroup, ale nie ma tam jeszcze większości funkcji.

Wywalę sobie ile się da do skrypta, żeby się uniezależnić od OpenRC i wszystkiego, co się da, z wyjątkiem cgred, bo ten grzecznie przydziela procesy do odpowiednich grup.

Takiego błędu, jak 50004 jeszcze na oczy nie widziałem.

I radzę obejrzeć dokumentację kernela, tam jest pierwsza wersja konfiguracji, której używałem przy pisaniu skryptu cgstart.
Sznurek:
https://www.kernel.org/doc/Documentation/cgroups/

EDYTA:
Nowa wersja cgstart, skrypt sam zakłada i montuje foldery.
http://jacekalex.sh.dug.net.pl/cgstartnew
Powinien pomóc na Debianie.
Zmieniłem też limity pamięci  na soft, bo na starych ubijał program zamiast zabronić większej ilości ramu.

Pozdro
;-)

Ostatnio edytowany przez Jacekalex (2013-07-04 14:42:09)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#23  2013-07-04 14:49:19

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

Udało mi się w końcu ograniczyć zasoby dla opery! xD

Wpisywanie wartości ręcznie coś nie chce uzupełniać pliku tasks o pidy. Zacząłem sobie pisać na nowo /etc/cgconfig.conf i wyskrobałem tam coś takiego:

Kod:

mount {
    cpuset  = /cgroup/cpuset;
    cpu     = /cgroup/cpu;
    cpuacct = /cgroup/cpuacct;
    memory  = /cgroup/memory;
    devices = /cgroup/devices;
    freezer = /cgroup/freezer;
    net_cls = /cgroup/net_cls;
    blkio   = /cgroup/blkio;
}


group users/opera {
    perm {
        task {
            uid = root;
            gid = root;
        }
        admin {
            uid = root;
            gid = root;
        }
    }
    cpu {
        cpu.shares = "512";
    }
    memory {
        memory.limit_in_bytes = 200M;
    }
}

Nie mogłem przy pomocy tego pliku zamontować katalogów pod /sys/fs/cgroup/ to zamontowałem pod /cgroup/ . Dopisanie regułki "perm" sprawiło, że pidy są dodawane do tasks.

Błąd w cgrulesengd dalej istnieje przy odpalaniu opery ale nie wpływa na nic.  Po osiągnięciu około 240mb w ramie, zaczyna się zapełnianie swapa.

Także wychodzi na to, że czegoś brakowało przy ręcznym dodawaniu wartości. Jakie regułki by były potrzebne od tego perm ?

Ostatnio edytowany przez morfik (2013-07-04 14:54:37)

Offline

 

#24  2013-07-04 14:53:00

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: [SOLVED] Cgroup

Tu masz dokładny opis wszystkich parametrów cgroup.memory:
https://www.kernel.org/doc/Documentation/cgroups/memory.txt

Ja już nie mam siły z tym kombinować na razie.


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#25  2013-07-04 15:04:21

  morfik - Cenzor wirtualnego świata

morfik
Cenzor wirtualnego świata
Skąd: ze WSI
Zarejestrowany: 2011-09-15
Serwis

Re: [SOLVED] Cgroup

To działa chyba tak jak powinno:

Kod:

root:/#  cat /cgroup/memory/users/opera/tasks
23900
23904
23910
23911
23917
root:/# ps -eo "%mem user pid args" --sort %mem | grep opera
 0.0 morfik   23899 /bin/sh -c /usr/bin/opera 
 0.0 root     24269 grep --color=auto opera
22.3 morfik   23900 /usr/lib/opera/opera
root:/# cat /cgroup/memory/users/opera/memory.limit_in_bytes 
209715200

Da radę sprawdzić ile proces zajmuje w swap?

Offline

 

Stopka forum

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson
Nas ludzie lubią po prostu, a nie klikając w przyciski ;-)