Cgroups-memory

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Anlegen von Control Groups

  • cgcreate -g memory:/foo

Welche Parameter sind vorhanden

  • cgget -g memory /foo
/foo:
memory.use_hierarchy: 1
memory.kmem.tcp.max_usage_in_bytes: 0
memory.kmem.slabinfo: slabinfo - version: 2.1
	# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
memory.kmem.tcp.usage_in_bytes: 0
memory.kmem.failcnt: 0
memory.force_empty:
memory.max_usage_in_bytes: 0
memory.swappiness: 60
memory.limit_in_bytes: 9223372036854771712
memory.kmem.usage_in_bytes: 0
memory.pressure_level:
memory.kmem.max_usage_in_bytes: 0
memory.kmem.tcp.limit_in_bytes: 9223372036854771712
memory.stat: cache 0
	rss 0
	rss_huge 0
	mapped_file 0
	dirty 0
	writeback 0
	pgpgin 0
	pgpgout 0
	pgfault 0
	pgmajfault 0
	inactive_anon 0
	active_anon 0
	inactive_file 0
	active_file 0
	unevictable 0
	hierarchical_memory_limit 9223372036854771712
	total_cache 0
	total_rss 0
	total_rss_huge 0
	total_mapped_file 0
	total_dirty 0
	total_writeback 0
	total_pgpgin 0
	total_pgpgout 0
	total_pgfault 0
	total_pgmajfault 0
	total_inactive_anon 0
	total_active_anon 0
	total_inactive_file 0
	total_active_file 0
	total_unevictable 0
memory.numa_stat: total=0 N0=0
	file=0 N0=0
	anon=0 N0=0
	unevictable=0 N0=0
	hierarchical_total=0 N0=0
	hierarchical_file=0 N0=0
	hierarchical_anon=0 N0=0
	hierarchical_unevictable=0 N0=0
memory.kmem.tcp.failcnt: 0
memory.oom_control: oom_kill_disable 0
	under_oom 0
memory.kmem.limit_in_bytes: 9223372036854771712
memory.soft_limit_in_bytes: 9223372036854771712
memory.failcnt: 0
memory.usage_in_bytes: 0
memory.move_charge_at_immigrate: 0

Check the maximum memory limit

  • cgget -g memory /foo | grep memory.limit_in_bytes
memory.limit_in_bytes: 9223372036854771712

Set the maximum memory limit to 100MB

  • echo 100000000 > /sys/fs/cgroup/memory/foo/memory.limit_in_bytes

Check the maximum memory limit again

  • cgget -g memory /foo | grep memory.limit_in_bytes
memory.limit_in_bytes: 99999744

Testprogramm

  • apt install mathomatic-primes

3 Limitierte Prozesse und einen Unlimitierten starten

  • cgexec -g cpu:cpulimited matho-primes 0 9999999999 > /dev/null
  • cgexec -g cpu:cpulimited matho-primes 0 9999999999 > /dev/null
  • cgexec -g cpu:cpulimited matho-primes 0 9999999999 > /dev/null
  • cgexec -g cpu:lesscpulimited matho-primes 0 9999999999 > /dev/null

Top

  • top

Cgroup-1.png

Links