From owner-freebsd-current@freebsd.org Wed Oct 9 01:50:05 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C29313D26B for ; Wed, 9 Oct 2019 01:50:05 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 46nxx92nsRz3HpZ for ; Wed, 9 Oct 2019 01:50:05 +0000 (UTC) (envelope-from julian@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 5DF1613D26A; Wed, 9 Oct 2019 01:50:05 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5DADF13D269 for ; Wed, 9 Oct 2019 01:50:05 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 46nxx84jDMz3HpY for ; Wed, 9 Oct 2019 01:50:04 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (c-73-225-95-104.hsd1.wa.comcast.net [73.225.95.104]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id x991o1C7007785 (version=TLSv1.2 cipher=AES128-SHA bits=128 verify=NO); Tue, 8 Oct 2019 18:50:02 -0700 (PDT) (envelope-from julian@freebsd.org) Subject: Re: panic: Assertion in_epoch(net_epoch_preempt) failed at ... src/sys/net/if.c:3694 To: Ryan Stone Cc: FreeBSD Current References: <20191008121519.GS1263@albert.catwhisker.org> From: Julian Elischer Message-ID: Date: Tue, 8 Oct 2019 18:49:56 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Rspamd-Queue-Id: 46nxx84jDMz3HpY X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.93 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.93)[-0.931,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:36236, ipnet:204.109.60.0/22, country:US] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2019 01:50:05 -0000 On 10/8/19 4:22 PM, Ryan Stone wrote: > I haven't found any good references on the subject, but here's my understanding: > > - epoch_enter() and epoch_exit() are very inexpensive operations > (cheaper than mtx, rw_lock or rm_lock operations) that are use to mark > read-only critical sections > - epoch_wait() guarantees that no threads that were in the critical > section when it was first called are still in the critical section > when it completes > > With this guarantee, you can safely destroy an object with the > following procedure: > > 1. Atomically remove all global pointers to the object (e.g. remove it > from any lists that the critical sections might look it up in). This > must be done atomically because read-only threads can be concurrently > running in the critical section. This guarantees that no more threads > can get a pointer to it. > 2. Call epoch_wait() to drain all threads that already held pointers > to it before step 1. > 3. You now hold the only pointer to the object, so you are free to > destroy it as you please. Ok thanks. Gottit.  thanks for the description.