<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2826/">https://reviewboard.asterisk.org/r/2826/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 21st, 2013, 4:11 a.m. UTC, <b>rmudgett</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2826/diff/3/?file=45654#file45654line146" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/main/lock.c</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">int __ast_pthread_mutex_init(int tracking, const char *filename, int lineno, const char *func,</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">87</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">        </span><span class="tb">        </span><span class="n">ast_reentrancy<span class="hl">_init</span></span><span class="p">(</span><span class="o">&</span><span class="n">t</span><span class="o">-></span><span class="n">track</span><span class="p">);</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">146</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">        </span><span class="tb">        </span><span class="n">as<span class="hl">t_ge</span>t_reentrancy</span><span class="p">(</span><span class="o">&</span><span class="n">t</span><span class="o">-></span><span class="n">track</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Lock tracking initialization must be deferred until the mutex or rwlock is actually used. Otherwise, it is no different than putting the tracking memory into the ast_mutex_t struct.
Lock tracking used to be part of the ast_mutex_t until it was discovered that chan_iax was using 100M bytes just being loaded. chan_iax has a 32k element lock array that it initializes when it loads.</pre>
</blockquote>
<p>On September 23rd, 2013, 2:16 p.m. UTC, <b>David Lee</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">That's the whole problem, though. There's no way to synchronize
initialization on first use. Multiple threads trying to simultaneously
acquire a lock with uninitialized lock tracking could result in double
initialization.
Maybe it would be better if DEBUG_THREADS dramatically reduced the
size of that array in chan_iax.</pre>
</blockquote>
<p>On September 23rd, 2013, 8:10 p.m. UTC, <b>rmudgett</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Reducing the size of that array is not an option. The size of that array is the range of call numbers chan_iax2 will accept for calls.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">It sounds like we're trading off correctness for lower memory footprint.
If you're running with DEBUG_THREADS, the amount of memory you're consuming is generally the least of your concerns - or at least should be.</pre>
<br />
<p>- Matt</p>
<br />
<p>On September 5th, 2013, 6:24 p.m. UTC, David Lee wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers and Matt Jordan.</div>
<div>By David Lee.</div>
<p style="color: grey;"><i>Updated Sept. 5, 2013, 6:24 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-19463">ASTERISK-19463</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch corrects a consistency issue with debug threads that I
noticed while fixing ASTERISK-22455.
The initialization of a mutex's lock tracking structure was not
protected in a critical section. This is fine for any mutex that is
explicitly initialized, but a static mutex may have its lock tracking
double-initialized if multiple threads attempt the first lock
simultaneously.
This patch creates a global mutex to properly serialize the
initialization of the lock tracking structure for a mutex. It also
changes lock.c to properly handle allocation failures of the lock
tracking structure.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I propose we setup Bamboo to run the TestSuite with DEBUG_THREADS
enabled on this branch nightly for a few weeks.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/include/asterisk/lock.h <span style="color: grey">(398421)</span></li>
<li>/branches/1.8/main/lock.c <span style="color: grey">(398421)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2826/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>