<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Accidentally replied to John off-list</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Patrick Farrell &lt;patrick.farrell@oracle.com&gt;<br>
<b>Sent:</b> Friday, April 26, 2024 11:15 AM<br>
<b>To:</b> John Bauer &lt;bauerj@iodoctors.com&gt;<br>
<b>Subject:</b> Re: [External] : [lustre-devel] OSC cache page retention issue</font>
<div>&nbsp;</div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
John,</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Ah, this one...&nbsp; OK, I'm intrigued today.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Most likely the issue is that our page cache shrinker doesn't work very well.&nbsp; It's not something I've dug into in detail before, but that's the simple explanation - The kernel expresses memory pressure by calling shrinkers registered by kernel modules.&nbsp; Lustre
 has a shrinker at the OSC level which is responsible for freeing pages from cache when there's memory pressure.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
The relevant function is osc_cache_shrink_scan (which actually shrinks as well as scans).&nbsp; Unfortunately it's devoid of any debug so without modifying the code to add debug, you won't be able to get any info out of it.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I see a few possible issues - the shrinker will not remove more than one RPC worth of pages from a given OSC when the shrinker is called.&nbsp; This is a pretty small amount, and it's probably actually smaller - the code comments note the shrinker only requests
 128 pages at a time and Lustre just tries to free what's asked for.<br>
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
FWIW, the shrinker doesn't appear to have any biasing towards OSCs which are more full.&nbsp; So when called, it will try to free (probably) 128 pages from the first OSC in the list, then move that OSC to the back of the list and stop.&nbsp; If the kernel still needs
 memory, it will be called repeatedly.<br>
<br>
So the idea at least is that the shrinker will rotate across the OSCs, freeing 128 pages each time.&nbsp; It doesn't care how full they are.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Here's a possible framework for the problem.&nbsp; I can't quite infer the striping and OSCs used by the files from your note - sorry, it's probably there but I'm struggling to figure it out - but...<br>
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
If the file we wish were getting evicted is already in cache is on OSCs 0-3, and the new file is on OSCs, say, 0-16, so when we start, the caches for OSCs 0-3 are full and those for OSCs 4-16 are
<b>not</b>,&nbsp;our shrinker design <b>would not preferentially drain the full ones</b>.&nbsp; It would just start draining and then balance the drain equally across all OSCs, so if the system as a whole is at memory pressure, and the source of the memory pressure is
 using all OSCs, any OSCs which are full <b>will stay full</b>&nbsp;- since they are being refilled.&nbsp; There will be no rebalancing of usage between those which are full and those which are not.<br>
<br>
Does this actually line up with your problem?&nbsp; Or are the files on separate OSCs?</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Even if this isn't the issue, the problem is very likely something in our shrinker implementation.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Regards,</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Patrick</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> lustre-devel &lt;lustre-devel-bounces@lists.lustre.org&gt; on behalf of John Bauer &lt;bauerj@iodoctors.com&gt;<br>
<b>Sent:</b> Friday, April 26, 2024 10:26 AM<br>
<b>To:</b> lustre-devel@lists.lustre.org &lt;lustre-devel@lists.lustre.org&gt;<br>
<b>Subject:</b> [External] : [lustre-devel] OSC cache page retention issue</font>
<div>&nbsp;</div>
</div>
<div>
<p>&nbsp;My first posting here.&nbsp; I hope it proves to be interesting.<br>
</p>
<p>I have an issue that I had posted to lustre-discuss some time back and Andreas Dilger recommended I post to lustre-devel.&nbsp; I have a job that does I/O to 3 files on a Lustre file system.&nbsp; The first file, SCRATCH, that gets written and read in the first 50
 seconds of the job. then nothing until rtc=2950 (rtc is real time clock, in seconds). The second file, SCR300, is written and read thoughout the job.&nbsp; I attach a couple of images below to indicate the activity.&nbsp; In each image, the bottom frame indicates how
 the file is being accessed, reads and writes, over time.&nbsp; The Y axis indicates the part of the file being accessed and the X indicates the time when the access occured.&nbsp; The top frame in each image is the amount of page cache used by each OSC that the given
 file is striped on ( 4x1M ), versus time.&nbsp; The third file is trivial ( 26MB in size and 41MB transferred ) and will not be mentioned further.<br>
</p>
<p>What is of interest is that the 4 OSC's associated with SCRATCH do not give up their cache page memory until rtc=2918, despite the file not being accessed from rtc=50 until rtc=2950, especially in light of the intense memory pressure created by the reading
 and writing of the SCR300 file.</p>
