mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kmemleak: Show where early_log issues come from
Date: Fri, 12 Aug 2011 10:40:18 +0100	[thread overview]
Message-ID: <20110812094018.GA1639@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <1311701636.3526.97.camel@gandalf.stny.rr.com>

Hi Steven,

On Tue, Jul 26, 2011 at 06:33:56PM +0100, Steven Rostedt wrote:
> The backtrace is from where the problem was detected, not where the
> problem occurred. I also noticed that the logs that are stored include a
> stack_trace dump. But this trace is only added when ALLOC is done.
> 
> The above issues ended up being from the cgroup code calling
> kmemleak_not_leak(), which does not store the trace. But that didn't
> matter, because even if it did, the trace is not printed out here
> leaving the above output still unhelpful in finding where the problem
> occurred.
> 
> By having all early kmemleak logs record the stack_trace, and by having
> the above error message / detection bubble up the call stack that an
> error occurred. We can have kmemleak_init() write exactly where the
> problem occurred.
...
> @@ -1708,10 +1730,12 @@ void __init kmemleak_init(void)
>  			kmemleak_free_part(log->ptr, log->size);
>  			break;
>  		case KMEMLEAK_NOT_LEAK:
> -			kmemleak_not_leak(log->ptr);
> +			if (__kmemleak_not_leak(log->ptr) < 0)
> +				print_log_stack(log);
>  			break;
>  		case KMEMLEAK_IGNORE:
> -			kmemleak_ignore(log->ptr);
> +			if (__kmemleak_ignore(log->ptr) < 0)
> +				print_log_stack(log);
>  			break;
>  		case KMEMLEAK_SCAN_AREA:
>  			kmemleak_scan_area(log->ptr, log->size, GFP_KERNEL);

Thanks for the patch, it makes sense. I was wondering whether we should
extend the above to the other early kmemleak API calls (apart from
KMEMLEAK_ALLOC). Also, to avoid some code duplication, maybe something
like below:

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index d6880f5..afec4cb 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1696,32 +1696,37 @@ void __init kmemleak_init(void)
 	 */
 	for (i = 0; i < crt_early_log; i++) {
 		struct early_log *log = &early_log[i];
+		int ret = 0;
 
 		switch (log->op_type) {
 		case KMEMLEAK_ALLOC:
 			early_alloc(log);
 			break;
 		case KMEMLEAK_FREE:
-			kmemleak_free(log->ptr);
+			ret = __kmemleak_free(log->ptr);
 			break;
 		case KMEMLEAK_FREE_PART:
-			kmemleak_free_part(log->ptr, log->size);
+			ret = __kmemleak_free_part(log->ptr, log->size);
 			break;
 		case KMEMLEAK_NOT_LEAK:
-			kmemleak_not_leak(log->ptr);
+			ret = __kmemleak_not_leak(log->ptr);
 			break;
 		case KMEMLEAK_IGNORE:
-			kmemleak_ignore(log->ptr);
+			ret = __kmemleak_ignore(log->ptr);
 			break;
 		case KMEMLEAK_SCAN_AREA:
-			kmemleak_scan_area(log->ptr, log->size, GFP_KERNEL);
+			ret = __kmemleak_scan_area(log->ptr, log->size,
+						   GFP_KERNEL);
 			break;
 		case KMEMLEAK_NO_SCAN:
-			kmemleak_no_scan(log->ptr);
+			ret = __kmemleak_no_scan(log->ptr);
 			break;
 		default:
 			WARN_ON(1);
 		}
+
+		if (ret < 0)
+			print_log_stack(log);
 	}
 }
 

Thanks.

-- 
Catalin

  reply	other threads:[~2011-08-12  9:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26 17:33 Steven Rostedt
2011-08-12  9:40 ` Catalin Marinas [this message]
2011-08-12 13:17   ` Steven Rostedt
2011-09-28 13:07 Catalin Marinas
2011-09-28 13:52 ` Steven Rostedt

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=20110812094018.GA1639@e102109-lin.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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®