Skip to contentSkip to conversation

debugobjects: fix debug_objects_freed accounting

PATCH Superseded Arnd Bergmann 2 participants 3 messages Feb 22, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 debugobjects: fix debug_objects_freed accounting

The removal of the batched object freeing has caused the debug_objects_freed to become read-only, and the reading is inside an ifdef, so gcc warns that it is completely unused without CONFIG_DEBUG_FS:

lib/debugobjects.c:71:14: error: 'debug_objects_freed' defined but not used [-Werror=unused-variable]

Assuming we are still interested in this number, this adds back code to count every instance we are about to free while we still hold the spinlock.

Fixes 636e1970fd7d ("debugobjects: Use global free list in free_object()")
---
 lib/debugobjects.c | 3 +++
 1 file changed, 3 insertions(+)
lib/debugobjects.c +3 -0
index faab2c4ea024..748288dba512 100644
@@ -235,6 +235,9 @@ static void free_obj_work(struct work_struct *work)
 		hlist_move_list(&obj_to_free, &tofree);
 		obj_nr_tofree = 0;
 	}
+	hlist_for_each_entry(obj, &tofree, node)
+		debug_objects_freed++;
+
 	raw_spin_unlock_irqrestore(&pool_lock, flags);
 
 	hlist_for_each_entry_safe(obj, tmp, &tofree, node) {
Signature · 1 line
2.9.0
#1 lore raw
Quoted 20 lines · Arnd Bergmann

The removal of the batched object freeing has caused the debug_objects_freed to become read-only, and the reading is inside an ifdef, so gcc warns that it is completely unused without CONFIG_DEBUG_FS:

lib/debugobjects.c:71:14: error: 'debug_objects_freed' defined but not used [-Werror=unused-variable]

Assuming we are still interested in this number, this adds back code to count every instance we are about to free while we still hold the spinlock.

Fixes 636e1970fd7d ("debugobjects: Use global free list in free_object()")
---
 lib/debugobjects.c | 3 +++
 1 file changed, 3 insertions(+)
lib/debugobjects.c +0 -0
index faab2c4ea024..748288dba512 100644

lib/debugobjects.c static void free_obj_work(struct work_struct *work) · line 235

Quoted 1 line
lib/debugobjects.c +0 -0
@@ -235,6 +235,9 @@ static void free_obj_work(struct work_struct *work)
 		hlist_move_list(&obj_to_free, &tofree);

It would be simpler to just do:

               debug_objects_freed += obj_nr_tofree;

lib/debugobjects.c static void free_obj_work(struct work_struct *work) · line 243

Quoted 8 lines
lib/debugobjects.c +3 -0
 		obj_nr_tofree = 0;
 	}
+	hlist_for_each_entry(obj, &tofree, node)
+		debug_objects_freed++;
+
 	raw_spin_unlock_irqrestore(&pool_lock, flags);
 
 	hlist_for_each_entry_safe(obj, tmp, &tofree, node) {

-Longman

#2 lore raw
Quoted 24 lines · Waiman Long
Quoted 20 lines · Arnd Bergmann

The removal of the batched object freeing has caused the debug_objects_freed to become read-only, and the reading is inside an ifdef, so gcc warns that it is completely unused without CONFIG_DEBUG_FS:

lib/debugobjects.c:71:14: error: 'debug_objects_freed' defined but not used [-Werror=unused-variable]

Assuming we are still interested in this number, this adds back code to count every instance we are about to free while we still hold the spinlock.

Fixes 636e1970fd7d ("debugobjects: Use global free list in free_object()")
---
 lib/debugobjects.c | 3 +++
 1 file changed, 3 insertions(+)
lib/debugobjects.c +0 -0
index faab2c4ea024..748288dba512 100644

lib/debugobjects.c static void free_obj_work(struct work_struct *work) · line 235

Quoted 1 line
lib/debugobjects.c +0 -0
@@ -235,6 +235,9 @@ static void free_obj_work(struct work_struct *work)
              hlist_move_list(&obj_to_free, &tofree);

It would be simpler to just do:

Quoted 2 lines
               debug_objects_freed += obj_nr_tofree;

Right, I missed that, sending v2 now.

Thanks for the review!

Arnd