From 9f1291cf1d4247baf20ef5064fa61cfac41001ec Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Wed, 20 Feb 2013 13:15:58 +1100 Subject: [PATCH] lockdep: check that no locks held at freeze time We shouldn't try_to_freeze if locks are held. Verified that I get no lockdep warnings after applying this patch and "vfork: don't freezer_count() for in-kernel users of CLONE_VFORK". Signed-off-by: Mandeep Singh Baines Cc: Ben Chan Cc: Oleg Nesterov Cc: Tejun Heo Cc: Rafael J. Wysocki Cc: Ingo Molnar Signed-off-by: Andrew Morton --- include/linux/freezer.h | 2 ++ kernel/lockdep.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index e70df40d84f6..2d34ec51ce7a 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -3,6 +3,7 @@ #ifndef FREEZER_H_INCLUDED #define FREEZER_H_INCLUDED +#include #include #include #include @@ -48,6 +49,7 @@ extern void thaw_kernel_threads(void); static inline bool try_to_freeze(void) { + debug_check_no_locks_held(current); might_sleep(); if (likely(!freezing(current))) return false; diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 8a0efac4f99d..0008e70ad7ea 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -4096,10 +4096,10 @@ static void print_held_locks_bug(struct task_struct *curr) return; printk("\n"); - printk("=====================================\n"); - printk("[ BUG: lock held at task exit time! ]\n"); + printk("=======================================\n"); + printk("[ BUG: lock held at exit/freeze time! ]\n"); print_kernel_ident(); - printk("-------------------------------------\n"); + printk("---------------------------------------\n"); printk("%s/%d is exiting with locks still held!\n", curr->comm, task_pid_nr(curr)); lockdep_print_held_locks(curr); -- 2.39.5