From nobody Mon Aug 19 11:03:25 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 4WnV7x6mKRz5SnrY; Mon, 19 Aug 2024 11:03:25 +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 4WnV7x5wqLz4SNk; Mon, 19 Aug 2024 11:03:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724065405; 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=78YzzI4MmWJ57l6qxJmju6yID0HUfOwjUuohaY56j44=; b=sx6g2NkeHuajId1QON9T9nCgxc9Iqh3okpjn3dOzBla3WMro/kbZNwOTE6/f1qdLVusaji QwR/fR3u1GC8Rsh7KiYPqi4e//FkenJaRQ/U6bjjrOwAniSWA15OBVn++/rnqgJW67nW/i ggwaQtxwx7MXKilU62xLjbl/QegctQlcxEyAlwBQdZNOKlAzF5Wl/3uGF/QcxEcyEpba2d ZPdQ0hNiVLUL0p6YVCw9aURw/TRJ00LVZTJjzCqRjXoPFEymyYe9UTYYKq+fQrD1y1qzbs eZzeNR05/idTH2rdpfjlmTEOlwDLJGT9KcJVreiyjP5hdHqep7qvpFRVlvIUZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724065405; a=rsa-sha256; cv=none; b=b30NLxHyAR01PIYU2HSSO/lm6mmYFgCjLeYA/Y4smWi0bROphDljxXFxp8AqeN/B843hl9 2LBF62dkFgpNEvKPx9sss3WpSZU6w/01v7usTQFxooVM+XY7Bj9iIVwzAVxUNqtgR+rK6m wF2dYS/hN0Ji0I3Ff6A40gPBMQl/EbRKsqr4PlARbBAx08hJKNWlv6/EtQhiwPYVUqc7wU A+1TK0cEjBEqHMy/VW4YLybnj8ybXqheO85VyhKWlrzXzaMZK8RoRYibpd1kmUH7YFC2MV FE23/+JJKz3bz7rA2gNsvPMXtVuAOun/eQhunDk54VIDlvqbZ3jOazouppmYFA== 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=1724065405; 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=78YzzI4MmWJ57l6qxJmju6yID0HUfOwjUuohaY56j44=; b=JNTyqCrGlOJf5qNhaKbA0zLTSwY8tzKEhu1yudr2KkpM6nefp3/oncfkZq8ek+ndobVRx4 V2sfLd4iZx7af6p4rRov4zkzmqeZFm7ePBOSzTvk6L38FZc3r+UZRtUvdt1B4Zyzu5Xbho CP5ZO3L7TUXx59ait+WZ1vs3lTE9oYUfncyR+uauxpMBGPjLXx2es74FpOvnL50TT4JoC7 TtfDqjVNL0moJQiSktSd5f75ywJGbkRdAI0zkf8g1WRj+7G+aYuMdRzQFrrRs5VAG/0u42 QDLbaaXeXQ66JA+VNVyApI7K7ePG3ucnWND0G1bKbS4z0yaSz6pXwbs7MoKwDA== 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 4WnV7x5X46zFGj; Mon, 19 Aug 2024 11:03:25 +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 47JB3Peb037492; Mon, 19 Aug 2024 11:03:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47JB3PjZ037489; Mon, 19 Aug 2024 11:03:25 GMT (envelope-from git) Date: Mon, 19 Aug 2024 11:03:25 GMT Message-Id: <202408191103.47JB3PjZ037489@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: d3d34d56bee4 - main - 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/main X-Git-Reftype: branch X-Git-Commit: d3d34d56bee4222b3bf3ec26d7877998405115a3 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=d3d34d56bee4222b3bf3ec26d7877998405115a3 commit d3d34d56bee4222b3bf3ec26d7877998405115a3 Author: Andrew Turner AuthorDate: 2024-07-29 10:28:24 +0000 Commit: Andrew Turner CommitDate: 2024-08-19 09:04:25 +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 --- 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 6bd3b91dcd04..2d61f393712d 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