From owner-freebsd-net@freebsd.org Mon Jun 20 10:45:43 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85C50A7B7E1 for ; Mon, 20 Jun 2016 10:45:43 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 721F51FA4 for ; Mon, 20 Jun 2016 10:45:43 +0000 (UTC) (envelope-from hps@selasky.org) Received: by mailman.ysv.freebsd.org (Postfix) id 66945A7B7DF; Mon, 20 Jun 2016 10:45:43 +0000 (UTC) Delivered-To: net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65E4CA7B7DD; Mon, 20 Jun 2016 10:45:43 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 295551F9D; Mon, 20 Jun 2016 10:45:42 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 4FC1F1FE023; Mon, 20 Jun 2016 12:45:40 +0200 (CEST) Subject: Re: panic with tcp timers To: Gleb Smirnoff , Julien Charbon References: <20160617045319.GE1076@FreeBSD.org> <1f28844b-b4ea-b544-3892-811f2be327b9@freebsd.org> <20160620073917.GI1076@FreeBSD.org> <1d18d0e2-3e42-cb26-928c-2989d0751884@freebsd.org> <20160620095822.GJ1076@FreeBSD.org> Cc: rrs@FreeBSD.org, net@FreeBSD.org, current@FreeBSD.org From: Hans Petter Selasky Message-ID: <4b5d36b0-a20a-8a1b-b346-8761fbc2e9cf@selasky.org> Date: Mon, 20 Jun 2016 12:49:17 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <20160620095822.GJ1076@FreeBSD.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2016 10:45:43 -0000 On 06/20/16 11:58, Gleb Smirnoff wrote: > J> callout_stop() should return 0 when the callout is currently being > J> serviced and indeed unstoppable > J> https://reviews.freebsd.org/differential/changeset/?ref=62513&whitespace=ignore-most > > What are the old paths impacted? > Hi Gleb, Digging through my e-mail archive rephrasing myself and comments about: https://reviews.freebsd.org/D3078 There are two kinds of callouts. So-called MPSAFE callouts which doesn't have a mutex associated with it, and non-MPSAFE which do. When you are associating a mutex with a callout, callout_stop() will _always_ cancel the callback even if it is pending, and this should be reflected by the return value. Your proposed changes will break that ??? The changes in D3078 didn't take into account "use_lock" at least, and so the return values for the non-MPSAFE case becomes incorrect. > Hi, > > I think this patch is incomplete and can break the return value for non-MPSAFE callouts. I think the correct statement should check the value of "use_lock" too: > > not_running = !(cc_exec_curr(cc, direct) == c && use_lock == 0); > > Because if the callback process waits for lock "c_lock" in the callback process then we have above "cc_exec_curr(cc, direct) == c" is satisfied too, and non-MPSAFE callouts are always cancelable, via cc_exec_cancel(cc, direct) = true; --HPS