From: Mathieu Desnoyers Date: Mon, 19 Sep 2016 01:45:32 +0000 (-0400) Subject: Cleanup: libringbuffer: remove duplicate shmp() invocations in slow paths X-Git-Tag: v2.9.0-rc1~14 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=3d3c3833d4d119acde0a3fdb2c472aea010cd7e7 Cleanup: libringbuffer: remove duplicate shmp() invocations in slow paths Signed-off-by: Mathieu Desnoyers --- diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index accd5dc5..e631ae3d 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -1609,6 +1609,7 @@ void lib_ring_buffer_switch_old_start(struct lttng_ust_lib_ring_buffer *buf, const struct lttng_ust_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, handle); @@ -1617,16 +1618,16 @@ void lib_ring_buffer_switch_old_start(struct lttng_ust_lib_ring_buffer *buf, * determine that the subbuffer is full. */ cmm_smp_wmb(); + cc_hot = shmp_index(handle, buf->commit_hot, oldidx); v_add(config, config->cb.subbuffer_header_size(), - &shmp_index(handle, buf->commit_hot, oldidx)->cc); - commit_count = v_read(config, &shmp_index(handle, buf->commit_hot, oldidx)->cc); + &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, handle, tsc); lib_ring_buffer_write_commit_counter(config, buf, chan, offsets->old + config->cb.subbuffer_header_size(), - commit_count, handle, - shmp_index(handle, buf->commit_hot, oldidx)); + commit_count, handle, cc_hot); } /* @@ -1647,6 +1648,7 @@ void lib_ring_buffer_switch_old_end(struct lttng_ust_lib_ring_buffer *buf, const struct lttng_ust_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; @@ -1658,13 +1660,14 @@ void lib_ring_buffer_switch_old_end(struct lttng_ust_lib_ring_buffer *buf, * determine that the subbuffer is full. */ cmm_smp_wmb(); - v_add(config, padding_size, &shmp_index(handle, buf->commit_hot, oldidx)->cc); - commit_count = v_read(config, &shmp_index(handle, buf->commit_hot, oldidx)->cc); + cc_hot = shmp_index(handle, 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, handle, tsc); lib_ring_buffer_write_commit_counter(config, buf, chan, offsets->old + padding_size, commit_count, handle, - shmp_index(handle, buf->commit_hot, oldidx)); + cc_hot); } /* @@ -1684,6 +1687,7 @@ void lib_ring_buffer_switch_new_start(struct lttng_ust_lib_ring_buffer *buf, const struct lttng_ust_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, handle); @@ -1694,14 +1698,14 @@ void lib_ring_buffer_switch_new_start(struct lttng_ust_lib_ring_buffer *buf, cmm_smp_wmb(); v_add(config, config->cb.subbuffer_header_size(), &shmp_index(handle, buf->commit_hot, beginidx)->cc); - commit_count = v_read(config, &shmp_index(handle, buf->commit_hot, beginidx)->cc); + cc_hot = shmp_index(handle, buf->commit_hot, beginidx); + 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, handle, tsc); lib_ring_buffer_write_commit_counter(config, buf, chan, offsets->begin + config->cb.subbuffer_header_size(), - commit_count, handle, - shmp_index(handle, buf->commit_hot, beginidx)); + commit_count, handle, cc_hot); } /*