From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77E3FECAAD3 for ; Wed, 7 Sep 2022 10:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbiIGKBR (ORCPT ); Wed, 7 Sep 2022 06:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbiIGKAc (ORCPT ); Wed, 7 Sep 2022 06:00:32 -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 B14253F319 for ; Wed, 7 Sep 2022 03:00:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4F76B61835 for ; Wed, 7 Sep 2022 10:00:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67DF0C433B5; Wed, 7 Sep 2022 10:00:24 +0000 (UTC) Date: Wed, 7 Sep 2022 11:00:20 +0100 From: Catalin Marinas To: "zhaoyang.huang" Cc: Andrew Morton , Zhaoyang Huang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ke.wang@unisoc.com Subject: Re: [Resend RFC PATCH] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation Message-ID: References: <1662116347-17649-1-git-send-email-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1662116347-17649-1-git-send-email-zhaoyang.huang@unisoc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 06:59:07PM +0800, zhaoyang.huang wrote: > From: Zhaoyang Huang > > Kthread and drivers could fetch memory via alloc_pages directly which make them > hard to debug when leaking. Solve this by introducing __GFP_TRACELEAK and reuse > kmemleak mechanism which unified most of kernel cosuming pages into kmemleak. This may be helpful for debugging individual drivers but they could as well call kmemleak_alloc/free() directly and not bother with new GFP and page flags. I wonder whether we could go the other way around. Add a __GFP_NOLEAKTRACE (we have SLAB_NOLEAKTRACE for example) and pass it in the places where we don't want pages to be scanned/tracked: page cache pages (too many and they don't store pointers to other kernel objects), sl*b, CMA etc. allocations (basically in all places where you have kmemleak_alloc() calls, otherwise the pointers overlap and confuse kmemleak). -- Catalin