From owner-dev-commits-src-all@freebsd.org Tue Mar 9 17:34:03 2021 Return-Path: Delivered-To: dev-commits-src-all@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 ECA9356ACE5; Tue, 9 Mar 2021 17:34:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dw2Pl6VGSz4kbP; Tue, 9 Mar 2021 17:34:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 45E23278D6; Tue, 9 Mar 2021 17:34:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: 1ae20f7c70ea - main - kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING() To: Kyle Evans , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202103091117.129BHOZa042851@gitrepo.freebsd.org> From: John Baldwin Message-ID: <3d67f7e4-c1fc-ca2c-8fc5-417dcf8e4145@FreeBSD.org> Date: Tue, 9 Mar 2021 09:33:59 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <202103091117.129BHOZa042851@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2021 17:34:04 -0000 On 3/9/21 3:17 AM, Kyle Evans wrote: > The branch main has been updated by kevans: > > URL: https://cgit.FreeBSD.org/src/commit/?id=1ae20f7c70ea16fa8b702e409030e170df4f5c13 > > commit 1ae20f7c70ea16fa8b702e409030e170df4f5c13 > Author: Kyle Evans > AuthorDate: 2021-03-08 06:16:27 +0000 > Commit: Kyle Evans > CommitDate: 2021-03-09 11:16:39 +0000 > > kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING() > > Simple condition flip; we wanted to panic here after epoch_trace_list(). > > Reviewed by: glebius, markj > MFC after: 3 days > Differential Revision: https://reviews.freebsd.org/D29125 > --- > sys/kern/kern_malloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c > index 48383358e3ad..0d6f9dcfcab7 100644 > --- a/sys/kern/kern_malloc.c > +++ b/sys/kern/kern_malloc.c > @@ -537,7 +537,7 @@ malloc_dbg(caddr_t *vap, size_t *sizep, struct malloc_type *mtp, > #ifdef EPOCH_TRACE > epoch_trace_list(curthread); > #endif > - KASSERT(1, > + KASSERT(0, > ("malloc(M_WAITOK) with sleeping prohibited")); I would perhaps just use panic() directly under INVARIANTS instead of KASSERT(false, ...) Either that or duplicate the condition and let the compiler deal with avoiding checking it twice, e.g.: #ifdef EPOCH_TRACE if (!THREAD_CAN_SLEEP()) epoc_trace_list(curthread); #endif KASSERT(THREAD_CAN_SLEEP(), ("malloc(M_WAITOK) with sleeping prohibited")); -- John Baldwin