From d7e740172ed8d5bc91bce8404b2cc96b04f23ed3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 19 Mar 2016 11:34:22 -0400 Subject: [PATCH] libringbuffer: implement event too big API Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/frontend_types.h | 2 ++ lib/ringbuffer/ring_buffer_frontend.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/ringbuffer/frontend_types.h b/lib/ringbuffer/frontend_types.h index 46bf8d27..ef63cb50 100644 --- a/lib/ringbuffer/frontend_types.h +++ b/lib/ringbuffer/frontend_types.h @@ -161,6 +161,8 @@ void *channel_get_private(struct channel *chan) return chan->backend.priv; } +void lib_ring_buffer_lost_event_too_big(struct channel *chan); + /* * Issue warnings and disable channels upon internal error. * Can receive struct lib_ring_buffer or struct lib_ring_buffer_backend diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c index 9ebdd5fb..c92e9271 100644 --- a/lib/ringbuffer/ring_buffer_frontend.c +++ b/lib/ringbuffer/ring_buffer_frontend.c @@ -1743,6 +1743,25 @@ retry: return 0; } +static struct lib_ring_buffer *get_current_buf(struct channel *chan, int cpu) +{ + const struct lib_ring_buffer_config *config = &chan->backend.config; + + if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) + return per_cpu_ptr(chan->backend.buf, cpu); + else + return chan->backend.buf; +} + +void lib_ring_buffer_lost_event_too_big(struct channel *chan) +{ + const struct lib_ring_buffer_config *config = &chan->backend.config; + struct lib_ring_buffer *buf = get_current_buf(chan, smp_processor_id()); + + v_inc(config, &buf->records_lost_big); +} +EXPORT_SYMBOL_GPL(lib_ring_buffer_lost_event_too_big); + /** * lib_ring_buffer_reserve_slow - Atomic slot reservation in a buffer. * @ctx: ring buffer context. @@ -1759,12 +1778,7 @@ int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx) struct switch_offsets offsets; int ret; - if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) - buf = per_cpu_ptr(chan->backend.buf, ctx->cpu); - else - buf = chan->backend.buf; - ctx->buf = buf; - + ctx->buf = buf = get_current_buf(chan, ctx->cpu); offsets.size = 0; do { -- 2.34.1