CINXE.COM

LKML: Linus Torvalds: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation

<?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: Linus Torvalds: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation</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 Linus Torvalds" href="/groupie.php?aid=1" /><!--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/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/12"> [Dec]</a> 聽 <a class="nb" href="/lkml/2005/12/15"> [15]</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/2005/12/15/286" onclick="this.href='/lkml/headers'+'/2005/12/15/286';">[headers]</a>聽 <a href="/lkml/bounce/2005/12/15/286">[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/2005/12/15/149">First message in thread</a></li><li><a href="/lkml/2005/12/15/201">Linus Torvalds</a><ul><li><a href="/lkml/2005/12/15/216">Erik Mouw</a><ul><li><a href="/lkml/2005/12/15/224">(Dick Streefland)</a></li><li><a href="/lkml/2005/12/16/61">Erik Mouw</a><ul><li><a href="/lkml/2005/12/17/22">Sander</a><ul><li><a href="/lkml/2005/12/17/34">Douglas McNaught</a></li><li><a href="/lkml/2005/12/19/34">Erik Mouw</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2005/12/15/269">Nikita Danilov</a></li><li><a href="/lkml/2005/12/15/274"> linux&#64;horizon ...</a><ul><li class="origin"><a href="/lkml/2005/12/15/422">Linus Torvalds</a><ul><li><a href="/lkml/2005/12/15/422"> linux&#64;horizon ...</a></li></ul></li><li><a href="/lkml/2005/12/15/315">Steven Rostedt</a></li></ul></li><li><a href="/lkml/2005/12/15/304">Steven Rostedt</a></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, 15 Dec 2005 11:52:05 -0800 (PST)</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Linus Torvalds &lt;&gt;</td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody"><br /><br />On Thu, 15 Dec 2005, linux&#64;horizon.com wrote:<br />&gt; <br />&gt; Huh? I thought *you* were violently unhappy with the idea of naming<br />&gt; mutex acquire and release down() and up(), and your e-mail is an example<br />&gt; of this unhapiness.<br /><br />Ahh, I thought you were considering naming unhappiness to be a reason<br />_for_ the mutex change.<br /><br />down() and up() aren't the traditional names for the operations, P()/V()<br />are, and I thought you were arguing that some people might dislike the<br />_current_ naming.<br /><br />&gt; There haven't been problems with the semaphore *implementation*, but<br />&gt; people screw up and deadlock themselves often enough. I sure remember<br />&gt; double-acquire lockups. Forgive me if I don't grep the archives, but<br />&gt; I remember people showing code paths that led to them.<br /><br />Double aquires certainly occasionally happen, but they are (assuming it's <br />a real double aquire, and not a race due to lock ordering) easy to see, <br />since it just hangs the process and you get a traceback and find it.<br /><br />But mutexes don't help either. A mutex will hang exactly the same way, <br />with exactly the same behaviour, and aren't any easier to debug (as <br />mentioned, a hung semaphore isn't exactly hard to debug).<br /><br />Or maybe you're talking about a _recursive_ mutex, which is something that <br />actually has totally different semantics. We've discussed adding them, but <br />pretty much every time it was the result of some really really bad locking <br />design, so at least so far we've instead decided to bite the bullet and <br />fix the locking.<br /><br />So yes, recursive mutexes can be easier to use, but they really do allow <br />(and thus indirectly encourage) bad locking. So I'm not convinced we want <br />one.<br /><br />&gt; But all of this requires that a lock have an identifiable owner, which<br />&gt; is something hat a mutex has and a semaphore fundamentally doesn't.<br /><br />Actually, we've certainly had semaphore debugging patches which consider <br />the last person who successfully got a semaphore to be the "owner".<br /><br />Sure, it's not well-defined for the generic semaphore case, but so what? <br />In the generic case, you can't use mutexes anyway. For _debugging_ <br />ownership as in "who got this lock last" is still useful. I know I've <br />cooked up trivial patches to do that when I was trying to figure out a <br />lock ordering bug.<br /><br />Google is your friend. Just try "semaphore owner debug", and the #2 hit is <br />a patch that does exactly that for Linux.<br /><br />&gt; I don't care what it's *called*. I care that we have stronger<br />&gt; conditions that we can test for correctness.<br /><br />Hey, if so, please don't encourage the current patch. <br /><br />We can certainly add a new lockign mechanism, I'm just not at all <br />convinced that it's warranted. I certainly disagree with you that using <br />semaphores would somehow be less easy to test for correctness.<br /><br /> Linus<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo&#64;vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><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: 2009-11-18 23:46 聽聽 [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