Use -EIO as tsc value for nmi error (and drop event)
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 May 2011 12:00:14 +0000 (08:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 May 2011 12:00:14 +0000 (08:00 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/frontend_api.h
lib/ringbuffer/ring_buffer_frontend.c
wrapper/trace-clock.h

index d55eb33e31601658e15ca83865422be136b00fcb..8a58ace456ad29ab3235484ec52a01e15bc6e6d3 100644 (file)
@@ -82,6 +82,8 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
        *o_old = *o_begin;
 
        ctx->tsc = lib_ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->tsc == -EIO)
+               return 1;
 
        /*
         * Prefetch cacheline for read because we have to read the previous
@@ -130,8 +132,12 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
  * Atomic wait-free slot reservation. The reserved space starts at the context
  * "pre_offset". Its length is "slot_size". The associated time-stamp is "tsc".
  *
- * Return : -ENOSPC if not enough space, -EAGAIN if channel is disabled.
- *          Returns 0 on success.
+ * Return :
+ *  0 on success.
+ * -EAGAIN if channel is disabled.
+ * -ENOSPC if event size is too large for packet.
+ * -ENOBUFS if there is currently not enough space in buffer for the event.
+ * -EIO if data cannot be written into the buffer for any other reason.
  */
 
 static inline
index d48d66b32779e90c7baa8dacf7475d57da5cf252..9a90997c278b4b49086a03d2e4c16e3e1ea743a0 100644 (file)
@@ -1482,7 +1482,9 @@ EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_slow);
 /*
  * Returns :
  * 0 if ok
- * !0 if execution must be aborted.
+ * -ENOSPC if event size is too large for packet.
+ * -ENOBUFS if there is currently not enough space in buffer for the event.
+ * -EIO if data cannot be written into the buffer for any other reason.
  */
 static
 int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
@@ -1501,6 +1503,8 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
        offsets->pre_header_padding = 0;
 
        ctx->tsc = config->cb.ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->tsc == -EIO)
+               return -EIO;
 
        if (last_tsc_overflow(config, buf, ctx->tsc))
                ctx->rflags = RING_BUFFER_RFLAG_FULL_TSC;
@@ -1553,7 +1557,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
                                 * and we are full : record is lost.
                                 */
                                v_inc(config, &buf->records_lost_full);
-                               return -1;
+                               return -ENOBUFS;
                        } else {
                                /*
                                 * Next subbuffer not being written to, and we
@@ -1570,7 +1574,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
                         * many nested writes over a reserve/commit pair.
                         */
                        v_inc(config, &buf->records_lost_wrap);
-                       return -1;
+                       return -EIO;
                }
                offsets->size =
                        config->cb.record_header_size(config, chan,
@@ -1589,7 +1593,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
                         * complete the sub-buffer switch.
                         */
                        v_inc(config, &buf->records_lost_big);
-                       return -1;
+                       return -ENOSPC;
                } else {
                        /*
                         * We just made a successful buffer switch and the
@@ -1618,7 +1622,8 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
  * lib_ring_buffer_reserve_slow - Atomic slot reservation in a buffer.
  * @ctx: ring buffer context.
  *
- * Return : -ENOSPC if not enough space, else returns 0.
+ * Return : -NOBUFS if not enough space, -ENOSPC if event size too large,
+ * -EIO for other errors, else returns 0.
  * It will take care of sub-buffer switching.
  */
 int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx)
@@ -1637,9 +1642,10 @@ int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx)
        offsets.size = 0;
 
        do {
-               if (unlikely(lib_ring_buffer_try_reserve_slow(buf, chan, &offsets,
-                                                         ctx)))
-                       return -ENOSPC;
+               ret = lib_ring_buffer_try_reserve_slow(buf, chan, &offsets,
+                                                      ctx);
+               if (unlikely(ret))
+                       return ret;
        } while (unlikely(v_cmpxchg(config, &buf->offset, offsets.old,
                                    offsets.end)
                          != offsets.old));
index 18cda2aa1355dc98306ab8fe3a1b24f2e9ecdb9b..b2a90bd462e292f0f3f4eed6dd021da9b39138d0 100644 (file)
@@ -28,7 +28,7 @@ static inline u64 trace_clock_monotonic_wrapper(void)
         * nest over the xtime write seqlock and deadlock.
         */
        if (in_nmi())
-               return 0;
+               return (u64) -EIO;
 
        ktime = ktime_get();
        return (u64) ktime.tv64;
This page took 0.0293 seconds and 4 git commands to generate.