26 RCSID(
"$Id: 4c9b7eac8aec45848041939320b3ab29e966ff9f $")
32 #include <freeradius-devel/autoconf.h>
33 #include <freeradius-devel/io/atomic_queue.h>
34 #include <freeradius-devel/util/talloc.h>
36 #define CACHE_LINE_SIZE 64
87 if (size == 0)
return NULL;
97 sizeof(*
aq) + (size) *
sizeof(
aq->
entry[0]));
98 if (!chunk)
return NULL;
101 talloc_set_name_const(chunk,
"fr_atomic_queue_t");
107 for (i = 0; i < size; i++) {
153 if (!
data)
return false;
220 if (!p_data)
return false;
230 diff = (seq - (tail + 1));
253 *p_data = entry->
data;
270 #ifdef WITH_VERIFY_PTR
309 fprintf(fp,
"AQ %p size %zu, head %" PRId64
", tail %" PRId64
"\n",
312 for (i = 0; i <
aq->
size; i++) {
317 fprintf(fp,
"\t[%zu] = { %p, %" PRId64
" }",
325 fprintf(fp,
"\tstatus %d, data_size %zd, signal %d, ack %zd, ch %p",
atomic_int64_t head
Head, aligned bytes to ensure it's in a different cache line to tail to reduce memory contention.
bool fr_atomic_queue_pop(fr_atomic_queue_t *aq, void **p_data)
Pop a pointer from the atomic queue.
void * chunk
To pass to free. The non-aligned address.
fr_atomic_queue_t * fr_atomic_queue_alloc(TALLOC_CTX *ctx, size_t size)
Create fixed-size atomic queue.
fr_atomic_queue_entry_t entry[]
The entry array, also aligned to ensure it's not in the same cache line as tail and size.
size_t fr_atomic_queue_size(fr_atomic_queue_t *aq)
bool fr_atomic_queue_push(fr_atomic_queue_t *aq, void *data)
Push a pointer into the atomic queue.
void fr_atomic_queue_free(fr_atomic_queue_t **aq)
Free an atomic queue if it's not freed by ctx.
void fr_atomic_queue_debug(fr_atomic_queue_t *aq, FILE *fp)
Dump an atomic queue.
atomic_int64_t seq
Must be seq then data to ensure seq is 64bit aligned for 32bit address spaces.
Structure to hold the atomic queue.
#define cas_incr(_store, _var)
#define store(_store, _var)
static fr_atomic_queue_t * aq
fr_control_message_status_t status
status of this message
size_t data_size
size of the data we're sending
The header for the control message.
#define atomic_thread_fence(order)
TALLOC_CTX * talloc_aligned_array(TALLOC_CTX *ctx, void **start, size_t alignment, size_t size)
Return a page aligned talloc memory array.