From nobody Mon Oct 23 17:32:44 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SDj272j2Kz4yJf2; Mon, 23 Oct 2023 17:32:47 +0000 (UTC) (envelope-from garyj@gmx.de) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.gmx.net", Issuer "Telekom Security ServerID OV Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SDj263YJlz4drh; Mon, 23 Oct 2023 17:32:46 +0000 (UTC) (envelope-from garyj@gmx.de) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1698082365; x=1698687165; i=garyj@gmx.de; bh=RQBVBDdLLNsOJcFhAQW4d630+0oXMksV6bgG4Pv09JA=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References: Reply-To; b=PjKvF9+ITusXM3p1ZWav4mKUPqTkwq2hAaWVLurZ1mwySAK/pbWe20iP4iaFk+bm TAKTZIdVdgM0gZMkeki644DZVNchEZ21+fI/4mFTq5DwM6gfk60IX5JcyNTT53FhA 6JVwqss2Tz+xpGuhP6gpgMZ5Qwct9kQOE4+5kqMszIhKgwxT49E1wGgBihhWlkbXD xQVY9nxpWc0Z22sKLe3USsElz61pRZhpD6wkPciuSl/TyxiVqFldO93nTY2tzyxZY kEtwOIUvQ+1Ecw2y7uJyz5lYI/cce/BB1nO6X5mxWJCinBI2Wtv00JX2eg3eE7Ozt z5WcqexjP7xe19ePdg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ernst.home ([217.226.57.134]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M9Wys-1qpUbo47Gu-005WVW; Mon, 23 Oct 2023 19:32:45 +0200 Date: Mon, 23 Oct 2023 17:32:44 +0000 From: Gary Jennejohn To: Mateusz Guzik Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: c35f527ed115 - main - sx: unset td_wantedlock around going to sleep Message-ID: <20231023193244.148ddcec@ernst.home> In-Reply-To: <202310231723.39NHNSn8063744@gitrepo.freebsd.org> References: <202310231723.39NHNSn8063744@gitrepo.freebsd.org> Reply-To: garyj@gmx.de X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:c4g/LjG3bQulm8SmT9XQ3pdb3ZAJAHXpaLCtD9oWQBeVW5oXCSf i5FIWB4iT/YtC6BV5fpX9DCRdSBTaknvI9jcbZJGeyKLV2z9uIW5CwI6rq2hLwlZJ1sCjPC GkqfqId87FO/EYUSjNHLhVsRGPlFxXeP7rLizWtso5Z2ckM6pwPj3sXfVaW/jOKxls+qMPg +egN1qoRupCwLL6P9N3OA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:T1rGdUPbzu0=;pBF87mcoFMWSnNLlEQw7/YFAD6n 5KzXo0v4fm9LaV6olNvl0utN30HVxNfGV6NLL689hDWcztajl+pSW8TDoAxeowmo5ai046ljm jE2HhW9eMXULLYA8dFnA2yBTbDj4AeXzr65ru3sllqMtyYdr6a1eEyge/wlgNh2WOCnqjWYQM Doe7B7y9deINUn09WG1pWSOW1Ng0nKOpc8mwvkPCiG3rRPe/7g7GwMIwZL0CaTfHZJTPYfhZr QI97vFk9O9TV+G2jYW4keEBuLgPM6cuK17/lDHv3SW8zV8Nu4ABDFmzSC1FiifLeqAghxJzAO O7rRJOXJ5H6HnnZYV4kG+EUNcVlf60EU5xrZZENAIpJCitH5j/hvrC9f4nLYbLo1lk2RFJ3f6 cdhgdai3UDoczsPSvKGye1AJd7z8hNrd8B/BfsLOmBv1iT64n1dzrAlnz6SRsiSsCXdPmmxEx va68HjwXhJ3zFqGejI9I/ynI3ioHxeqbLL+e10MLJXrFPBi6Z9trP9qmkGIYUfyMStbjVKU46 gaVs4af7nGFw2DkN4bdlNbDdUexABnlfWhnxwN339s0YCA49AvP/reHj8Y+TjF91Bx7rgPkCq IGScb8mPsN+9xU6eQTx4cjcP4xf1kIgT+lmXjye+BRuZBlfQ3dA0ciK5t3g5DpsWRlR/HjXkp +1veoOglA3kiv8bzx7S/O76i35vVMqy64snYm3Z0v07dmVqolNoPFS00kpS8IEPECcgmzhHNa bmR/KkP2fwHrwJ+rNOja+pHrxf678b5e8uWaTnJWvBP7T6rzeJl9Bg7JJl1NSwj5F3QEq0A0/ p2O7End7wwUuj/Zdl+Hcm4zidAEGpBURhoyCiCKyS21YdTBoLcuta4Nm467ftHGuDeq7iHTL6 Ek2dHgTI84BJztNOWlOYpYPMXlwMIP4RSePc8VZvbYfkozjgBdy4nZm3m+l0SCvZ0m1ILcmbQ 6aTiHthznZGGxtpWJ/b12jYNaH4= X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE] X-Rspamd-Queue-Id: 4SDj263YJlz4drh On Mon, 23 Oct 2023 17:23:28 GMT Mateusz Guzik wrote: > The branch main has been updated by mjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3Dc35f527ed115b792463d30c7d= 3c8904e435caead > > commit c35f527ed115b792463d30c7d3c8904e435caead > Author: Mateusz Guzik > AuthorDate: 2023-10-23 17:22:12 +0000 > Commit: Mateusz Guzik > CommitDate: 2023-10-23 17:22:12 +0000 > > sx: unset td_wantedlock around going to sleep > > Otherwise it can crash in sleepq_wait_sig -> sleepq_catch_signals -> > sig_ast_checksusp -> thread_suspend_check due to a mutex acquire. > > Reported by: pho > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > sys/kern/kern_sx.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c > index bc8a1214689f..455ae165e328 100644 > --- a/sys/kern/kern_sx.c > +++ b/sys/kern/kern_sx.c > @@ -854,10 +854,17 @@ retry_sleepq: > sleepq_add(&sx->lock_object, NULL, sx->lock_object.lo_name, > SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? > SLEEPQ_INTERRUPTIBLE : 0), SQ_EXCLUSIVE_QUEUE); > + /* > + * Hack: this can land in thread_suspend_check which will > + * conditionally take a mutex, tripping over an assert if a > + * lock we are waiting for is set. > + */ > + THREAD_CONTENTION_DONE(&sx->lock_object); > if (!(opts & SX_INTERRUPTIBLE)) > sleepq_wait(&sx->lock_object, 0); > else > error =3D sleepq_wait_sig(&sx->lock_object, 0); > + THREAD_CONTENTION_DONE(&sx->lock_object); should this be THREAD_CONTENDS_ON_LOCK, like below? > #ifdef KDTRACE_HOOKS > sleep_time +=3D lockstat_nsecs(&sx->lock_object); > sleep_cnt++; > @@ -1209,10 +1216,17 @@ retry_sleepq: > sleepq_add(&sx->lock_object, NULL, sx->lock_object.lo_name, > SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? > SLEEPQ_INTERRUPTIBLE : 0), SQ_SHARED_QUEUE); > + /* > + * Hack: this can land in thread_suspend_check which will > + * conditionally take a mutex, tripping over an assert if a > + * lock we are waiting for is set. > + */ > + THREAD_CONTENTION_DONE(&sx->lock_object); > if (!(opts & SX_INTERRUPTIBLE)) > sleepq_wait(&sx->lock_object, 0); > else > error =3D sleepq_wait_sig(&sx->lock_object, 0); > + THREAD_CONTENDS_ON_LOCK(&sx->lock_object); > #ifdef KDTRACE_HOOKS > sleep_time +=3D lockstat_nsecs(&sx->lock_object); > sleep_cnt++; > =2D- Gary Jennejohn