Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4702532rwn; Sun, 11 Sep 2022 19:26:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR45IkbsFrPDECtH6keyyPQ48pb6UbW97C0k9bbj9u4RzPGuB4UMtieh5RSktRJhJNwreC2H X-Received: by 2002:a05:6a00:d57:b0:541:987:1ced with SMTP id n23-20020a056a000d5700b0054109871cedmr11742840pfv.16.1662949592971; Sun, 11 Sep 2022 19:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662949592; cv=none; d=google.com; s=arc-20160816; b=OAyrVdE5jhmC/ISCUHzxtJl76Jk/Zy87jpCHwUsJf0EXLQSw8/AYP6e8WjEKZ1CMjy cQ62R26rB2kAmel6VhtmK+N08FQHTA1UehUnTp7ui4wKguUW1HrD5bpJHaGvICWK0rxD 2Pv+OXGuFm8zPSIRp6mygm7nBnaNSaufqwj2ptPlNfrLt0MDeR7W0DeaBRm3ezrQw+u+ NBsMUzM63uz59y/EXOeGySEAKswbgQNAJPeZlpNbOPjy0GtJTUFgWWMF3Ew1NWi6+Ut2 FOkTXFJMd1NOg6ZLXWeg1txvOh4ivfioCnPpr+rmC+tGhk6BpSeyQ/hJ2RoH1lQx4d8E 4s0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sQSPw2/Yv4uUp2AaAGOjeqmDAWsfMqITGNLo8334oeE=; b=mEfXnjjg7A6KCtZTs+lRgC2tHZkoPYmViQlMfBIRNE3hlYg4qarQ/9s4aU/p402sNQ KiRu5r0aT1UI9gKoC/kP16A5YVXCRPjASZw3p7hUTMKNBp+EtPYuRym1/5FFS1Ohrxi2 z4z0gEnFkkXZeNQYDFpLtVdYVNGxtRkadSnJycO+K3ODHzq8ydmtH7qPnFw/8LmNupxn G31bsq0flI4DLuswfxexyshMrqLK9YzPmIVA+uXZlEKxox1C1GvDWS0wAjopsQqYV50g mcEk1qp7vlrOD5cSV/B4ghsZ/SH1WBUoCvsxhTzprv4yFZr0nq+CR7+tWkh8WtfE8Bm1 ki3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VaKZg8t+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020a056a000c9600b00537b1bc9683si1715650pfv.36.2022.09.11.19.26.21; Sun, 11 Sep 2022 19:26:32 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VaKZg8t+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbiILCX5 (ORCPT + 99 others); Sun, 11 Sep 2022 22:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiILCX4 (ORCPT ); Sun, 11 Sep 2022 22:23:56 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A9BA1EC7B for ; Sun, 11 Sep 2022 19:23:55 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id s10so8316701ljp.5 for ; Sun, 11 Sep 2022 19:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=sQSPw2/Yv4uUp2AaAGOjeqmDAWsfMqITGNLo8334oeE=; b=VaKZg8t+l7Y5XlONXTGOuwmbf4afC1bwL9BOGvU8npmzhmzMHKlmim937SzLzi7f6+ mwh8N0ZgY1vey5nXKOCE2NbUS0rU+aNwpfbpFie8oZZFblfgHHmVX9M8qur8aKnT7jh9 /X8AVNFidSiEJh8u+DK92BrhbclID/LggJN3v9FITFQxHfGeeovBt9VSIQP9QH+iaFLc MyY1hyLvbq59wQzn4QbnCsvRucAnc54Bf8rp24SnqkMeQ8IP630JXu3MC/7rh5lmDCQY HDp29MGwQK4QbDCmqeSkT3uWianTiILJbqQ4plgyYF9fyOMxeqVaCZ7L6fjgqESTgpBM 1f5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=sQSPw2/Yv4uUp2AaAGOjeqmDAWsfMqITGNLo8334oeE=; b=aNCpkUE9zfoVWRmL8smS0RHVj7XaG9K4Eriph8qy95GxuPPcJHzECEc56LZGBAqgau nvo07CDpTQLtWTq7+cpOdbwcTzRWRVPJ4DTzecDZJ+xV7R+weAhI3Vlt+yyMezlXd6OA KavZ0E/PicLx4WNy1RnyNrcyJpIcJzibsWAp3uil2lHO7OGpRTDPyGBtFd4mI16U10D0 ml1+MC5aiIYmQcgQyssgfVPplqB+ZR7/Q69SqLMpQQ27ZetrG1PetB1VdWSezGvnIuir 9wNpVk30Qe35aUicNQzd35hLSIV2cKZpXPmZjtoQtJApdrs2VQqEpDKlj2b9JK3HZE/7 RyFw== X-Gm-Message-State: ACgBeo2wZKMBCwvKrD9ID0Q4TRRfiJFxTbyPMxBUzRAUmRWBi3ijPj36 9Eh8fB8J5gci6S5A4pnVkiS9BmeE9KBpCkTS/78= X-Received: by 2002:a2e:be8d:0:b0:26c:f4b:47a0 with SMTP id a13-20020a2ebe8d000000b0026c0f4b47a0mr131263ljr.92.1662949433420; Sun, 11 Sep 2022 19:23:53 -0700 (PDT) MIME-Version: 1.0 References: <1662116347-17649-1-git-send-email-zhaoyang.huang@unisoc.com> In-Reply-To: From: Zhaoyang Huang Date: Mon, 12 Sep 2022 10:23:25 +0800 Message-ID: Subject: Re: [Resend RFC PATCH] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation To: Catalin Marinas Cc: "zhaoyang.huang" , Andrew Morton , "open list:MEMORY MANAGEMENT" , LKML , Ke Wang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Wed, Sep 7, 2022 at 6:00 PM Catalin Marinas wrote: > > 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. Sure, it could be done as you suggested. However, I would like to have all memory related things wrapped together and leaving the user a simple entrance. Besides, some drivers are designed in Producer/Consumer mode where pages are got and freed by different peers, which may lead to unpair kmemleak operation. > > 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