On Tue, Aug 19, 2025 at 11:27:23PM -0400, Waiman Long wrote:
On 8/18/25 5:09 AM, Gu Bowen wrote:
@@ -858,8 +870,14 @@ static void delete_object_part(unsigned long ptr, size_t size, object = __find_and_remove_object(ptr, 1, objflags); if (!object) { #ifdef DEBUG
/*
* Printk deferring due to the kmemleak_lock held.
* This is done to avoid deadlock.
*/
kmemleak_warn("Partially freeing unknown object at 0x%08lx (size %zu)\n", ptr, size);printk_deferred_enter();
#endifprintk_deferred_exit();
This particular warning message can be moved after unlock by adding a warning flag. Locking is done outside of the other two helper functions above, so it is easier to use printk_deferred_enter/exit() for those.
I thought about this as well but the above is under an #ifdef DEBUG so we end up adding more lines on the unlock path (not sure which one looks better; I'd say the above, marginally).
Another option would be to remove the #ifdef and try to identify the call sites that trigger the warning. Last time I checked (many years ago) they were fairly benign and decided to hide them before an #ifdef.