From nobody Mon Sep 02 09:12:43 2024 X-Original-To: dev-commits-src-all@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 4Wy31l5C49z5MqnY; Mon, 02 Sep 2024 09:12:43 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wy31l2S5Pz4Ck2; Mon, 2 Sep 2024 09:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725268363; 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=OZoKY5JWkIzq9VlufBAFztJUjKx3rKjOdO/BzBB3KsA=; b=aKl7iekQ+QyaPfpx3iddOQku4LCqPZ7ND16hjJIdDGr2NvlMR9kWcqdm98D66RI+0FpWrP 3dL3u4jDIEtIAkH9vnEEMJWpIVg2TazZrUxYdt5Oa9IagvyFObA9oyE3dc6CaiZoQKW5Eo zjRRXGyDjA0dXpbiAL5Wlt0XvxlAyLXO1p9SNgrDVoWE89O0bAM87pVbVUPtFAU+dizLDT 30d+Ufvcq9B6GPAtNLtnnabqRlfB1mc3LN1BIEtq8FIe313To19g4921djBohy7IWrzQlm YyRNLYaMH6F2zJ9a3LKP9+oFJhU7AZliqWQS3ouEeg2RcnQo/JODRUoIsteiIA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725268363; a=rsa-sha256; cv=none; b=RbQpfrq6Uv+KXzYmvwpwxoITm38nYvuXBrPmzsZ6zDT5siF3SG5AHrSFccJgP5OLRDjqY/ liU2op0F7SXQSNMtHxU7WrrXlZN7XFOdhU6nvQi8ml7xTTWqsxT70jnEogGIx7An9EHLXD yxo4DehszXwaBHBi7w7dfdiDIMF47yuNJ/fnbHu7Kj7xtjGBywwJFiRlE2lW1/Y/c23f/C WfdbpcJ9K4yd19G8EquKNWVgpBQGAvOYEKoDLRc3SyqfxYUWQ2b5snKquRzgLkT4OFiXxR Yk4h8If9aQP8jzPPh+tRlefU37lQYTfWd1NbOEphnySlNdsdta4Jx3LH1hMuCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725268363; 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=OZoKY5JWkIzq9VlufBAFztJUjKx3rKjOdO/BzBB3KsA=; b=lW/+VRg+nhV8fuWTThIDViUH8ap7jnS9MDRhDUkYqNKwQHvM3yMjFJC+De3OyF93tNJmeU tJIBtszmDM0y90bkSaFD3R9XgCtYL1toy6DcyQeygEJjRTzkEPM2qn2Elh/l1ZtqVPZflj +5vZg94gLzaap8IXjQl6B9JsA/Q7CGzanPQz9jQcG8vPbJdv2/L83fcbEU8MHopUyar4w4 8I8K2CPTsL6gplPWlIwZYZwa6OT9qoI2sNDIRRP0O+hBfjeRjwDFIRnfr/SGutEEqnRxc2 mC0VPzfDSTfDFKppGNI7nFZYu/kff7UfqaM523UZL85rSUxdq+Sj+U5FVB1JCQ== 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 4Wy31l1w0Gz15lc; Mon, 2 Sep 2024 09:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4829ChVh049791; Mon, 2 Sep 2024 09:12:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4829ChIU049788; Mon, 2 Sep 2024 09:12:43 GMT (envelope-from git) Date: Mon, 2 Sep 2024 09:12:43 GMT Message-Id: <202409020912.4829ChIU049788@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 0f85e71ab563 - stable/13 - buf_ring: Support DEBUG_BUFRING in userspace List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0f85e71ab5636fd32482e3241cfce57015c99436 Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=0f85e71ab5636fd32482e3241cfce57015c99436 commit 0f85e71ab5636fd32482e3241cfce57015c99436 Author: Andrew Turner AuthorDate: 2024-07-29 10:28:24 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 09:11:57 +0000 buf_ring: Support DEBUG_BUFRING in userspace The only part of DEBUG_BUFRING we don't support in userspace is the mutex checks. Add _KERNEL checks around these so we can enable the extra debugging. Reviewed by: alc, imp, kib, markj Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46149 (cherry picked from commit d3d34d56bee4222b3bf3ec26d7877998405115a3) --- sys/sys/buf_ring.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h index ad87a48bc695..77a8e5ec65b8 100644 --- a/sys/sys/buf_ring.h +++ b/sys/sys/buf_ring.h @@ -35,13 +35,9 @@ #include #include -#ifdef DEBUG_BUFRING -#ifdef _KERNEL +#if defined(DEBUG_BUFRING) && defined(_KERNEL) #include #include -#else -#error "DEBUG_BUFRING is only supported in kernel" -#endif #endif struct buf_ring { @@ -54,7 +50,7 @@ struct buf_ring { volatile uint32_t br_cons_tail; int br_cons_size; int br_cons_mask; -#ifdef DEBUG_BUFRING +#if defined(DEBUG_BUFRING) && defined(_KERNEL) struct mtx *br_lock; #endif void *br_ring[0] __aligned(CACHE_LINE_SIZE); @@ -210,8 +206,10 @@ buf_ring_dequeue_sc(struct buf_ring *br) #ifdef DEBUG_BUFRING br->br_ring[cons_head] = NULL; +#ifdef _KERNEL if (!mtx_owned(br->br_lock)) panic("lock not held on single consumer dequeue"); +#endif if (br->br_cons_tail != cons_head) panic("inconsistent list cons_tail=%d cons_head=%d", br->br_cons_tail, cons_head); @@ -277,7 +275,7 @@ static __inline void * buf_ring_peek(struct buf_ring *br) { -#ifdef DEBUG_BUFRING +#if defined(DEBUG_BUFRING) && defined(_KERNEL) if ((br->br_lock != NULL) && !mtx_owned(br->br_lock)) panic("lock not held on single consumer dequeue"); #endif @@ -296,9 +294,9 @@ buf_ring_peek(struct buf_ring *br) static __inline void * buf_ring_peek_clear_sc(struct buf_ring *br) { -#ifdef DEBUG_BUFRING void *ret; +#if defined(DEBUG_BUFRING) && defined(_KERNEL) if (!mtx_owned(br->br_lock)) panic("lock not held on single consumer dequeue"); #endif @@ -320,17 +318,15 @@ buf_ring_peek_clear_sc(struct buf_ring *br) atomic_thread_fence_acq(); #endif + ret = br->br_ring[br->br_cons_head]; #ifdef DEBUG_BUFRING /* * Single consumer, i.e. cons_head will not move while we are * running, so atomic_swap_ptr() is not necessary here. */ - ret = br->br_ring[br->br_cons_head]; br->br_ring[br->br_cons_head] = NULL; - return (ret); -#else - return (br->br_ring[br->br_cons_head]); #endif + return (ret); } static __inline int