histograms: add function to merge histograms

Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: I75f737a7e0a5490eeb183e6fa922fa8e17d30268

Reviewed-on: https://review.gerrithub.io/432558
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Piotr Pelplinski 2018-11-08 10:07:29 +01:00 committed by Jim Harris
parent 84c168fa65
commit a3f7d8aa4d

View File

@ -106,6 +106,12 @@ __spdk_histogram_get_count(const struct spdk_histogram_data *h, uint32_t range,
return h->bucket[(range << SPDK_HISTOGRAM_BUCKET_SHIFT(h)) + index];
}
static inline uint64_t *
__spdk_histogram_get_bucket(const struct spdk_histogram_data *h, uint32_t range, uint32_t index)
{
return &h->bucket[(range << SPDK_HISTOGRAM_BUCKET_SHIFT(h)) + index];
}
static inline void
spdk_histogram_data_reset(struct spdk_histogram_data *histogram)
{
@ -203,6 +209,17 @@ spdk_histogram_data_iterate(const struct spdk_histogram_data *histogram,
}
}
static inline void
spdk_histogram_data_merge(const struct spdk_histogram_data *dst,
const struct spdk_histogram_data *src)
{
uint64_t i;
for (i = 0; i < SPDK_HISTOGRAM_NUM_BUCKETS(dst); i++) {
dst->bucket[i] += src->bucket[i];
}
}
static inline struct spdk_histogram_data *
spdk_histogram_data_alloc_sized(uint32_t bucket_shift)
{