History

debugobjects: Provide and use free_object_list()

Move the loop to free a list of objects into a helper function so it can be reused later.

Thomas Gleixner committed 2 years ago

Commit 49a5cb81 parent 241463f1 file · +16 −6Browse files

Showing the changes to lib/debugobjects.c (1 of 1 file). Show all

Unified · Split

lib/debugobjects.c+16−6
@@ -125,6 +125,20 @@ static const char *obj_states[ODEBUG_STATE_MAX] = { · 124 unmodified lines
125 [ODEBUG_STATE_NOTAVAILABLE] = "not available",125 [ODEBUG_STATE_NOTAVAILABLE] = "not available",
126};126};
127 127
128static void free_object_list(struct hlist_head *head)
129{
130 struct hlist_node *tmp;
131 struct debug_obj *obj;
132 int cnt = 0;
133
134 hlist_for_each_entry_safe(obj, tmp, head, node) {
135 hlist_del(&obj->node);
136 kmem_cache_free(obj_cache, obj);
137 cnt++;
138 }
139 debug_objects_freed += cnt;
140}
141
128static void fill_pool(void)142static void fill_pool(void)
129{143{
130 gfp_t gfp = __GFP_HIGH | __GFP_NOWARN;144 gfp_t gfp = __GFP_HIGH | __GFP_NOWARN;
@@ -286,7 +300,6 @@ init_obj: · 155 unmodified lines
286 */300 */
287static void free_obj_work(struct work_struct *work)301static void free_obj_work(struct work_struct *work)
288{302{
289 struct hlist_node *tmp;
290 struct debug_obj *obj;303 struct debug_obj *obj;
291 unsigned long flags;304 unsigned long flags;
292 HLIST_HEAD(tofree);305 HLIST_HEAD(tofree);
@@ -323,15 +336,11 @@ free_objs: · 30 unmodified lines
323 */336 */
324 if (obj_nr_tofree) {337 if (obj_nr_tofree) {
325 hlist_move_list(&obj_to_free, &tofree);338 hlist_move_list(&obj_to_free, &tofree);
326 debug_objects_freed += obj_nr_tofree;
327 WRITE_ONCE(obj_nr_tofree, 0);339 WRITE_ONCE(obj_nr_tofree, 0);
328 }340 }
329 raw_spin_unlock_irqrestore(&pool_lock, flags);341 raw_spin_unlock_irqrestore(&pool_lock, flags);
330 342
331 hlist_for_each_entry_safe(obj, tmp, &tofree, node) {343 free_object_list(&tofree);
332 hlist_del(&obj->node);
333 kmem_cache_free(obj_cache, obj);
334 }
335}344}
336 345
337static void __free_object(struct debug_obj *obj)346static void __free_object(struct debug_obj *obj)
@@ -1334,6 +1343,7 @@ static bool __init debug_objects_replace_static_objects(struct kmem_cache *cache · 996 unmodified lines
1334 }1343 }
1335 return true;1344 return true;
1336free:1345free:
1346 /* Can't use free_object_list() as the cache is not populated yet */
1337 hlist_for_each_entry_safe(obj, tmp, &objects, node) {1347 hlist_for_each_entry_safe(obj, tmp, &objects, node) {
1338 hlist_del(&obj->node);1348 hlist_del(&obj->node);
1339 kmem_cache_free(cache, obj);1349 kmem_cache_free(cache, obj);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t