Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5492751rwb; Wed, 7 Sep 2022 03:52:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7e7Ac4BXmrWxIlhe0FluqAWW8IO/XY5OTYV7wu0ZZrZMiWBpOSYy3lQztsL728C5WAN8F5 X-Received: by 2002:a62:e91a:0:b0:537:e307:fab0 with SMTP id j26-20020a62e91a000000b00537e307fab0mr3371715pfh.37.1662547928143; Wed, 07 Sep 2022 03:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662547928; cv=none; d=google.com; s=arc-20160816; b=X2K6ViwTkubjwm3x4FUlz9ygKEV2dK5IOFsB2E2lgXH9Lce+zoSPiLn45tNKYTu6mm z9Bcag76bcRebvmwg6yagxVttMaEYmPZ41EOGvSrEazLfnJWAa6azAUCSGl7oYwv4drR P2ZQdlsCXd+83/pP80/n3LoT9bvNO+u9OL/igMxmxgRkaDVOBZU9/cTmq4TTkwpNL0oH DgGTQaEH/myJUgfYJYiM2sowlISYUmCKc2Ol3EbhB4FHRDHnw9SkKw+HrE05gaqwIJy3 a/75hKDfBvv7/pkb1F/4AXyJdgEFFAVVUf114CTa3jowLSokqj7EUYYUlKIXHXh9T0tr QYMQ== 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=05pdO9cXLUxBlXJk6Nb0oTUVGkLzWjzW2yk9HdfAmbk=; b=eqOW07rUi901wtW3jYyHw+lKlgG/FYch2QkeR4poIA5ulwFb+4vRVmjDY4pmkhMFDl EiLHynrBeIKxv0wtVYx3To9P2bTEjVK+4O4ZEcaYDUxVmavd1LgPFL0RWLQF2G1Yu93T 0Z99O8knUl0r8LrG1fT2WgZ7q+JWIcn2m9a/GdAnA9yDUdTnYe+xjxr0BsQRSkgOl8gW NR+/fluSEHD0aO+LaAcVtrA9ucfw6JmmbSUp8ooZo2B9kxywmQ4saDWT/x8BjQNxWO3A gHe3DagEU8E40vwEyGF11A8i13onfRCmP3hxmQQg2qmKC1P+LPZXjAmezywmEFOhMSSW kbOw== 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 i16-20020a635850000000b0041bd3212b81si12827092pgm.254.2022.09.07.03.51.56; Wed, 07 Sep 2022 03:52:08 -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 S230461AbiIGKBM (ORCPT + 99 others); Wed, 7 Sep 2022 06:01:12 -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> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 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