CINXE.COM

LKML: Vlastimil Babka: Re: [PATCH] mm, mmap: fix vma_merge() case 7 with vma_ops->close

<?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: Vlastimil Babka: Re: [PATCH] mm, mmap: fix vma_merge() case 7 with vma_ops-&gt;close</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 Vlastimil Babka" 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/2024"> [2024]</a> 聽 <a class="nb" href="/lkml/2024/2"> [Feb]</a> 聽 <a class="nb" href="/lkml/2024/2/22"> [22]</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/2024/2/22/1489" onclick="this.href='/lkml/headers'+'/2024/2/22/1489';">[headers]</a>聽 <a href="/lkml/bounce/2024/2/22/1489">[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/2024/2/22/1070">First message in thread</a></li><li><a href="/lkml/2024/2/22/1332">"Liam R. Howlett"</a><ul><li><a href="/lkml/2024/2/22/1473">Vlastimil Babka</a><ul><li class="origin"><a href="">Vlastimil Babka</a></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">Date</td><td class="rp" itemprop="datePublished">Thu, 22 Feb 2024 22:32:12 +0100</td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH] mm, mmap: fix vma_merge() case 7 with vma_ops-&gt;close</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Vlastimil Babka &lt;&gt;</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">On 2/22/24 22:19, Vlastimil Babka wrote:<br />&gt; On 2/22/24 20:27, Liam R. Howlett wrote:<br />&gt;&gt; * Liam R. Howlett &lt;Liam.Howlett&#64;Oracle.com&gt; [240222 13:56]:<br />&gt;&gt;&gt; * Vlastimil Babka &lt;vbabka&#64;suse.cz&gt; [240222 11:56]:<br />&gt;&gt;&gt; This separates the check for potentially merging previous to a later<br />&gt;&gt;&gt; failure case. Would it be better to check:<br />&gt;&gt;&gt; if (curr &amp;&amp; curr-&gt;vm_ops &amp;&amp; curr-&gt;vm_ops-&gt;close)<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; and not set merge_prev = true, ie we cannot merge with the predecessor?<br />&gt; <br />&gt; Good suggestion, thanks!<br /><br />Or actually as Lorenzo informed me, it would affect case 5 as well and we<br />don't want that. And special casing 5 vs 7 that early would be ugly again.<br /><br />So I'll just do the code dedup Lorenzo suggested...<br /><br />&gt;&gt;&gt; That way we would exit as merge_prev == false.<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; We would have the added benefit of not having to look at merge_prev &amp;<br />&gt;&gt;&gt; merge_next case with this vm_ops-&gt;close in mind (case 1 and 6).. because<br />&gt;&gt;&gt; I'm pretty sure we can currently get to case 6 in this way:<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; merge_prev = true<br />&gt;&gt;&gt; check for merge_next.. can_vma_merge_before(next...);<br />&gt;&gt;&gt; is_mergeable_vma(next.... , true);<br />&gt;&gt;&gt; if (true &amp;&amp; next-&gt;vm_ops &amp;&amp; next-&gt;vm_ops-&gt;close) /* Fine for next.. */<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; Remove curr by case 6 without checking curr-&gt;vm_ops &amp;&amp;<br />&gt;&gt;&gt; curr-&gt;vm_ops-&gt;close<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; If I am correct, then are we blaming the right commit?<br />&gt; <br />&gt; It was bisected with no nondeterminism in the test, so yeah.<br />&gt; <br />&gt;&gt; I am not correct.<br />&gt;&gt; The file check will ensure the same ops, so the file and ops must match.<br />&gt;&gt; As long as both are checked on one VMA then it will work as required.<br />&gt; <br />&gt; Right, otherwise we would have bigger issues even before the buggy commit,<br />&gt; we were never checking curr's vma_ops before.<br />&gt; <br />&gt;&gt;&gt; <br />&gt;&gt;&gt; Perhaps we should just fail earlier when we find a curr with the close<br />&gt;&gt;&gt; ops?<br />&gt;&gt; <br />&gt;&gt; I'd rather fail earlier, but it's not a big deal.<br />&gt; <br />&gt; Your suggestion will indeed result in a nicer and more obvious code, so will<br />&gt; do, thanks!<br />&gt; <br />&gt;&gt;&gt; <br />&gt;&gt;&gt; &gt; } else { /* case 5 */<br />&gt;&gt;&gt; &gt; + err = dup_anon_vma(prev, curr, &amp;anon_dup);<br />&gt;&gt;&gt; &gt; adjust = curr;<br />&gt;&gt;&gt; &gt; adj_start = (end - curr-&gt;vm_start);<br />&gt;&gt;&gt; &gt; }<br />&gt;&gt;&gt; &gt; -- <br />&gt;&gt;&gt; &gt; 2.43.1<br />&gt;&gt;&gt; &gt; <br />&gt; <br /><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: 2024-05-27 15:17 聽聽 [from the cache]<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>

Pages: 1 2 3 4 5 6 7 8 9 10