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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3414DECAAD3 for ; Wed, 7 Sep 2022 10:00:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C05776B0072; Wed, 7 Sep 2022 06:00:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB5058D0002; Wed, 7 Sep 2022 06:00:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7C496B0074; Wed, 7 Sep 2022 06:00:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 960506B0072 for ; Wed, 7 Sep 2022 06:00:29 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6C51A4104D for ; Wed, 7 Sep 2022 10:00:29 +0000 (UTC) X-FDA: 79884844578.09.D5CAAFC Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id C8D7C1A006A for ; Wed, 7 Sep 2022 10:00:28 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id E261BB81B84; 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> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662544829; a=rsa-sha256; cv=none; b=ltZUQE1JxBFmqJEM1Bs8wkk+Tpqm/wwslOhEvgVhFFszESwawUffVZjpeaZ+YaurycSuPV xaFBir5G1opIVf8NA+J/aVR6fqEITBtYqS13x9fc6qzOTleVC7JIa2Cujoc1Or2psQu5ou 5lZush/jks8MqPxW3aHJcwYZHy5m1Hc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662544829; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=05pdO9cXLUxBlXJk6Nb0oTUVGkLzWjzW2yk9HdfAmbk=; b=7rPY+7/ZNJhDXXvbYtStx5RCvgdt7LxUOhod+tOGi7v0O0kBAEHjN5uCuMBkPsNSQK1gUe TklCxH3YzEh6j7EATk83wWXX4NtfZSJ6TPkoh0bwA+RsPYrIQpj6WmQ0xFI3sY9f7xB8mZ iTuEz2XcHxTOb2NBE2Hjs04+QKCHdq0= X-Rspam-User: X-Rspamd-Queue-Id: C8D7C1A006A Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Stat-Signature: txo5jxbuzxwufyss87r9tnqurwnijke5 X-Rspamd-Server: rspam03 X-HE-Tag: 1662544828-432360 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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