From owner-freebsd-current@freebsd.org Tue Jun 7 02:46:21 2016 Return-Path: Delivered-To: freebsd-current@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 8881CB6D342 for ; Tue, 7 Jun 2016 02:46:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EBBD145B; Tue, 7 Jun 2016 02:46:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u572kAqW016192 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 7 Jun 2016 05:46:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u572kAqW016192 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u572kAVD016190; Tue, 7 Jun 2016 05:46:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 7 Jun 2016 05:46:10 +0300 From: Konstantin Belousov To: Mark Johnston Cc: freebsd-current@FreeBSD.org Subject: Re: thread suspension when dumping core Message-ID: <20160607024610.GI38613@kib.kiev.ua> References: <20160604022347.GA1096@wkstn-mjohnston.west.isilon.com> <20160604093236.GA38613@kib.kiev.ua> <20160606171311.GC10101@wkstn-mjohnston.west.isilon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160606171311.GC10101@wkstn-mjohnston.west.isilon.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 07 Jun 2016 02:46:21 -0000 On Mon, Jun 06, 2016 at 10:13:11AM -0700, Mark Johnston wrote: > On Sat, Jun 04, 2016 at 12:32:36PM +0300, Konstantin Belousov wrote: > > Does your fs both set TDF_SBDRY and call lf_advlock()/lf_advlockasync() ? > > It doesn't. This code belongs to a general framework for distributed FS > locks; in this particular case, the application was using it to acquire > a custom advisory lock. What statement was not true: that your code sets TDF_SBDRY, or that the lf_advlock() function was called ? > > > This cannot work, regardless of the mode of single-threading. TDF_SBDRY > > makes such sleep non-interruptible by any single-threading request, on > > the promise that the thread owns some resources (typically vnode locks). > > I.e. changing the mode would not help. > > I'm a bit confused by this. How does TDF_SBDRY prevent thread_single() > from waking up the thread? The sleepq_abort() call is only elided in the > SINGLE_ALLPROC case, so in other cases, I think we will still interrupt > the sleep. Thus, since thread_suspend_check() is only invoked prior to > going to sleep, the application I referred to must have attempted to > single-thread the process before the thread in question went to sleep. It does not prevent the wakeup, sorry. What I should have said, more precisely, is that thread_suspend_check() call before the thread is goes to sleep, is nop in case of TDF_SBDRY flag was set. > > > > > I see two reasons to use SINGLE_NO_EXIT for coredumping. It allows > > coredump writer to record more exact state of the process into the notes. > > > > Another one is that SINGLE_NO_EXIT is generally faster and more > > reliable than SINGLE_BOUNDARY. Some states are already good enough for > > SINGLE_NO_EXIT, while require more work to get into SINGLE_BOUNDARY. In > > other words, core dump write starts earlier. > > > > It might be not very significant reasons. > > > > From what I see in the code, our NFS client has similar issue of calling > > lf_advlock() with TDF_SBDRY set. Below is the patch to fix that. > > Similar bug existed in our fifofs, see r277321. > > Thanks. It may be that a similar fix is appropriate in our locking code, > but I'll have to spend more time reading it. Still, I am confused now as well. If you can catch the process in that state, where a thread is sleeping while single-threading request cannot make the progress, I would like to see the struct thread and struct proc printouts. Esp. the thread flags are interesting. Thanks.