CINXE.COM
LKML: Aboorva Devarajan: Re: [RFT][PATCH v1 0/5] cpuidle: menu: Avoid discarding useful information when processing recent idle intervals
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Aboorva Devarajan: Re: [RFT][PATCH v1 0/5] cpuidle: menu: Avoid discarding useful information when processing recent idle intervals</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Aboorva Devarajan" href="/groupie.php?aid=" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2025"> [2025]</a> 聽 <a class="nb" href="/lkml/2025/2"> [Feb]</a> 聽 <a class="nb" href="/lkml/2025/2/26"> [26]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2025/2/26/233" onclick="this.href='/lkml/headers'+'/2025/2/26/233';">[headers]</a>聽 <a href="/lkml/bounce/2025/2/26/233">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2025/2/6/927">First message in thread</a></li><li><a href="/lkml/2025/2/6/927">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/6/923">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/17/790">Christian Loehle</a></li></ul></li><li><a href="/lkml/2025/2/6/924">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/17/866">Christian Loehle</a><ul><li><a href="/lkml/2025/2/17/880">"Rafael J. Wysocki"</a></li></ul></li></ul></li><li><a href="/lkml/2025/2/6/925">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/17/853">Christian Loehle</a></li></ul></li><li><a href="/lkml/2025/2/6/926">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/17/804">Christian Loehle</a></li></ul></li><li><a href="/lkml/2025/2/6/928">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/6/961">Christian Loehle</a></li></ul></li><li><a href="/lkml/2025/2/7/1027">Artem Bityutskiy</a><ul><li><a href="/lkml/2025/2/7/1103">Christian Loehle</a><ul><li><a href="/lkml/2025/2/7/1115">"Rafael J. Wysocki"</a></li></ul></li><li><a href="/lkml/2025/2/7/1157">"Rafael J. Wysocki"</a></li></ul></li><li><a href="/lkml/2025/2/10/922">Christian Loehle</a><ul><li><a href="/lkml/2025/2/10/965">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/10/972">Christian Loehle</a></li></ul></li><li><a href="/lkml/2025/2/18/1941">Christian Loehle</a><ul><li><a href="/lkml/2025/2/19/773">"Rafael J. Wysocki"</a></li></ul></li></ul></li><li><a href="/lkml/2025/2/13/1996">"Doug Smythies"</a><ul><li><a href="/lkml/2025/2/14/1548">"Rafael J. Wysocki"</a><ul><li><a href="/lkml/2025/2/16/278">"Doug Smythies"</a></li></ul></li></ul></li><li><a href="/lkml/2025/2/24/221">Aboorva Devarajan</a><ul><li><a href="/lkml/2025/2/24/240">Aboorva Devarajan</a></li><li><a href="/lkml/2025/2/24/1038">"Rafael J. Wysocki"</a></li><li class="origin"><a href="/lkml/2025/2/26/773">Aboorva Devarajan</a><ul><li><a href="/lkml/2025/2/26/773">Christian Loehle</a></li></ul></li></ul></li></ul></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [RFT][PATCH v1 0/5] cpuidle: menu: Avoid discarding useful information when processing recent idle intervals</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Aboorva Devarajan <></td></tr><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Wed, 26 Feb 2025 10:19:14 +0530</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">On Mon, 2025-02-24 at 11:57 +0530, Aboorva Devarajan wrote:<br />> On Thu, 2025-02-06 at 15:21 +0100, Rafael J. Wysocki wrote:<br />> <br />> <br />> <br />> <br />> So for the entire series:<br />> <br />> Tested-by: Aboorva Devarajan <aboorvad@linux.ibm.com><br />> <br />> I'm also trying a minimal unit fuzz-test with the pre- and post- patched version of the get_typical_interval聽<br />> function to understand this better, will post the results soon.<br />> <br />> <br />In addition to the previous tests, I also reviewed and tested how get_typical_interval<br />predicts the idle duration before and after the patch by mimicking the function in<br />userspace for better unit fuzz testing [1].<br /><br />With the patch get_typical_interval function now produces more predictable values, whereas<br />in the previous implementation it frequently returned UINT_MAX. The behavior with the patch<br />seems to be more reasonable compared to before. <br /><br />Here are the test results <br /><br />1. Low Variance:<br /><br />When the history of CPU idle durations (8 intervals) is relatively uniform with low variance,<br />the predicted idle duration is unchanged between the patched and unpatched versions: <br /><br />| Test Case | Intervals | Before | After | Difference |<br />|-----------|----------------------------------------------|--------|-------|------------|<br />| 1 | 100,105,110,115,120,125,130,135 | 117 | 117 | 0 |<br />| 2 | 200,205,210,215,220,225,230,235 | 217 | 217 | 0 |<br />| 3 | 500,505,510,515,520,525,530,535 | 517 | 517 | 0 |<br />| 4 | 1000,1005,1010,1015,1020,1025,1030,1035 | 1017 | 1017 | 0 |<br /><br /> 2. High Variance<br /><br />For cases with high variance, the nonpatched function returned UINT_MAX,<br /><br />After the patch, the function now returns reasonable values: <br /><br />| Test Case | Intervals | Before | After | Difference |<br />|-----------|--------------------------------------------|-------------|-------|------------------|<br />| 5 | 99,198,297,396,495,594,693,792 | 4294967295 | 594 | -4294966701 |<br />| 6 | 1000,2000,3000,4000,5000,6000,7000,8000 | 4294967295 | 6000 | -4294961295 |<br />| 7 | 40,140,240,340,440,540,640,740 | 4294967295 | 540 | -4294966755 |<br />| 8 | 90,590,1090,1590,2090,2590,3090,3590 | 4294967295 | 2590 | -4294964705 |<br />| 9 | 42,142,242,342,442,542,642,742 | 4294967295 | 542 | -4294966753 |<br />| 10 | 70,570,1070,1570,2070,2570,3070,3570 | 4294967295 | 2570 | -4294964725 |<br />| 11 | 44,144,244,344,444,544,644,744 | 4294967295 | 544 | -4294966751 |<br /><br /> 3. Low-end Outliers <br /><br />The patch removes variance from low-end values as well,<br />Without the patch, the function only filtered high-end outliers, but now it correctly eliminates both<br />high and low ends.<br /><br />| Test Case | Intervals | Before | After | Difference |<br />|-----------|-------------------------------------------|-------------|-------|-------------|<br />| 12 | 1,200,200,250,250,230,220,260 | 4294967295 | 230 | -4294967065 |<br />| 13 | 100000,200,200,250,250,230,220,260 | 230 | 230 | 0 |<br /><br /><br /> 4. As far as I understand, the function only returns UINT_MAX when all values are 0, negative, or the<br />computed average itself is UINT_MAX. <br /><br />| Test Case | Intervals | Before | After | Difference |<br />|-----------|---------------------------------------------|-------------|-------------|------------|<br />| 14 | 4294967295,4294967295,4294967295,4294967295 | 4294967295 | 4294967295 | 0 |<br />| 15 | 0,0,0,0,0,0,0,0 | 4294967295 | 4294967295 | 0 |<br /><br />The updated get_typical_interval function avoids unnecessary UINT_MAX returns, handles both low and high end<br />outliers, and gives more reliable predictions in high-variance cases. It only returns UINT_MAX when absolutely<br />necessary, and this will help in not selecting deeper idle state unless it is needed. So, I'm good with<br />the patch. <br /><br />Refer [2] for more test results.<br /><br />[1] - <a href="https://github.com/AboorvaDevarajan/linux-utils/blob/main/cpuidle/cpuidle-predict-duration/predict_cpuidle_interval.c">https://github.com/AboorvaDevarajan/linux-utils/blob/main/cpuidle/cpuidle-predict-duration/predict_cpuidle_interval.c</a><br />[2] - <a href="https://github.com/AboorvaDevarajan/linux-utils/blob/main/cpuidle/cpuidle-predict-duration/out.predict.csv">https://github.com/AboorvaDevarajan/linux-utils/blob/main/cpuidle/cpuidle-predict-duration/out.predict.csv</a><br /><br /><br />Thanks,<br />Aboorva<br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2025-02-26 05:50 聽聽 [W:0.749 / U:0.399 seconds]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>