Cgroups-memory: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 69: Zeile 69:
 
</pre>
 
</pre>
  
*cgget -g cpu /cpulimited
+
=Check the maximum memory limit=
<pre>
+
*cgget -g memory /foo | grep memory.limit_in_bytes
/cpulimited:
+
memory.limit_in_bytes: 9223372036854771712
cpu.shares: 1024
+
=Set the maximum memory limit to 100MB=
cpu.cfs_quota_us: -1
+
*echo 100000000 > /sys/fs/cgroup/memory/foo/memory.limit_in_bytes
cpu.stat: nr_periods 0
+
=Check the maximum memory limit again=
nr_throttled 0
+
*cgget -g memory /foo | grep memory.limit_in_bytes
throttled_time 0
+
memory.limit_in_bytes: 99999744
cpu.cfs_period_us: 100000
+
=PID der CGroup zu teilen=
</pre>
+
*echo 1623 > /sys/fs/cgroup/memory/foo/cgroup.procs
  
=cpu.shares auf 512 in den cpulimited group=
+
=Links=
Normaler Wert ist 1024
+
*https://wiki.archlinux.org/index.php/cgroups
*cgset -r cpu.shares=512 cpulimited
 
 
 
=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
 
[[Datei:cgroup-1.png|600px]]
 

Aktuelle Version vom 14. Oktober 2017, 19:48 Uhr

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

PID der CGroup zu teilen

  • echo 1623 > /sys/fs/cgroup/memory/foo/cgroup.procs

Links