From owner-freebsd-current@freebsd.org Tue Jun 7 04:47:01 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 EEC57B6DCA2 for ; Tue, 7 Jun 2016 04:47:01 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pf0-x22d.google.com (mail-pf0-x22d.google.com [IPv6:2607:f8b0:400e:c00::22d]) (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 BECC01EDB; Tue, 7 Jun 2016 04:47:01 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pf0-x22d.google.com with SMTP id c2so1068472pfa.2; Mon, 06 Jun 2016 21:47:01 -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=oAMvi2tEQ504Shp+ol8N1IFKPJqU3lTJGlmYypn7tLY=; b=Ob/j6s0eoq6mjD/gyZfzCzv6klg8Vi4NFI7e+6wkdDfOvckPCUT0I5D+9VbItVxIEK LOlxmO5s6uR9EG1DULpcUjZG1fGlkMvQMD8STh0edALzhN4edtinLOoe6q23SGE1obT5 AP/D/SNcz+fneavF0MglqkgXR0SdCT4Jf7T41fTyjsKtbB/xTLyiLKm1m6upSSMJhYCA UY7dp1sNr+He+FZ8rv5Y9Ne++UlJu5nQ9pxA0LaA12yUV5XSksMHLWkWm2VEzthrP8zo 7nq1RBhNyxpyk6oewaxGCxQK0vLm5rdvRY8A3V/ASRYs73GHStmqcbQmH0k+10gXApbD DOkQ== 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=oAMvi2tEQ504Shp+ol8N1IFKPJqU3lTJGlmYypn7tLY=; b=iS7iqnpvv5T/G7AlyjvPqRd1OwONa6nk6IVGQeUMb3Yh9CQ2m3TXe8p1P7+Lsg8qpV BTHJE32ovrADoNztntcPiiJ/9HG+G0qyJgmULb2c22g8sKNr3y7MDCXozPVIn+X5zRWl i6PuA22tXdLBDCyF2n/rqnGqvvUwuqM7zVDejyt/tFwyZOyEARyLBnxfb1rF7WgaO0xo i/rHCvhQ/BGZT6YEGajPfKmQTukL5g9oqJzXnkhYovOxYM+t4/TWL0cEv/lI74tTLLRV EUucAMPMKWgB2p12PSAkq79PV+IAiE63giLSj+bnjeQlYRslxFiOmixOzGm2QpKBtmid WsEA== X-Gm-Message-State: ALyK8tKfmoNy5j1k+y2XhkmUsmWVPW91/CLEiOTjlHnuURuma9FhABDlr0tSTJ3ahd3kXg== X-Received: by 10.98.97.71 with SMTP id v68mr29937979pfb.138.1465274821308; Mon, 06 Jun 2016 21:47:01 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id 22sm31244599pfw.92.2016.06.06.21.46.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 21:47:00 -0700 (PDT) Sender: Mark Johnston Date: Mon, 6 Jun 2016 21:50:47 -0700 From: Mark Johnston To: Konstantin Belousov Cc: freebsd-current@FreeBSD.org, cem@FreeBSD.org Subject: Re: thread suspension when dumping core Message-ID: <20160607045047.GB29017@wkstn-mjohnston.west.isilon.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160607042956.GM38613@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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2016 04:47:02 -0000 On Tue, Jun 07, 2016 at 07:29:56AM +0300, Konstantin Belousov wrote: > On Mon, Jun 06, 2016 at 09:17:41PM -0700, Mark Johnston wrote: > > Sure, see below. For reference: > > > > td_flags = 0xa84c = INMEM | SINTR | CANSWAP | ASTPENDING | SBDRY | NEEDSUSPCHK > > td_pflags = 0 > > td_inhibitors = 0x2 = SLEEPING > > td_locks = 0 > > > > stack: > > mi_switch+0x21e sleepq_catch_signals+0x377 sleepq_wait_sig+0xb _sleep+0x29d ... > > > > p_flag = 0x10080080 = INMEM | STOPPED_SINGLE | HADTHREADS > > p_flag2 = 0 > > > > The thread is sleeping interruptibly. The NEEDSUSPCHK flag is set, yet the > > SLEEPABORT flag is not, so the thread can not have been sleeping when > > thread_single() was called - else sleepq_abort() would have been > > invoked and set SLEEPABORT. We are at the second sleepq_switch() call in > > sleepq_catch_signals(), and no signal was pending, so we called > > thread_suspend_check(), which returned 0 because of SBDRY. So we went to > > sleep. > > 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. Thanks, that sounds right to me. It results in unified behaviour for TDF_SBDRY regardless of whether the suspension attempt took place before or after the thread went to sleep, and seems like it does the right thing in the single-threaded case as well.