Skip to content

Commit 1fe942f

Browse files
tobonexkv2019i
authored andcommitted
performance_monitor: fix issue with freeing bitmap
Zephyr's bitarray had a problem when clearing the bit before freeing it. Not clearing it changes nothing in overall logic so we can just not do it. Also fixes and issue with computing bitmap idx. Signed-off-by: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
1 parent 1e5b284 commit 1fe942f

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

src/debug/telemetry/performance_monitor.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static int perf_bitmap_setbit(struct perf_bitmap * const bitmap, size_t bit)
100100
return sys_bitarray_set_bit(bitmap->array, bit);
101101
}
102102

103+
__attribute__((unused))
103104
static int perf_bitmap_clearbit(struct perf_bitmap * const bitmap, size_t bit)
104105
{
105106
return sys_bitarray_clear_bit(bitmap->array, bit);
@@ -145,12 +146,8 @@ struct perf_data_item_comp *perf_data_getnext(void)
145146
int perf_data_free(struct perf_data_item_comp * const item)
146147
{
147148
/* find index of item */
148-
int idx = (item - perf_data) / sizeof(*item);
149-
int ret = perf_bitmap_clearbit(&performance_data_bitmap, idx);
150-
151-
if (ret < 0)
152-
return ret;
153-
ret = perf_bitmap_free(&performance_data_bitmap, idx);
149+
int idx = (item - perf_data);
150+
int ret = perf_bitmap_free(&performance_data_bitmap, idx);
154151
if (ret < 0)
155152
return ret;
156153

@@ -473,10 +470,6 @@ int io_perf_monitor_release_slot(struct io_perf_data_item *item)
473470
k_spin_unlock(&self->lock, key);
474471

475472
/* we assign data items ourselves so neither of those should ever fail */
476-
ret = perf_bitmap_clearbit(&self->io_performance_data_bitmap, idx);
477-
assert(!ret);
478-
if (ret < 0)
479-
return ret;
480473
ret = perf_bitmap_free(&self->io_performance_data_bitmap, idx);
481474
assert(!ret);
482475
return ret;

0 commit comments

Comments
 (0)