mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Dmitry Safonov <dima@arista.com>, linux-kernel@vger.kernel.org
Cc: 0x7f454c46@gmail.com, kernel test robot <rong.a.chen@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2/2] debugobjects: Print warnings outside bucket lock
Date: Thu, 13 Dec 2018 17:04:13 -0500	[thread overview]
Message-ID: <005b2528-bc58-957f-916f-d09419593e8e@redhat.com> (raw)
In-Reply-To: <20181213043447.23006-2-dima@arista.com>

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@shao2-debian
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Waiman Long <longman@redhat.com>
> Signed-off-by: Dmitry Safonov <dima@arista.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

  reply	other threads:[~2018-12-13 22:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13  4:34 [PATCH 1/2] debugobjects: Warn wrong annotation " Dmitry Safonov
2018-12-13  4:34 ` [PATCH 2/2] debugobjects: Print warnings " Dmitry Safonov
2018-12-13 22:04   ` Waiman Long [this message]
2018-12-13  9:28 ` [PATCH 1/2] debugobjects: Warn wrong annotation " Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=005b2528-bc58-957f-916f-d09419593e8e@redhat.com \
    --to=longman@redhat.com \
    --cc=0x7f454c46@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dima@arista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rong.a.chen@intel.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®