<p>Thinking this was virtual memory related, I decided to plot all of the values in /proc/vmstat versus time while the job was running and see if something of interest was occurring at rtc=2918.&nbsp; It turns out that the only thing of interest is the value slabs_scanned
 is constant until rtc=2918, then has a spike, as shown in the 3rd image below.</p>
<p>For completeness, I have also included a plot of several /proc/meminfo values versus time ( the 4th image below ).</p>
<p>This was run on a dedicated 64GB node.&nbsp; It can be seen in the meminfo plot that Lustre is using, at maximum, 50% of system memory.&nbsp; The 4 OSC's of the SCRATCH file are holding on to aggregate 22GB of memory of 32GB maximum used by Lustre.&nbsp; The SCR300 file
 is left with 10GB of memory for repeated forward and backward reading of a 70GB region of the 104GB file.&nbsp; The SCR300 could really use the 22GB being held for SCRATCH.<br>
</p>
<p>Lustre version is 2.14.0_ddn98.</p>
<p>Single process, single host ( 2 NUMA nodes )</p>
<p>For completeness I have included a plot of memory info for each of the 2 NUMA nodes.&nbsp; 5th image below.&nbsp; It can clearly be seen that memory on both numa nodes are active.<br>
</p>
<p>I should point out that this is not a new problem, nor unique to the current system I am running it on.&nbsp; I had first observed it back in 2015 on an internal system at Cray Inc.&nbsp; A plot of the SCRATCH file position activity is shown in the 6th image below.&nbsp;
 This was the actual MSC.Nastran job running, and there was&nbsp; 13150 seconds of I/O wait out of 18213 second run.&nbsp; In this job, the 4 OSC's for the SCRATCH file never released their memory, despite the file not being accessed for 18000 seconds ( 5 hours ).<br>
