<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Trebuchet MS";
panose-1:2 11 6 3 2 2 2 2 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:2041854490;
mso-list-type:hybrid;
mso-list-template-ids:-192370206 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p><b><span style="font-size:9.0pt;font-family:"Trebuchet MS",sans-serif;color:#AAAAAA">Dell - Internal Use - Confidential
</span></b><o:p></o:p></p>
<p class="MsoNormal"> Hi All:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am trying to test Resource Control of system by setting MemoryLimit on my Debian system. Unfortunately it won’t work after my testing. Maybe I am not configuring right. Please let me know how to fix this.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here is info for your reference:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">1)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>uname -a<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Linux OS10 3.16.7-ckt11 #1 SMP Thu Feb 4 13:32:12 PST 2016 x86_64 GNU/Linux<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">2)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>my test program: keeping allocate 2k memory as shown below:<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">#include <stdio.h><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">#include <stdlib.h><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">main(int argc, char *argv[])<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">{<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> int size = 0, times = 0;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> char *buffer = NULL;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> size = 2000;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> times = 1;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> while (1) {<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> printf("size=%d, times=%d\n", size, times);<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> buffer = malloc(size);<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> if (buffer == NULL) {<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> printf("out of memory\n");
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> break;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> }<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> else {<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> printf("buffer=%p\n", buffer);
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> } <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> times++;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> sleep(3);<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> }<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">}<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">3)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>/lib/systemd/system/limits.slice<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">[Unit]<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Description=Limited resources Slice<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">DefaultDependencies=no<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Before=slices.target<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">[Slice]<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">MemoryAccounting=true<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">MemoryLimit=20K<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">4)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]> /lib/system/system/test.service<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">[Unit]<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Description=My Test Service.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">DefaultDependencies=no<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">[Service]<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Slice=limits.slice<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">ExecStart=/tmp/test<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">KillSignal=SIGKILL<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">SuccessExitStatus=SIGKILL<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">FailureAction=reboot-force<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"># Resource Limitations<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">LimitCORE=infinity<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">5)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]> systemctl daemon-reload<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">6)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>systemctl restart limits.slice<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">7)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>systemctl start test.service<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">I would like to see test program will be ended after running for a while keeping allocating 2K memory with configured MemroyLimit as 20K.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in">But it seems test program is keep running for a long time and it won’t be stopped.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Here is the output of systemctl status test.service<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">test.service - Test Service.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"> Loaded: loaded (/lib/systemd/system/test.service; static)<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"> Active: active (running) since Thu 2016-02-18 06:40:49 UTC; 2min 5s ago<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Main PID: 2429 (test)<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"> CGroup: /limits.slice/test.service<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"> 2429 /tmp/test<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Feb 18 06:40:49 OS10 systemd[1]: Started Test Service..<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Where does it go wrong or am I missing anything ?<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Please help !<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Thanks,<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.25in">Jeremy<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>