Re: [PATCH 2/4 v6] lib: debugobjects: add global free list and the counter

From: Yang Shi
Date: Mon Feb 12 2018 - 13:53:49 EST




On 2/12/18 7:54 AM, Thomas Gleixner wrote:
On Mon, 12 Feb 2018, Thomas Gleixner wrote:
On Tue, 6 Feb 2018, Yang Shi wrote:
+ /*
+ * The objs on the pool list might be allocated before the work is
+ * run, so recheck if pool list it full or not, if not fill pool
+ * list from the global free list
+ */
+ while (obj_pool_free < debug_objects_pool_size) {
+ if (obj_nr_tofree <= 0)
+ break;
+
+ obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
+ hlist_del(&obj->node);
+ hlist_add_head(&obj->node, &obj_pool);
+ obj_pool_free++;
+ obj_nr_tofree--;
+ }
+
+ /*
+ * pool list is already full, and there are still objs on the free list,
+ * move remaining free objs to a separate list to free the memory later.
+ */
+ if (obj_nr_tofree > 0) {
+ hlist_move_list(&obj_to_free, &tofree);
+ obj_nr_tofree = 0;
+ }
+
while (obj_pool_free >= debug_objects_pool_size + ODEBUG_FREE_BATCH) {
for (i = 0; i < ODEBUG_FREE_BATCH; i++) {
objs[i] = hlist_entry(obj_pool.first,
This whole section is now pointless and can be removed. There is no way
that this code path can be entered after this change. Surplus objects are
on the obj_to_free list and not on the obj_pool itself.

Yes, it is correct. I think the whole ODEBUG_FREE_BATCH thing can be removed too.

Will do it in the next version.

Regards,
Yang

Actually not in this patch, but in the next one.

Thanks,

tglx