Re: [patch 08/25] debugobjects: Provide and use free_object_list()
From: Thomas Gleixner
Date: Fri Oct 11 2024 - 16:40:30 EST
On Thu, Oct 10 2024 at 10:54, Leizhen wrote:
> On 2024/10/8 0:50, Thomas Gleixner wrote:
>> Move the loop to free a list of objects into a helper function so it can be
>> reused later.
>>
>> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>> ---
>> lib/debugobjects.c | 22 ++++++++++++++++------
>> 1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> --- a/lib/debugobjects.c
>> +++ b/lib/debugobjects.c
>> @@ -125,6 +125,20 @@ static const char *obj_states[ODEBUG_STA
>> [ODEBUG_STATE_NOTAVAILABLE] = "not available",
>> };
>>
>> +static void free_object_list(struct hlist_head *head)
>> +{
>> + struct hlist_node *tmp;
>> + struct debug_obj *obj;
>> + int cnt = 0;
>> +
>> + hlist_for_each_entry_safe(obj, tmp, head, node) {
>> + hlist_del(&obj->node);
>> + kmem_cache_free(obj_cache, obj);
>> + cnt++;
>> + }
>> + debug_objects_freed += cnt;
>
> debug_objects_freed was previously protected by pool_lock. Use atomic?
It's statistics, so I'm not really worried about it whether it's a bit
off or not.
But aside of that the freeing is single threaded because objects are
only handed back to the kmem_cache from the worker thread.
Thanks,
tglx