Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107579666
D46149.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D46149.diff
View Options
diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h
--- a/sys/sys/buf_ring.h
+++ b/sys/sys/buf_ring.h
@@ -35,13 +35,9 @@
#include <machine/atomic.h>
#include <machine/cpu.h>
-#ifdef DEBUG_BUFRING
-#ifdef _KERNEL
+#if defined(DEBUG_BUFRING) && defined(_KERNEL)
#include <sys/lock.h>
#include <sys/mutex.h>
-#else
-#error "DEBUG_BUFRING is only supported in kernel"
-#endif
#endif
struct buf_ring {
@@ -54,7 +50,7 @@
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 @@
#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 @@
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 @@
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 @@
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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 4:37 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15833593
Default Alt Text
D46149.diff (1 KB)
Attached To
Mode
D46149: buf_ring: Support DEBUG_BUFRING in userspace
Attached
Detach File
Event Timeline
Log In to Comment