From owner-svn-src-all@freebsd.org Mon Aug 17 15:37:09 2020 Return-Path: Delivered-To: svn-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 746823B5C88; Mon, 17 Aug 2020 15:37:09 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BVdT12W2Pz3Zw4; Mon, 17 Aug 2020 15:37:09 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38D1723085; Mon, 17 Aug 2020 15:37:09 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07HFb9kN058298; Mon, 17 Aug 2020 15:37:09 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07HFb8a6058296; Mon, 17 Aug 2020 15:37:08 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <202008171537.07HFb8a6058296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 17 Aug 2020 15:37:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364310 - in head/sys: kern vm X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: in head/sys: kern vm X-SVN-Commit-Revision: 364310 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Aug 2020 15:37:09 -0000 Author: glebius Date: Mon Aug 17 15:37:08 2020 New Revision: 364310 URL: https://svnweb.freebsd.org/changeset/base/364310 Log: With INVARIANTS panic immediately if M_WAITOK is requested in a non-sleepable context. Previously only _sleep() would panic. This will catch misuse of M_WAITOK at development stage rather than at stress load stage. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D26027 Modified: head/sys/kern/kern_malloc.c head/sys/vm/uma_core.c Modified: head/sys/kern/kern_malloc.c ============================================================================== --- head/sys/kern/kern_malloc.c Mon Aug 17 15:11:46 2020 (r364309) +++ head/sys/kern/kern_malloc.c Mon Aug 17 15:37:08 2020 (r364310) @@ -618,6 +618,9 @@ void * unsigned long osize = size; #endif + KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(), + ("malloc(M_WAITOK) in non-sleepable context")); + #ifdef MALLOC_DEBUG va = NULL; if (malloc_dbg(&va, &size, mtp, flags) != 0) Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Mon Aug 17 15:11:46 2020 (r364309) +++ head/sys/vm/uma_core.c Mon Aug 17 15:37:08 2020 (r364310) @@ -3328,6 +3328,9 @@ uma_zalloc_smr(uma_zone_t zone, int flags) uma_cache_bucket_t bucket; uma_cache_t cache; + KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(), + ("uma_zalloc_smr(M_WAITOK) in non-sleepable context")); + #ifdef UMA_ZALLOC_DEBUG void *item; @@ -3351,6 +3354,9 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags { uma_cache_bucket_t bucket; uma_cache_t cache; + + KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(), + ("uma_zalloc(M_WAITOK) in non-sleepable context")); /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);