Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

3.2. cpu

cpu 子​​​系​​​统​​​调​​​度​​​对​​​ cgroup 的​​​ CPU 访​​​问​​​。​​​可​​​根​​​据​​​以​​​下​​​参​​​数​​​调​​​度​​​对​​​ CPU 资​​​源​​​的​​​访​​​问​​​,每​​​个​​​参​​​数​​​都​​​独​​​立​​​存​​​在​​​于​​​ cgroup 虚​​​拟​​​文​​​件​​​系​​​统​​​的​​​伪​​​文​​​件​​​中​​​:
cpu.shares
包​​​含​​​用​​​来​​​指​​​定​​​在​​​ cgroup 中​​​的​​​任​​​务​​​可​​​用​​​的​​​相​​​对​​​共​​​享​​​ CPU 时​​​间​​​的​​​整​​​数​​​值​​​。​​​例​​​如​​​:在​​​两​​​个​​​ cgroup 中​​​都​​​将​​​ cpu.shares 设​​​定​​​为​​​ 1 的​​​任​​​务​​​将​​​有​​​相​​​同​​​的​​​ CPU 时​​​间​​​,但​​​在​​​ cgroup 中​​​将​​​ cpu.shares 设​​​定​​​为​​​ 2 的​​​任​​​务​​​可​​​使​​​用​​​的​​​ CPU 时​​​间​​​是​​​在​​​ cgroup 中​​​将​​​ cpu.shares 设​​​定​​​为​​​ 1 的​​​任​​​务​​​可​​​使​​​用​​​的​​​ CPU 时​​​间​​​的​​​两​​​倍​​​。​​​
cpu.rt_runtime_us
以​​​微​​​秒​​​(µs,这​​​里​​​以​​​“​​​us”​​​代​​​表​​​)为​​​单​​​位​​​指​​​定​​​在​​​某​​​个​​​时​​​间​​​段​​​中​​​ cgroup 中​​​的​​​任​​​务​​​对​​​ CPU 资​​​源​​​的​​​最​​​长​​​连​​​续​​​访​​​问​​​时​​​间​​​。​​​建​​​立​​​这​​​个​​​限​​​制​​​是​​​为​​​了​​​防​​​止​​​一​​​个​​​ cgroup 中​​​的​​​任​​​务​​​独​​​占​​​ CPU 时​​​间​​​。​​​如​​​果​​​ cgroup 中​​​的​​​任​​​务​​​应​​​该​​​可​​​以​​​每​​​ 5 秒​​​中​​​可​​​有​​​ 4 秒​​​时​​​间​​​访​​​问​​​ CPU 资​​​源​​​,请​​​将​​​ cpu.rt_runtime_us 设​​​定​​​为​​​ 4000000,并​​​将​​​ cpu.rt_period_us 设​​​定​​​为​​​ 5000000。​​​
cpu.rt_period_us
以​​​微​​​秒​​​(µs,这​​​里​​​以​​​“​​​us”​​​代​​​表​​​)为​​​单​​​位​​​指​​​定​​​在​​​某​​​个​​​时​​​间​​​段​​​中​​​ cgroup 对​​​ CPU 资​​​源​​​访​​​问​​​重​​​新​​​分​​​配​​​的​​​频​​​率​​​。​​​如​​​果​​​某​​​个​​​ cgroup 中​​​的​​​任​​​务​​​应​​​该​​​每​​​ 5 秒​​​钟​​​有​​​ 4 秒​​​时​​​间​​​可​​​访​​​问​​​ CPU 资​​​源​​​,则​​​请​​​将​​​ cpu.rt_runtime_us 设​​​定​​​为​​​ 4000000,并​​​将​​​ cpu.rt_period_us 设​​​定​​​为​​​ 5000000。​​​