Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1165570rdb; Wed, 16 Aug 2023 03:56:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/GlHFQWm7DlcWPixsZnif7hhBnwDTbM4Oi9Lm0ip++aKxgsmOqDfn90TAWLHMwLfAAvrB X-Received: by 2002:a05:6808:159c:b0:3a3:f92c:3f38 with SMTP id t28-20020a056808159c00b003a3f92c3f38mr2314155oiw.6.1692183412937; Wed, 16 Aug 2023 03:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692183412; cv=none; d=google.com; s=arc-20160816; b=i9vpXhYlocl5DTGwVE2qzaET8c4gkBvs9KwcN+vUpxL/L3uzne9N7di1n7gzt8nSSk YUx9ICFK2E6fOYUTRUxW89OrjMrnHecGWiLt+Kk1zmMs6cdSkgOwoK9jblAQQbNPORoI 1wHQCpl293cYD4njGHDYgaJ50MYoMkjTKSuDHDLPgzfb6po3gxzZIFzd7DUknoj6trbL WdE0lE93uC2ZpqrK4KROprRhyvbK1WQOfNJFiW1AA7s+aAWnT4KwUKIpQ9qgzZ/rDByY rFeQ6WGoJbEhzceV+SVGNmkQYcUHFZQ8QISWnSBt23oyAScKq241dRvyrGdKmDRKyQx8 Z5lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3gyv+Fe2kRF4t4UAImyxMYlz2KWNWd/t5KZRm4sI4P8=; fh=bQJDGEHJtXd+vCAvE14Ux/UT+xYgwT2Sl5ptYnEqXkk=; b=a35XhSkx//YT7Pz6XR+DuDsliGgoJfwet5/yAkAbrcRd9BAwSNEAya5yNNkfdXK443 185iVrlIJhFATn7YIqC5nt1M0apCfyBN++POlxlXz69YQ+dxISRQRKRqtPXaU/yFy0y+ kRsUFIA7rK6zApv7O6iEbkx4laVvuElklyqFf/jTgtYjkl5acwGDynjmr69UpnpZID4n wIrrax1cT8ENfXv9L4jz3l4Ftf+AzcMZnd400LADVRFCazPk8BNq3+ORQVt3QmxQQWEK lOClmdZBtK4Oh21VE9J4xl6FvNBDthQE9fuveKf5fSvmBcTyYySkUjFi3bst0Tab4SCC IWXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v135-20020a63618d000000b00565b3d7cfb5si1347429pgb.673.2023.08.16.03.56.38; Wed, 16 Aug 2023 03:56:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbjHOKkZ (ORCPT + 99 others); Tue, 15 Aug 2023 06:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236515AbjHOKkB (ORCPT ); Tue, 15 Aug 2023 06:40:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47C619B0 for ; Tue, 15 Aug 2023 03:39:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2A60465265 for ; Tue, 15 Aug 2023 10:39:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9224C433C7; Tue, 15 Aug 2023 10:39:54 +0000 (UTC) Date: Tue, 15 Aug 2023 11:39:52 +0100 From: Catalin Marinas To: Xiaolei Wang 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() Message-ID: References: <20230815051358.802035-1-xiaolei.wang@windriver.com> <20230815051358.802035-2-xiaolei.wang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230815051358.802035-2-xiaolei.wang@windriver.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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