btrfs instrumentation: update to 4.10 kernel
[lttng-modules.git] / lib / ringbuffer / ring_buffer_frontend.c
index c5123a6415e39afc75cc55b8208b9b6924fbf975..5d4be3b3dcf4ddc60920377c3d1f160ceb629261 100644 (file)
@@ -247,7 +247,8 @@ int lib_ring_buffer_create(struct lib_ring_buffer *buf,
                kzalloc_node(ALIGN(sizeof(*buf->commit_hot)
                                   * chan->backend.num_subbuf,
                                   1 << INTERNODE_CACHE_SHIFT),
-                       GFP_KERNEL, cpu_to_node(max(cpu, 0)));
+                       GFP_KERNEL | __GFP_NOWARN,
+                       cpu_to_node(max(cpu, 0)));
        if (!buf->commit_hot) {
                ret = -ENOMEM;
                goto free_chanbuf;
@@ -257,7 +258,8 @@ int lib_ring_buffer_create(struct lib_ring_buffer *buf,
                kzalloc_node(ALIGN(sizeof(*buf->commit_cold)
                                   * chan->backend.num_subbuf,
                                   1 << INTERNODE_CACHE_SHIFT),
-                       GFP_KERNEL, cpu_to_node(max(cpu, 0)));
+                       GFP_KERNEL | __GFP_NOWARN,
+                       cpu_to_node(max(cpu, 0)));
        if (!buf->commit_cold) {
                ret = -ENOMEM;
                goto free_commit;
@@ -1356,6 +1358,7 @@ void lib_ring_buffer_switch_old_start(struct lib_ring_buffer *buf,
        const struct lib_ring_buffer_config *config = &chan->backend.config;
        unsigned long oldidx = subbuf_index(offsets->old, chan);
        unsigned long commit_count;
+       struct commit_counters_hot *cc_hot;
 
        config->cb.buffer_begin(buf, tsc, oldidx);
 
@@ -1372,15 +1375,15 @@ void lib_ring_buffer_switch_old_start(struct lib_ring_buffer *buf,
                barrier();
        } else
                smp_wmb();
-       v_add(config, config->cb.subbuffer_header_size(),
-             &buf->commit_hot[oldidx].cc);
-       commit_count = v_read(config, &buf->commit_hot[oldidx].cc);
+       cc_hot = &buf->commit_hot[oldidx];
+       v_add(config, config->cb.subbuffer_header_size(), &cc_hot->cc);
+       commit_count = v_read(config, &cc_hot->cc);
        /* Check if the written buffer has to be delivered */
        lib_ring_buffer_check_deliver(config, buf, chan, offsets->old,
                                      commit_count, oldidx, tsc);
-       lib_ring_buffer_write_commit_counter(config, buf, chan, oldidx,
+       lib_ring_buffer_write_commit_counter(config, buf, chan,
                        offsets->old + config->cb.subbuffer_header_size(),
-                       commit_count);
+                       commit_count, cc_hot);
 }
 
 /*
@@ -1400,6 +1403,7 @@ void lib_ring_buffer_switch_old_end(struct lib_ring_buffer *buf,
        const struct lib_ring_buffer_config *config = &chan->backend.config;
        unsigned long oldidx = subbuf_index(offsets->old - 1, chan);
        unsigned long commit_count, padding_size, data_size;
+       struct commit_counters_hot *cc_hot;
 
        data_size = subbuf_offset(offsets->old - 1, chan) + 1;
        padding_size = chan->backend.subbuf_size - data_size;
@@ -1418,12 +1422,14 @@ void lib_ring_buffer_switch_old_end(struct lib_ring_buffer *buf,
                barrier();
        } else
                smp_wmb();
-       v_add(config, padding_size, &buf->commit_hot[oldidx].cc);
-       commit_count = v_read(config, &buf->commit_hot[oldidx].cc);
+       cc_hot = &buf->commit_hot[oldidx];
+       v_add(config, padding_size, &cc_hot->cc);
+       commit_count = v_read(config, &cc_hot->cc);
        lib_ring_buffer_check_deliver(config, buf, chan, offsets->old - 1,
                                      commit_count, oldidx, tsc);
-       lib_ring_buffer_write_commit_counter(config, buf, chan, oldidx,
-                       offsets->old + padding_size, commit_count);
+       lib_ring_buffer_write_commit_counter(config, buf, chan,
+                       offsets->old + padding_size, commit_count,
+                       cc_hot);
 }
 
 /*
@@ -1442,6 +1448,7 @@ void lib_ring_buffer_switch_new_start(struct lib_ring_buffer *buf,
        const struct lib_ring_buffer_config *config = &chan->backend.config;
        unsigned long beginidx = subbuf_index(offsets->begin, chan);
        unsigned long commit_count;
+       struct commit_counters_hot *cc_hot;
 
        config->cb.buffer_begin(buf, tsc, beginidx);
 
@@ -1458,15 +1465,15 @@ void lib_ring_buffer_switch_new_start(struct lib_ring_buffer *buf,
                barrier();
        } else
                smp_wmb();
-       v_add(config, config->cb.subbuffer_header_size(),
-             &buf->commit_hot[beginidx].cc);
-       commit_count = v_read(config, &buf->commit_hot[beginidx].cc);
+       cc_hot = &buf->commit_hot[beginidx];
+       v_add(config, config->cb.subbuffer_header_size(), &cc_hot->cc);
+       commit_count = v_read(config, &cc_hot->cc);
        /* Check if the written buffer has to be delivered */
        lib_ring_buffer_check_deliver(config, buf, chan, offsets->begin,
                                      commit_count, beginidx, tsc);
-       lib_ring_buffer_write_commit_counter(config, buf, chan, beginidx,
+       lib_ring_buffer_write_commit_counter(config, buf, chan,
                        offsets->begin + config->cb.subbuffer_header_size(),
-                       commit_count);
+                       commit_count, cc_hot);
 }
 
 /*
@@ -1980,6 +1987,33 @@ void lib_ring_buffer_vmcore_check_deliver(const struct lib_ring_buffer_config *c
                v_set(config, &buf->commit_hot[idx].seq, commit_count);
 }
 
+/*
+ * The ring buffer can count events recorded and overwritten per buffer,
+ * but it is disabled by default due to its performance overhead.
+ */
+#ifdef LTTNG_RING_BUFFER_COUNT_EVENTS
+static
+void deliver_count_events(const struct lib_ring_buffer_config *config,
+               struct lib_ring_buffer *buf,
+               unsigned long idx)
+{
+       v_add(config, subbuffer_get_records_count(config,
+                       &buf->backend, idx),
+               &buf->records_count);
+       v_add(config, subbuffer_count_records_overrun(config,
+                       &buf->backend, idx),
+               &buf->records_overrun);
+}
+#else /* LTTNG_RING_BUFFER_COUNT_EVENTS */
+static
+void deliver_count_events(const struct lib_ring_buffer_config *config,
+               struct lib_ring_buffer *buf,
+               unsigned long idx)
+{
+}
+#endif /* #else LTTNG_RING_BUFFER_COUNT_EVENTS */
+
+
 void lib_ring_buffer_check_deliver_slow(const struct lib_ring_buffer_config *config,
                                   struct lib_ring_buffer *buf,
                                   struct channel *chan,
@@ -2032,15 +2066,7 @@ void lib_ring_buffer_check_deliver_slow(const struct lib_ring_buffer_config *con
                 * and any other writer trying to access this subbuffer
                 * in this state is required to drop records.
                 */
-               v_add(config,
-                     subbuffer_get_records_count(config,
-                                                 &buf->backend, idx),
-                     &buf->records_count);
-               v_add(config,
-                     subbuffer_count_records_overrun(config,
-                                                     &buf->backend,
-                                                     idx),
-                     &buf->records_overrun);
+               deliver_count_events(config, buf, idx);
                config->cb.buffer_end(buf, tsc, idx,
                                      lib_ring_buffer_get_data_size(config,
                                                                buf,
This page took 0.02516 seconds and 4 git commands to generate.