return res;
}
+static void cpu_records_clear(struct cpu_event_history *p)
+{
+ memset(p->_clear_begin, 0, p->_clear_end - p->_clear_begin);
+}
+
static void cpu_records_free(struct cpu_event_history **p)
{
XFREE(MTYPE_EVENT_STATS, *p);
for (ALL_LIST_ELEMENTS_RO(masters, ln, m)) {
frr_with_mutex (&m->mtx) {
struct cpu_event_history *item;
- struct cpu_records_head old[1];
- cpu_records_init(old);
- cpu_records_swap_all(old, m->cpu_records);
-
- while ((item = cpu_records_pop(old))) {
+ /* it isn't possible to free the memory here
+ * because some of these will be in use (e.g.
+ * the one we're currently running in!)
+ */
+ frr_each (cpu_records, m->cpu_records, item) {
if (item->types & filter)
- cpu_records_free(&item);
- else
- cpu_records_add(m->cpu_records,
- item);
+ cpu_records_clear(item);
}
-
- cpu_records_fini(old);
}
}
}
struct cpu_records_item item;
void (*func)(struct event *e);
+
+ /* fields between the pair of these two are nulled on "clear event cpu" */
+ char _clear_begin[0];
+
atomic_size_t total_cpu_warn;
atomic_size_t total_wall_warn;
atomic_size_t total_starv_warn;
} real;
struct time_stats cpu;
atomic_uint_fast32_t types;
+
+ /* end of cleared region */
+ char _clear_end[0];
+
const char *funcname;
};