From owner-freebsd-current@freebsd.org Tue Jun 7 16:02:02 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 8C20FB6EFC0 for ; Tue, 7 Jun 2016 16:02:02 +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 31E991A42; Tue, 7 Jun 2016 16:02:02 +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 u57G1twA012318 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 7 Jun 2016 19:01:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u57G1twA012318 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u57G1tp7012317; Tue, 7 Jun 2016 19:01:55 +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 19:01:55 +0300 From: Konstantin Belousov To: Jilles Tjoelker Cc: Mark Johnston , freebsd-current@FreeBSD.org, cem@FreeBSD.org Subject: Re: thread suspension when dumping core Message-ID: <20160607160155.GP38613@kib.kiev.ua> References: <20160604022347.GA1096@wkstn-mjohnston.west.isilon.com> <20160604093236.GA38613@kib.kiev.ua> <20160606171311.GC10101@wkstn-mjohnston.west.isilon.com> <20160607024610.GI38613@kib.kiev.ua> <20160607041741.GA29017@wkstn-mjohnston.west.isilon.com> <20160607042956.GM38613@kib.kiev.ua> <20160607142452.GA48251@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160607142452.GA48251@stack.nl> 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 16:02:02 -0000 On Tue, Jun 07, 2016 at 04:24:53PM +0200, Jilles Tjoelker wrote: > On Tue, Jun 07, 2016 at 07:29:56AM +0300, Konstantin Belousov wrote: > > This looks as if we should not ignore suspension requests in > > thread_suspend_check() completely in TDF_SBDRY case, but return either > > EINTR or ERESTART (most likely ERESTART). Note that the goal of > > TDF_SBDRY is to avoid suspending in the protected region, not to make an > > impression that the suspension does not occur at all. > > This looks like it would revert r246417 and re-introduce the bug fixed > by it (unexpected [EINTR] and short reads/writes after stop signals). Well, the patch returns ERESTART and not EINTR, so the syscall should be retried after all the unwinding. > > After r246417, TDF_SBDRY is intended for sleeps that occur while holding > resources such as vnode locks and are normally short but should be > interruptible by fatal signals because they may occasionally be > indefinitely long (such as a non-responsive NFS server). > > It looks like yet another kind of sleep may be required, since advisory > locks still hold some filesystem resources across the sleep (though not > vnode locks). I do not think that adv locks enter sleep with any resource held which would block other threads. But I agree with the statement because the lock might be granted and then the stopped thread would appear to own the blocking resource. > > We then have four kinds: > > * uninterruptible by signals, ignores stops (default) > * interruptible by signals, ignores stops (current TDF_SBDRY with > PCATCH) > * interruptible by signals, freezes in place on stops (avoids > unexpected short I/O) (current PCATCH, otherwise) > * interruptible by signals, fails with [ERESTART] on stops (avoids > holding resources across a stop) (new) > > The new kind of sleep would fail with [ERESTART] only for stops, since > [EINTR] should only be returned if a signal handler was called. There > cannot be a signal handler since a SIGTSTP/SIGTTIN/SIGTTOU signal with a > handler does not stop the process. > And where would this new kind of sleep used ? The advlock sleep is the one place. Does fifo sleep for reader or writer on open require this kind of handling (IMO no) ? I think this can be relatively easily implemented with either a flag for XXXsleep(9) (my older style of PBDRY) or using only the thread flag (jhb' newer TDF_SBDRY approach). Probably the later should be used, for consistency and easier marking of larger blocks of code.