From owner-freebsd-current@freebsd.org Tue Aug 18 15:08:48 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5823A3BECBC for ; Tue, 18 Aug 2020 15:08:48 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BWDnr0rzGz4Cvq for ; Tue, 18 Aug 2020 15:08:48 +0000 (UTC) (envelope-from david@catwhisker.org) Received: by mailman.nyi.freebsd.org (Postfix) id 1B8D43BECBB; Tue, 18 Aug 2020 15:08:48 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B4E43BEE89 for ; Tue, 18 Aug 2020 15:08:48 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from mx.catwhisker.org (mx.catwhisker.org [107.204.234.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BWDnp4fFPz4CcB for ; Tue, 18 Aug 2020 15:08:46 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.16.1/8.15.2) with ESMTP id 07IF8iR3030373; Tue, 18 Aug 2020 15:08:44 GMT (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.16.1/8.16.1/Submit) id 07IF8iDt030372; Tue, 18 Aug 2020 08:08:44 -0700 (PDT) (envelope-from david) Date: Tue, 18 Aug 2020 08:08:44 -0700 From: David Wolfskill To: Mateusz Guzik Cc: current@freebsd.org Subject: Re: "panic: malloc(M_WAITOK) in non-sleepable context" after r364296 -> r364341 Message-ID: <20200818150844.GR1394@albert.catwhisker.org> Reply-To: current@freebsd.org Mail-Followup-To: current@freebsd.org, Mateusz Guzik References: <20200818124419.GO1394@albert.catwhisker.org> <20200818125825.GP1394@albert.catwhisker.org> <20200818132902.GQ1394@albert.catwhisker.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w/cbcIkiD1zHilas" Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4BWDnp4fFPz4CcB X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.41 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[current@freebsd.org]; FREEFALL_USER(0.00)[david]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:107.204.234.170:c]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; HAS_ATTACHMENT(0.00)[]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; SIGNED_PGP(-2.00)[]; DMARC_NA(0.00)[catwhisker.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.01)[-1.008]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+,4:~]; ASN(0.00)[asn:7018, ipnet:107.192.0.0/12, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 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, 18 Aug 2020 15:08:48 -0000 --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--