From nobody Sat Mar 26 01:11:44 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AD34B1A3D2CB; Sat, 26 Mar 2022 01:11:44 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KQLX03GdBz3v56; Sat, 26 Mar 2022 01:11:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648257104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gdiaY1uy2rYusjUXr7jK1bgLo4YOTNZ4fM+YCIH2Ito=; b=p/msZQJuLWUxOoi8lbob6oazBsVBmShZFA66qY9CCB6H5ACp2Cs6vszmvwTp0m43DdUMUF d6Pj4FI7WlME7eyJIULIaLFS/8Z+A9KXfOo2fO9R83o1VbEZB/bbFJmVE8zeq2xgIxTWln K5kpowalbpC4V7GxaSx9htWzmFdjLEn/+MJBgV5jTHh65ANJSyywHNjkbx0xM1h7umgAlZ FIO4b/yIRxgFf9IWTeRFTnz2JzFGIE6mvVnysjmfplX5s1HtkkOGRgU06wgWxmy59mC7OY 5HC+UdBbDWIDTCap7+NS6QWGU8BfFBz+rGqAz5OA+2K/lzYwwOZkgGmKUzbNPQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 408CA17886; Sat, 26 Mar 2022 01:11:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22Q1BiAP063678; Sat, 26 Mar 2022 01:11:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22Q1BinT063677; Sat, 26 Mar 2022 01:11:44 GMT (envelope-from git) Date: Sat, 26 Mar 2022 01:11:44 GMT Message-Id: <202203260111.22Q1BinT063677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: a8cbb835bfdf - main - uma_zalloc: assert M_NOWAIT ^ M_WAITOK List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a8cbb835bfdf086249fab8f9cb3d2a3533214eac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648257104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gdiaY1uy2rYusjUXr7jK1bgLo4YOTNZ4fM+YCIH2Ito=; b=dvXzmg3aJDmZOygmSYew0pOXeYEXaoTwvIGUs/0cPj6ZZr9EXKNXol8sD7D1HXgqSppsmR 5ZWF6JDInE01srgY+xe+HOORuVn5DINyaTGPWLK7gVqAPB20g9g/ZLHLHcmyo0T3AKd7Ue IOb3qfh1N9NZvQymVICLCTBBc09i4vC2r3opzL38T/72o+hokxz2PFo0OaLVUttqv8mbqm nt9/IXOWbK4xuOE9ZouXrktVRgfzr27dgQasO3jxZEVIU8rT/ba1IFb9SjJ6ztvhcRaoVN X644ySofqeVFb52YPB5iB8KbFzoXZqYV1v2QcyG8J4WQVaDvKyezFIwXRDeSDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648257104; a=rsa-sha256; cv=none; b=JcAtO86G6kkOJaGDUjNTd54/oHuji+CoTBm+iFzB6d7G3gYfZbg68Arony6kFYBogcq4n4 z5unPGPzfYkWEY/IRRrziXsz8ao1Sx6K+ttznncLa0KGcf1moWWQUAs7LbT91ZjCedieKa GVrzdXbKiCbBJBmxHMusdeKYcrjuet8VCE6+asCJAFzax6KX+jPYBAR+4sMfT68TTHSIIe at6OrBsKA9X5soBT/4xqPmQDQQnAuoj4yUIsDMnMau1hLQn6mMYbuhgxvEzlW5vxoc9Nc+ mR7tuIo02KdpB+j+La7tjPe/aOTyrfuSDGg+zku8BI5u5/OwjDz7edC+sqb0Dg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=a8cbb835bfdf086249fab8f9cb3d2a3533214eac commit a8cbb835bfdf086249fab8f9cb3d2a3533214eac Author: Eric van Gyzen AuthorDate: 2022-03-04 11:23:08 +0000 Commit: Eric van Gyzen CommitDate: 2022-03-26 01:10:37 +0000 uma_zalloc: assert M_NOWAIT ^ M_WAITOK The uma_zalloc functions expect exactly one of [M_NOWAIT, M_WAITOK]. If neither or both are passed, print an error and a stack dump. Only do this ten times, to prevent livelock. In the future, after this exposes enough bad callers, this will be changed to a KASSERT(). Reviewed by: rstone, markj MFC after: 1 month Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D34452 --- sys/vm/uma_core.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 341b12209f9d..9fd2fd5e5d03 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -3494,6 +3494,9 @@ item_domain(void *item) #endif #if defined(INVARIANTS) || defined(DEBUG_MEMGUARD) || defined(WITNESS) +#if defined(INVARIANTS) && (defined(DDB) || defined(STACK)) +#include +#endif #define UMA_ZALLOC_DEBUG static int uma_zalloc_debug(uma_zone_t zone, void **itemp, void *udata, int flags) @@ -3515,6 +3518,31 @@ uma_zalloc_debug(uma_zone_t zone, void **itemp, void *udata, int flags) ("uma_zalloc_debug: called within spinlock or critical section")); KASSERT((zone->uz_flags & UMA_ZONE_PCPU) == 0 || (flags & M_ZERO) == 0, ("uma_zalloc_debug: allocating from a pcpu zone with M_ZERO")); + + _Static_assert(M_NOWAIT != 0 && M_WAITOK != 0, + "M_NOWAIT and M_WAITOK must be non-zero for this assertion:"); +#if 0 + /* + * Give the #elif clause time to find problems, then remove it + * and enable this. (Remove above, too.) + */ + KASSERT((flags & (M_NOWAIT|M_WAITOK)) == M_NOWAIT || + (flags & (M_NOWAIT|M_WAITOK)) == M_WAITOK, + ("uma_zalloc_debug: must pass one of M_NOWAIT or M_WAITOK")); +#elif defined(DDB) || defined(STACK) + if (__predict_false((flags & (M_NOWAIT|M_WAITOK)) != M_NOWAIT && + (flags & (M_NOWAIT|M_WAITOK)) != M_WAITOK)) { + static int stack_count; + struct stack st; + + if (stack_count < 10) { + ++stack_count; + printf("uma_zalloc* called with bad WAIT flags:\n"); + stack_save(&st); + stack_print(&st); + } + } +#endif #endif #ifdef DEBUG_MEMGUARD