From owner-dev-commits-src-main@freebsd.org Wed Mar 10 10:04:59 2021 Return-Path: Delivered-To: dev-commits-src-main@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 2BE255ABBCB; Wed, 10 Mar 2021 10:04:59 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (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 4DwSP66sczz4p1T; Wed, 10 Mar 2021 10:04:58 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id EF803260185; Wed, 10 Mar 2021 11:04:56 +0100 (CET) Subject: Re: git: 1ae20f7c70ea - main - kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING() To: John Baldwin , Kyle Evans , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202103091117.129BHOZa042851@gitrepo.freebsd.org> <3d67f7e4-c1fc-ca2c-8fc5-417dcf8e4145@FreeBSD.org> From: Hans Petter Selasky Message-ID: <4a923ee1-64a0-93ab-1e73-ff164d690bfc@selasky.org> Date: Wed, 10 Mar 2021 11:04:41 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <3d67f7e4-c1fc-ca2c-8fc5-417dcf8e4145@FreeBSD.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4DwSP66sczz4p1T X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2021 10:04:59 -0000 On 3/9/21 6:33 PM, John Baldwin wrote: > 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")); > Hi, Maybe the KASSERT() can just be a regular warning with backtrace. malloc() doesn't sleep unless there is no memory, would give developers more time to fix their bugs. --HPS