Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102896858
D6986.id17924.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
D6986.id17924.diff
View Options
Index: sys/sys/buf_ring.h
===================================================================
--- sys/sys/buf_ring.h
+++ sys/sys/buf_ring.h
@@ -162,8 +162,34 @@
uint32_t prod_tail;
void *buf;
+ /*
+ * This is a workaround to allow using buf_ring on ARM and ARM64.
+ * ARM64TODO: Fix buf_ring in a generic way.
+ *
+ * Preventing following situation:
+
+ * Core(0) - buf_ring_enqueue() Core(1) - buf_ring_dequeue_sc()
+ * ----------------------------------------- ----------------------------------------------
+ *
+ * cons_head = br->br_cons_head;
+ * atomic_cmpset_acq_32(&br->br_prod_head, ...));
+ * buf = br->br_ring[cons_head]; <see <1>>
+ * br->br_ring[prod_head] = buf;
+ * atomic_store_rel_32(&br->br_prod_tail, ...);
+ * prod_tail = br->br_prod_tail;
+ * if (cons_head == prod_tail)
+ * return (NULL);
+ * <condition is false and code uses invalid(old) buf>`
+ *
+ * <1> Load (on core 1) from br->br_ring[cons_head] can be reordered (speculative readed) by CPU.
+ */
+#if defined(__arm__) || defined(__aarch64__)
+ cons_head = atomic_load_acq_32(&br->br_cons_head);
+ prod_tail = atomic_load_acq_32(&br->br_prod_tail);
+#else
cons_head = br->br_cons_head;
prod_tail = br->br_prod_tail;
+#endif
cons_next = (cons_head + 1) & br->br_cons_mask;
#ifdef PREFETCH_DEFINED
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 11:14 AM (19 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14697929
Default Alt Text
D6986.id17924.diff (1 KB)
Attached To
Mode
D6986: ARM, ARM64: Workaround for buf_ring reordering
Attached
Detach File
Event Timeline
Log In to Comment