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 8E1546EC5F; Tue, 2 Mar 2021 12:04:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8E1546EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614675889; bh=N8NnjpRsEA9LCT3blLfzPqf2TnJn/PTk6J33Mai9Lk8=; 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=Kzc4MIoD8k62bBPhd23hIMhzjL1YW265oh5yWOqamyUgD7ROPRZrpnsGXvdbD8jYB 1xl6cLtwq9JsfqBZb6HvS0Zu/zPprF1gpENPlBt7s6gVOI7ADGuik9Xv3M6YX4U8an ik3vBRYkhVuVpgTTxjLyGDZUDDKQ7a6rwCUP5HGA= Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (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 5E5FC6EC5F for ; Tue, 2 Mar 2021 12:04:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5E5FC6EC5F Received: by smtp17.mail.ru with esmtpa (envelope-from ) id 1lH0xT-0000We-Lw; Tue, 02 Mar 2021 12:04:48 +0300 To: Cyrill Gorcunov , Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org References: <2ba579eef6f31d17a1670a6eaf31492366963ad9.1614637331.git.v.shpilevoy@tarantool.org> Message-ID: <3102df69-ed4b-f5e6-daca-8afb1aef29c9@tarantool.org> Date: Tue, 2 Mar 2021 12:04:47 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92A98208ECBDD29F592DFB44E0F725E61F2319814AA890CAA182A05F53808504068513426E625D133921C5B10EAD51963012034A222605FF456BE34EF3FAA889F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE706EA9E10470DC775EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063781E06E36B00F36668638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC2EC80735919255E1714272920F0CD7C763923A902D7DFCC5389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C06030C3405640F6718941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64AAE2D1698E8717BCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224967DACB3AE4B8FF8576E601842F6C81A12EF20D2F80756B5F7E9C4E3C761E06A776E601842F6C81A127C277FBC8AE2E8B01A39B917E09DD943AA81AA40904B5D9DBF02ECDB25306B2B25CBF701D1BE8734AD6D5ED66289B5278DA827A17800CE7BB1D8AFE8C29F51C67F23339F89546C5A8DF7F3B2552694A6FED454B719173D6725E5C173C3A84C3323A1F0A62E9D12F35872C767BF85DA2F004C906525384306FED454B719173D6462275124DF8B9C9DE2850DD75B2526BE5BFE6E7EFDEDCD789D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5A5642C713032D58FC00B4215E25B8577CCFE59AD43974FF0D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F1257DC9690AEBA17F65AD2A3DD21E657E7D640B513DCF979040E172C68E9CD01DD111031B619C251D7E09C32AA3244C91757048B9972320024C257941A89634E8FBBEFAE1C4874CFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnpKwxR6GFbtisx38rD1szg== X-Mailru-Sender: 583F1D7ACE8F49BDF0EA4664CAF0825D7317F277F61641CA580CF523037072181D2094D3B1F579C3823C4E0A9438D55D74690CA6451351EDEC462FDC9CAD1E11B969B486931C0B990F27244EEAA5B9A5AE208404248635DF 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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. Vlad, LGTM. > > Actually looking into fiber_loop code I see > > static void > fiber_loop(MAYBE_UNUSED void *data) > { > ... > fiber->flags |= FIBER_IS_DEAD; > while (! rlist_empty(&fiber->wake)) { > struct fiber *f; > f = rlist_shift_entry(&fiber->wake, struct fiber, > state); > assert(f != fiber); > fiber_wakeup(f); > } > > so it should be safe with your patch, but just to make sure I didn't > miss something obvious. -- Serge Petrenko