</p>
<p>Any light that could be cast upon this subject is welcomed.</p>
<p>John</p>
<p><br>
</p>
<p class="">The SCRATCH file activity and OSC memory usage</p>
<p class=""><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/mg55d6xv6hanmsebn4kvq/floorpan_SCRATCH.png?rlkey=rjkczx394n9mg54xtos87s0wd&amp;st=zx56loc2&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-JpmsRcFSFtg$">https://www.dropbox.com/scl/fi/mg55d6xv6hanmsebn4kvq/floorpan_SCRATCH.png?rlkey=rjkczx394n9mg54xtos87s0wd&amp;st=zx56loc2&amp;dl=0</a><br>
</p>
<img alt="https://www.dropbox.com/scl/fi/mg55d6xv6hanmsebn4kvq/floorpan_SCRATCH.png?rlkey=rjkczx394n9mg54xtos87s0wd&amp;st=yauwg1uo&amp;dl=0" width="835" height="577" data-outlook-trace="F:2|T:2" src="cid:part1.CirZiDN8.WrdBSuIK@iodoctors.com">
<p class="">The SCR300 file activity and OSC memory usage</p>
<p class=""><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/e8s4ku7zb2h6ndcwpsr3g/floorpan_SCR300.png?rlkey=elxv51uqjxv7pqwj6w3o4tmew&amp;st=1yapxmen&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-Jpmsmo4TYdw$">https://www.dropbox.com/scl/fi/e8s4ku7zb2h6ndcwpsr3g/floorpan_SCR300.png?rlkey=elxv51uqjxv7pqwj6w3o4tmew&amp;st=1yapxmen&amp;dl=0</a><br>
</p>
<p><img alt="https://www.dropbox.com/scl/fi/e8s4ku7zb2h6ndcwpsr3g/floorpan_SCR300.png?rlkey=elxv51uqjxv7pqwj6w3o4tmew&amp;st=cjwzzohl&amp;dl=0" width="835" height="577" data-outlook-trace="F:2|T:2" src="cid:part2.sFjbsa1k.fMZj1r6C@iodoctors.com"></p>
<p>The slabs_scanned from /proc/vmstat versus time.<br>
</p>
<p><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/qwg2uml7hpi204cazfynw/floorpan_slabs_scanned.png?rlkey=t4bhpobhwprhtlecbfsz1sy09&amp;st=mjepc6uw&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-Jpmtzuafs1Q$">https://www.dropbox.com/scl/fi/qwg2uml7hpi204cazfynw/floorpan_slabs_scanned.png?rlkey=t4bhpobhwprhtlecbfsz1sy09&amp;st=mjepc6uw&amp;dl=0</a><br>
</p>
<p><img alt="https://www.dropbox.com/scl/fi/qwg2uml7hpi204cazfynw/floorpan_slabs_scanned.png?rlkey=t4bhpobhwprhtlecbfsz1sy09&amp;st=74tmv31g&amp;dl=0" width="835" height="577" data-outlook-trace="F:2|T:2" src="cid:part3.18o8qJM4.9WWhdyGO@iodoctors.com"></p>
<p><br>
</p>
<p>Info from /proc/meminfo plotted versus time.<br>
</p>
<p><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/ddd99mrt26hto4fp81ayn/floorpan_meminfo.png?rlkey=401jpennt2u3343yjp2llaiqj&amp;st=09qaagpk&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-Jpmt_FqjmRg$">https://www.dropbox.com/scl/fi/ddd99mrt26hto4fp81ayn/floorpan_meminfo.png?rlkey=401jpennt2u3343yjp2llaiqj&amp;st=09qaagpk&amp;dl=0</a><br>
</p>
<p><img alt="https://www.dropbox.com/scl/fi/ddd99mrt26hto4fp81ayn/floorpan_meminfo.png?rlkey=401jpennt2u3343yjp2llaiqj&amp;st=irguyp12&amp;dl=0" width="835" height="577" data-outlook-trace="F:2|T:2" src="cid:part4.V4uqDP91.8TiLBxS9@iodoctors.com"></p>
<p><br>
</p>
<p>Memory info for the 2 numa nodes versus time.<br>
</p>
<p><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/g9auqkhzhhmp11m08hstl/floorpan_nodemem.png?rlkey=bzbmjkvb6b1lgrgj4h9xxvbny&amp;st=ihhu4c94&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-JpmsL2pseug$">https://www.dropbox.com/scl/fi/g9auqkhzhhmp11m08hstl/floorpan_nodemem.png?rlkey=bzbmjkvb6b1lgrgj4h9xxvbny&amp;st=ihhu4c94&amp;dl=0</a></p>
<img alt="https://www.dropbox.com/scl/fi/g9auqkhzhhmp11m08hstl/floorpan_nodemem.png?rlkey=bzbmjkvb6b1lgrgj4h9xxvbny&amp;st=ihhu4c94&amp;dl=0" width="734" height="553" data-outlook-trace="F:2|T:2" src="cid:part5.xq4jzCzP.Pljh85Qa@iodoctors.com">
<p><br>
</p>
<p>This is from the original job run back in 2015, internally at Cray Inc.&nbsp; This was a 128GB system.<br>
</p>
<p><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/5bwyqxjp8gi65c7qvnmcn/floorpan_orig.png?rlkey=j629zrdnuwm4lwiqv9wh6mxrt&amp;st=4bo6c1jy&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-Jpms-CIQn1A$">https://www.dropbox.com/scl/fi/5bwyqxjp8gi65c7qvnmcn/floorpan_orig.png?rlkey=j629zrdnuwm4lwiqv9wh6mxrt&amp;st=4bo6c1jy&amp;dl=0</a><br>
</p>
<p><br>
</p>
<p><img alt="https://www.dropbox.com/scl/fi/5bwyqxjp8gi65c7qvnmcn/floorpan_orig.png?rlkey=j629zrdnuwm4lwiqv9wh6mxrt&amp;st=cb2sd1bc&amp;dl=0" width="823" height="598" data-outlook-trace="F:2|T:2" src="cid:part6.0Ipctt0h.sUPojb5x@iodoctors.com"><br>
</p>
<p>The SCR300 file for the original job back in 2015<br>
</p>
<p><a class="x_x_moz-txt-link-freetext" href="https://urldefense.com/v3/__https://www.dropbox.com/scl/fi/sr969igg0c1hvzn0kaq47/floorpan_orig_SCR300.png?rlkey=q4rg34s78ytxal4dx4k3b26rd&amp;st=o2kzxa2z&amp;dl=0__;!!ACWV5N9M2RV99hQ!Km2c9xVnQ_BpUQ_AOFMN3K5SjxMEuVgpx7NPRzEnGLLeS2Itg3w2y02BJJNx1gZOkbH3CM26NI-JpmsuNAOxkQ$">https://www.dropbox.com/scl/fi/sr969igg0c1hvzn0kaq47/floorpan_orig_SCR300.png?rlkey=q4rg34s78ytxal4dx4k3b26rd&amp;st=o2kzxa2z&amp;dl=0</a></p>
<img alt="https://www.dropbox.com/scl/fi/sr969igg0c1hvzn0kaq47/floorpan_orig_SCR300.png?rlkey=q4rg34s78ytxal4dx4k3b26rd&amp;st=o2kzxa2z&amp;dl=0" width="826" height="613" data-outlook-trace="F:2|T:2" src="cid:part7.0OHwAi9q.aC028Ps6@iodoctors.com"><br>
<p></p>
</div>
</div>
</body>
</html>