libringbuffer: implement event too big API
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 19 Mar 2016 15:34:22 +0000 (11:34 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 2 May 2016 16:37:33 +0000 (12:37 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/frontend_types.h
lib/ringbuffer/ring_buffer_frontend.c

index 46bf8d27efda7741fc407e79c0553bdff6ab9702..ef63cb5005ab61604bf5da32c69171a6a120890a 100644 (file)
@@ -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
index 9ebdd5fbeefab0090d4353e42cf768e462b1647e..c92e9271fe978cc0abb940420d0e3cff268518f7 100644 (file)
@@ -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 {
This page took 0.027509 seconds and 4 git commands to generate.