Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Aug 2020 08:08:44 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        current@freebsd.org
Subject:   Re: "panic: malloc(M_WAITOK) in non-sleepable context" after r364296 -> r364341
Message-ID:  <20200818150844.GR1394@albert.catwhisker.org>
In-Reply-To: <CAGudoHG8ZcwcoPzs33WXTVcRZ0APRiABMNCR--KgUDwF%2BgosGg@mail.gmail.com>
References:  <20200818124419.GO1394@albert.catwhisker.org> <CAGudoHEEnZVaBwY1L-wjmDcrsHyP4pE3-0qyurh-kWsCO9Edhg@mail.gmail.com> <20200818125825.GP1394@albert.catwhisker.org> <CAGudoHHJLoQhU%2Bb4%2Btt_dmChYj=qXA%2BiVaC5mFW8sFxoqq54pw@mail.gmail.com> <20200818132902.GQ1394@albert.catwhisker.org> <CAGudoHG8ZcwcoPzs33WXTVcRZ0APRiABMNCR--KgUDwF%2BgosGg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--w/cbcIkiD1zHilas
Content-Type: multipart/mixed; boundary="Aq6vH1t1JS3Uc7g3"
Content-Disposition: inline


--Aq6vH1t1JS3Uc7g3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 18, 2020 at 03:37:50PM +0200, Mateusz Guzik wrote:
> So the previous patch should just print a warning.
>=20
> Does this take care of the problem in general? I don't have means to
> test the patch.
> ....

Sorry for the delay, but finished patching & rebuilding, and
(essentially), yes.  (The difference is that I replaced all 3 of the
KASSERT()s from r364310 with the WITNESS_WARN() constructs, rather
than only 2.)

FreeBSD freebeast.catwhisker.org 13.0-CURRENT FreeBSD 13.0-CURRENT #1004 r3=
64296M/364296: Mon Aug 17 06:04:40 PDT 2020     root@freebeast.catwhisker.o=
rg:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 1300109 1300109

FreeBSD freebeast.catwhisker.org 13.0-CURRENT FreeBSD 13.0-CURRENT #1006 r3=
64341M/364341: Tue Aug 18 06:59:10 PDT 2020     root@freebeast.catwhisker.o=
rg:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 1300110 1300110

Peace,
david
--=20
David H. Wolfskill				david@catwhisker.org
Donald Trump is either ignorant of how to govern or is refusing to do so.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.

--Aq6vH1t1JS3Uc7g3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch
Content-Transfer-Encoding: quoted-printable

Index: sys/kern/kern_malloc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/kern/kern_malloc.c	(revision 364341)
+++ sys/kern/kern_malloc.c	(working copy)
@@ -618,8 +618,8 @@
 	unsigned long osize =3D size;
 #endif
=20
-	KASSERT((flags & M_WAITOK) =3D=3D 0 || THREAD_CAN_SLEEP(),
-	    ("malloc(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) !=3D 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
=20
 #ifdef MALLOC_DEBUG
 	va =3D NULL;
Index: sys/vm/uma_core.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/vm/uma_core.c	(revision 364341)
+++ sys/vm/uma_core.c	(working copy)
@@ -3328,8 +3328,8 @@
 	uma_cache_bucket_t bucket;
 	uma_cache_t cache;
=20
-	KASSERT((flags & M_WAITOK) =3D=3D 0 || THREAD_CAN_SLEEP(),
-	    ("uma_zalloc_smr(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) !=3D 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
=20
 #ifdef UMA_ZALLOC_DEBUG
 	void *item;
@@ -3355,8 +3355,8 @@
 	uma_cache_bucket_t bucket;
 	uma_cache_t cache;
=20
-	KASSERT((flags & M_WAITOK) =3D=3D 0 || THREAD_CAN_SLEEP(),
-	    ("uma_zalloc(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) !=3D 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
=20
 	/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
 	random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);

--Aq6vH1t1JS3Uc7g3--

--w/cbcIkiD1zHilas
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGTBAEBCgB9FiEE4owz2QxMJyaxAefyQLJg+bY2PckFAl877vxfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEUy
OEMzM0Q5MEM0QzI3MjZCMTAxRTdGMjQwQjI2MEY5QjYzNjNEQzkACgkQQLJg+bY2
PclbjQf7BLuygQt/oo7HXOy9FxquzsE4HQOjAxESlzdmfZQrGfkjj5e0sGfkQc2N
Ld3ULkRINunhN47gqGNwWHA+ZTGTTtoH0HqwJSpGL/W/Vi7C1MPEcWxmwvx7BmFS
cp7R8o3W/TWA8gW81lyPip2ik9Q8CrPSVK8iz+R4a6wUeTQyXwjwpJnBnmcQg+lJ
kpfrYGmi3L9Lg/HKx9VGDJWG/kUN+g8/L94iKQ5rVlkvWy41j8Cc2ZF0x68PXV88
tKyfVNBG2VGaSEKRHQaibGT7Zl2M3PwWGvXMpcskxX8qxhPYLy4Al/YxRProYuXp
J6YhuRIq5bwc/BMXsRMvi9aOZRlE7g==
=2C9k
-----END PGP SIGNATURE-----

--w/cbcIkiD1zHilas--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200818150844.GR1394>