Hi All,<br><br>I appreciate if somebody can tell me why spinlock and semaphore are utilized to protect work queue in drbd worker thread. I have some performance issue with regard to the use of this semaphore. Specifically, <span style="background-color: rgb(255, 255, 0);">down_interruptible takes too long to be waked up. </span>Here is the detail:<br>
<br>In drbd_worker.c, function int drbd_worker(struct drbd_thread *thi).<br><br>int drbd_worker(struct drbd_thread *thi)<br>{<br>....<br> if (<span style="background-color: rgb(255, 255, 0);">down_trylock(&mdev->data.work.s</span>)) {<br>
mutex_lock(&mdev->data.mutex);<br> if (mdev->data.socket && !mdev->net_conf->no_cork)<br> drbd_tcp_uncork(mdev->data.socket);<br>
mutex_unlock(&mdev->data.mutex);<br><br> intr = <span style="background-color: rgb(255, 255, 0);">down_interruptible(&mdev->data.work.s);</span><br><br> mutex_lock(&mdev->data.mutex);<br>
if (mdev->data.socket && !mdev->net_conf->no_cork)<br> drbd_tcp_cork(mdev->data.socket);<br> mutex_unlock(&mdev->data.mutex);<br>
}<br><br>....<br> w = NULL;<br> spin_lock_irq(&mdev->data.work.q_lock);<br> ERR_IF(list_empty(&mdev->data.work.q)) {<br> <span style="background-color: rgb(255, 255, 0);"> /* something terribly wrong in our logic.</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> * we were able to down() the semaphore,</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> * but the list is empty... doh.</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> *</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> * what is the best thing to do now?</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> * try again from scratch, restarting the receiver,</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> * asender, whatnot? could break even more ugly,</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> * e.g. when we are primary, but no good local data.</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> *</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> * I'll try to get away just starting over this loop.</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> */</span><br>
spin_unlock_irq(&mdev->data.work.q_lock);<br> continue;<br> }<br>...<br>}<br><br>I tried to get rid of semaphore in above as well as in drbd_queue_work in drbd_ini.h. Somehow, the code breaks ugly. I guess I still don`t get the design rational here. Any help is appreciated.<br>
<br>Thanks<br>Ben<br clear="all">Commit yourself to constant self-improvement<br>