Re: [PATCH 2/4 v6] lib: debugobjects: add global free list and the counter
From: Thomas Gleixner
Date: Mon Feb 12 2018 - 10:55:23 EST
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.
Actually not in this patch, but in the next one.
Thanks,
tglx