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->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->close</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Vlastimil Babka <></td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">On 2/22/24 22:19, Vlastimil Babka wrote:<br />> On 2/22/24 20:27, Liam R. Howlett wrote:<br />>> * Liam R. Howlett <Liam.Howlett@Oracle.com> [240222 13:56]:<br />>>> * Vlastimil Babka <vbabka@suse.cz> [240222 11:56]:<br />>>> This separates the check for potentially merging previous to a later<br />>>> failure case. Would it be better to check:<br />>>> if (curr && curr->vm_ops && curr->vm_ops->close)<br />>>> <br />>>> and not set merge_prev = true, ie we cannot merge with the predecessor?<br />> <br />> 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 />>>> That way we would exit as merge_prev == false.<br />>>> <br />>>> We would have the added benefit of not having to look at merge_prev &<br />>>> merge_next case with this vm_ops->close in mind (case 1 and 6).. because<br />>>> I'm pretty sure we can currently get to case 6 in this way:<br />>>> <br />>>> merge_prev = true<br />>>> check for merge_next.. can_vma_merge_before(next...);<br />>>> is_mergeable_vma(next.... , true);<br />>>> if (true && next->vm_ops && next->vm_ops->close) /* Fine for next.. */<br />>>> <br />>>> Remove curr by case 6 without checking curr->vm_ops &&<br />>>> curr->vm_ops->close<br />>>> <br />>>> If I am correct, then are we blaming the right commit?<br />> <br />> It was bisected with no nondeterminism in the test, so yeah.<br />> <br />>> I am not correct.<br />>> The file check will ensure the same ops, so the file and ops must match.<br />>> As long as both are checked on one VMA then it will work as required.<br />> <br />> Right, otherwise we would have bigger issues even before the buggy commit,<br />> we were never checking curr's vma_ops before.<br />> <br />>>> <br />>>> Perhaps we should just fail earlier when we find a curr with the close<br />>>> ops?<br />>> <br />>> I'd rather fail earlier, but it's not a big deal.<br />> <br />> Your suggestion will indeed result in a nicer and more obvious code, so will<br />> do, thanks!<br />> <br />>>> <br />>>> > } else { /* case 5 */<br />>>> > + err = dup_anon_vma(prev, curr, &anon_dup);<br />>>> > adjust = curr;<br />>>> > adj_start = (end - curr->vm_start);<br />>>> > }<br />>>> > -- <br />>>> > 2.43.1<br />>>> > <br />> <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>