From owner-freebsd-current@freebsd.org  Wed Jun  8 13:35:19 2016
Return-Path: <owner-freebsd-current@freebsd.org>
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 6C101B6F99B
 for <freebsd-current@mailman.ysv.freebsd.org>;
 Wed,  8 Jun 2016 13:35:19 +0000 (UTC)
 (envelope-from markjdb@gmail.com)
Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com
 [IPv6:2a00:1450:400c:c09::22a])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 014E41F21;
 Wed,  8 Jun 2016 13:35:19 +0000 (UTC)
 (envelope-from markjdb@gmail.com)
Received: by mail-wm0-x22a.google.com with SMTP id r5so15380757wmr.0;
 Wed, 08 Jun 2016 06:35:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=sender:date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:in-reply-to:user-agent;
 bh=InAasyz34CnnaGAPOHHSZ9CAAIe7+oIujU+JpRKGa0A=;
 b=YYkx61AD/4cDWMiluIh1c8uFXJSTjhdF079AYnjy3+r49QGeFp68JM6e2P8Hm4Ck7W
 6Yy6sp/kIed4amudmXOHFSJG/eIOzvfFl5tYt8fbgZiQZ6nh1vqjU9QJlqXE9FMC3y1s
 w4xDUW8ER7ybpcx1Vspg9u7EL3I38g8gEAomJr8iW4x/NqdfJZUnxJHi31eG+OnMP7Nx
 4dVZWadlArTG/GVja3IIMXY3C2aEsapJWEbqWuBNVshjlH4ck6OlmZRb8/kNn2jNQJ82
 1TQ9BmsmpJk/12IhJa3KaEzczBnnmQI7P5V+LhbdBPTL6MJPdPSfiSCV80o7TQnS7Dgq
 XY4Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:sender:date:from:to:cc:subject:message-id
 :references:mime-version:content-disposition:in-reply-to:user-agent;
 bh=InAasyz34CnnaGAPOHHSZ9CAAIe7+oIujU+JpRKGa0A=;
 b=K1tDTxNCbTeEFN6SdTg8GC3cTOBhEPhB+GSwj1Vg1FbMZ8kH88OyyC/p2N0RhLJQ61
 3C4AtHzzEmwFUY5CxykLMRMQIrtkobDkg4rWHzXzJeNhTqnGqDw2IUVzrQQRB3lKvkIF
 6BIrP9ETf1grULsoaLp0xL63pPerqO11ANbtQcEPPca5FhgIM9WqGsMKkvmw0tgdLWMt
 yCvZCAfkneIolZscFqSXcAapBa2GbdA7fJPo/8HB+Z1QqtbTTSLQuI65Sq2TH+qsBezz
 XsrBtkcBwX1Mkv3Nm4lW3e8H5G5khtGQUxZRjbaaz98cgWBI2/UmYJVGyWgGsxb71wA7
 7uZQ==
X-Gm-Message-State: ALyK8tKejA9ZyIwVmj/fKSJFhEK3kUKsz0s/0ioTH9K+7tOHiNqMJdoItQHMI81LRvT0LQ==
X-Received: by 10.28.131.197 with SMTP id f188mr8421300wmd.12.1465392916773;
 Wed, 08 Jun 2016 06:35:16 -0700 (PDT)
Received: from charmander ([137.122.64.8])
 by smtp.gmail.com with ESMTPSA id o76sm2218978wme.0.2016.06.08.06.35.14
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 08 Jun 2016 06:35:15 -0700 (PDT)
Sender: Mark Johnston <markjdb@gmail.com>
Date: Wed, 8 Jun 2016 06:35:08 -0700
From: Mark Johnston <markj@FreeBSD.org>
To: Konstantin Belousov <kostikbel@gmail.com>
Cc: Jilles Tjoelker <jilles@stack.nl>, freebsd-current@FreeBSD.org,
 cem@FreeBSD.org
Subject: Re: thread suspension when dumping core
Message-ID: <20160608133508.GA93263@charmander>
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>
 <20160607160155.GP38613@kib.kiev.ua>
 <20160607211919.GA49961@stack.nl>
 <20160608043055.GV38613@kib.kiev.ua>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160608043055.GV38613@kib.kiev.ua>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
 <freebsd-current.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-current>, 
 <mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current/>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-current>, 
 <mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 08 Jun 2016 13:35:19 -0000

On Wed, Jun 08, 2016 at 07:30:55AM +0300, Konstantin Belousov wrote:
> On Tue, Jun 07, 2016 at 11:19:19PM +0200, Jilles Tjoelker wrote:
> > In this case it is clear which sleep(9) calls should be affected so it
> > may be better to avoid more hidden state.
> In this case yes, but apparently some out-of-tree users exist. And,
> the marking of the single sx_sleep() call depends on knowing our
> implementation. I remember that as the arguments to change from PBDRY to
> the current state setter, in NFS it is not too hard to try to enumerate
> interruptible sleeps. 
> 
> > 
> > I also wonder whether we may be overengineering things here. Perhaps
> > the advlock sleep can simply turn off TDF_SBDRY.
> Well, this was the very first patch suggested.  I would be fine with that,
> but again, out-of-tree code seems to be not quite fine with that local
> solution.

In our particular case, we could possibly use a similar approach. In
general, it seems incorrect to clear TDF_SBDRY if the thread calling
sx_sleep() has any locks held. It is easy to verify that all callers of
lf_advlock() are safe in this respect, but this kind of auditing is
generally hard. In fact, I believe the sx_sleep that led to the problem
described in D2612 is the same as the one in my case. That is, the
sleeping thread may or may not hold a vnode lock depending on context.