From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id F25CB70310; Thu, 4 Mar 2021 00:43:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F25CB70310 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614807788; bh=hKDqvtzh++ovRXCVXAx0u5UMlkugGXCFpwCO7JdmQ7I=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MP38jsdZktAuMpCHivpokLi2tPdSvEXpZaPMss+t4l57NFidfkZvVhLkQ2l3eHfME oaZI1Eh1WsILYxTVaK1EvOtHvBNLb3dj1k+VsHA1pffyNLO9+LxEUz6uF0VnaOJx9W uIVe+XVc+00QaTzqeHVMULmrU+9UOH04ewmbi3L4= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 3A68B70310 for ; Thu, 4 Mar 2021 00:43:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3A68B70310 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lHZGr-0002dt-EZ; Thu, 04 Mar 2021 00:43:05 +0300 To: Serge Petrenko , Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org References: <2ba579eef6f31d17a1670a6eaf31492366963ad9.1614637331.git.v.shpilevoy@tarantool.org> <3102df69-ed4b-f5e6-daca-8afb1aef29c9@tarantool.org> Message-ID: <9456f73b-a8f5-b590-d430-f4b40cb5602f@tarantool.org> Date: Wed, 3 Mar 2021 22:43:04 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <3102df69-ed4b-f5e6-daca-8afb1aef29c9@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92A98208ECBDD29F5D8C0A06ED169F0586A18EBFAC8707E15182A05F538085040B2750129168B971C13479701762C8F366D1F608FF27EA91A8030E9B9104C5310 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BAE5222749FC9020C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE782A779A89F7D69B28F08D7030A58E5ADC58D69EE07B14084C6CDE5D1141D2B1C596CEEFD57BEFE31084FA0C625B1D208B3138650268F2F019FA2833FD35BB23D9E625A9149C048EE1E561CDFBCA1751FF6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F790063773DCDF0198120BE8389733CBF5DBD5E9B5C8C57E37DE458BD96E472CDF7238E04AD6D5ED66289B5278DA827A17800CE74ABCC139FF3F849B67F23339F89546C5A8DF7F3B2552694A6FED454B719173D6725E5C173C3A84C33EA60AFABC492F3035872C767BF85DA2F004C906525384306FED454B719173D6462275124DF8B9C934F12F0C005D1A85E5BFE6E7EFDEDCD789D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5AD9AC8ABC28D7B21D0E3B9B056720EB321B7179E7069EAFFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343F22CE0A71FDB37E1FD6A2BCA7B8BFD2E7D7EB03DF15761BAC2B36189BA6E0CD747A113E922193101D7E09C32AA3244CBF8AC61144DE92B25E174155833C1D4B63871F383B54D9B3FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojSsmoOoMLSh3nXGcGht7/kg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382233002C25B00FCD78D40D38DBBFC211133841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/1] fiber_cond: remove rlist_shift usages X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 02.03.2021 10:04, Serge Petrenko wrote: > > > 02.03.2021 10:37, Cyrill Gorcunov пишет: >> On Mon, Mar 01, 2021 at 11:23:13PM +0100, Vladislav Shpilevoy wrote: >>> @@ -94,7 +94,7 @@ fiber_cond_broadcast(struct fiber_cond *e) >>>   { >>>       while (! rlist_empty(&e->waiters)) { >>>           struct fiber *f; >>> -        f = rlist_shift_entry(&e->waiters, struct fiber, state); >>> +        f = rlist_first_entry(&e->waiters, struct fiber, state); >>>           fiber_wakeup(f); >>>       } >>>   } >> The fiber_wakeup ignores >> >>     if (f->flags & (FIBER_IS_READY | FIBER_IS_DEAD)) >>         return; >> >> can't we hit the situation where fiber_cond_broadcast called with >> dead fiber so that it won't be deleted from the list with new code? > > Good point, I never thought of this. > > Once a fiber dies, it's removed from any list that could wake it up: > >         /* reset pending wakeups */ >         rlist_del(&fiber->state); > > And FIBER_IS_READY is set only from fiber_wakeup() to guard from > concurrent wake-ups. So the patch must be fine indeed. Moreover, a fiber can't be dead and be in fiber_cond. Fiber dies only after it returns from its main function. Until then it can be at most CANCELLED, which does not affect the yields. You still can sleep, wait, yield, be woken up, and so on.