linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Xiaolei Wang <xiaolei.wang@windriver.com>
Cc: akpm@linux-foundation.org, vbabka@suse.cz, glider@google.com,
	andreyknvl@gmail.com, zhaoyang.huang@unisoc.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm/kmemleak: use object_cache instead of kmemleak_initialized to check in set_track_prepare()
Date: Tue, 15 Aug 2023 11:39:52 +0100	[thread overview]
Message-ID: <ZNtV+MvSSf3TM+fU@arm.com> (raw)
In-Reply-To: <20230815051358.802035-2-xiaolei.wang@windriver.com>

On Tue, Aug 15, 2023 at 01:13:57PM +0800, Xiaolei Wang wrote:
> kmemleak_initialized is set in kmemleak_late_init(), which
> also means that there is no call trace which object's memory
> leak is before kmemleak_late_init(), so use object_cache instead
> of kmemleak_initialized to check in set_track_prepare() to avoid
> no call trace records when there is a memory leak in the code
> between kmemleak_init() and kmemleak_late_init().
> 
> unreferenced object 0xc674ca80 (size 64):
>  comm "swapper/0", pid 1, jiffies 4294938337 (age 204.880s)
>  hex dump (first 32 bytes):
>   80 55 75 c6 80 54 75 c6 00 55 75 c6 80 52 75 c6 .Uu..Tu..Uu..Ru.
>   00 53 75 c6 00 00 00 00 00 00 00 00 00 00 00 00 .Su..........
> 
> Fixes: 56a61617dd22 ("mm: use stack_depot for recording kmemleak's backtrace")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
>  mm/kmemleak.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index a2d34226e3c8..04bb4cdbb402 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -610,7 +610,8 @@ static noinline depot_stack_handle_t set_track_prepare(void)
>  	unsigned long entries[MAX_TRACE];
>  	unsigned int nr_entries;
>  
> -	if (!kmemleak_initialized)
> +	/*Use object_cache to determine whether kmemleak_init() is complete*/

Nitpick: please add spaces after/before the comment delimiters. I'd also
make it clearer that it's not about kmemleak being initialised but
rather the stack depot. E.g.:

	/*
	 * Use object_cache to determine whether kmemleak_init() has
	 * been invoked. stack_depot_early_init() is called before
	 * kmemleak_init() in mm_core_init().
	 */

> +	if (!object_cache)
>  		return 0;
>  	nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 3);
>  	trace_handle = stack_depot_save(entries, nr_entries, GFP_NOWAIT);

Otherwise:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>


  reply	other threads:[~2023-08-15 10:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15  5:13 [PATCH v2 0/2] mm/kmemleak: use object_cache instead of kmemleak_initialized Xiaolei Wang
2023-08-15  5:13 ` [PATCH v2 1/2] mm/kmemleak: use object_cache instead of kmemleak_initialized to check in set_track_prepare() Xiaolei Wang
2023-08-15 10:39   ` Catalin Marinas [this message]
2023-08-15  5:13 ` [PATCH v2 2/2] Rename kmemleak_initialized to kmemleak_late_initialized Xiaolei Wang
2023-08-15 10:40   ` Catalin Marinas

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=ZNtV+MvSSf3TM+fU@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    --cc=xiaolei.wang@windriver.com \
    --cc=zhaoyang.huang@unisoc.com \
    /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