[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <005b2528-bc58-957f-916f-d09419593e8e@redhat.com>
Date: Thu, 13 Dec 2018 17:04:13 -0500
From: Waiman Long <longman@...hat.com>
To: Dmitry Safonov <dima@...sta.com>, linux-kernel@...r.kernel.org
Cc: 0x7f454c46@...il.com, kernel test robot <rong.a.chen@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 2/2] debugobjects: Print warnings outside bucket lock
On 12/12/2018 11:34 PM, Dmitry Safonov wrote:
> Whenever debugobjects finds invalid pattern during life time of a kernel
> object such as:
> - Activation of uninitialized objects
> - Initialization of active objects
> - Usage of freed/destroyed objects
> it prints a warning and tries to make fixup over an object.
>
> Unfortunately, it becomes error-prone to use WARN() or printing under
> debugobjects bucket lock: printk() may defer work to workqueue, and
> realization of workqueues uses debugobjects. Further, console drivers
> use page allocator, potentially vmalloc() or slub/slab. Which reasonably
> makes lockdep to go nuts as there are debug_check_no_obj_freed() checks
> in allocators.
>
> Move printings out of debugobjets bucket lock to address the potential
> lockups.
>
> Link: lkml.kernel.org/r/20181211091154.GL23332@...o2-debian
> Reported-by: kernel test robot <rong.a.chen@...el.com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Waiman Long <longman@...hat.com>
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
> lib/debugobjects.c | 89 ++++++++++++++++++++++++----------------------
> 1 file changed, 47 insertions(+), 42 deletions(-)
>
> diff --git a/lib/debugobjects.c b/lib/debugobjects.c
> index 98968219405b..0c92e46cb588 100644
> --- a/lib/debugobjects.c
> +++ b/lib/debugobjects.c
> @@ -313,7 +313,7 @@ static struct debug_bucket *get_bucket(unsigned long addr)
> return &obj_hash[hash];
> }
>
> -static void debug_print_object(struct debug_obj *obj, char *msg)
> +static void __debug_print_object(struct debug_obj *obj, char *msg)
> {
> struct debug_obj_descr *descr = obj->descr;
> static int limit;
> @@ -330,6 +330,14 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
> debug_objects_warnings++;
> }
>
> +#define debug_print_object(obj, msg, lock, flags) \
> + do { \
> + struct debug_obj tmp = *obj; \
> + \
> + raw_spin_unlock_irqrestore(lock, flags); \
> + __debug_print_object(&tmp, msg); \
> + } while(0)
> +
My main problem with this patch is the hiding of the unlock call in the
macro. I will prefer matching unlocks to be clearly visible in the
function bodies. Otherwise, the readers may be confused.
Cheers,
Longman
Powered by blists - more mailing lists