Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3753321rwe; Mon, 29 Aug 2022 19:53:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR75RJRG78IpSDwAep/yJzUbrvtOj9Kp4eWkmt/rqk40gXOZ4AqbBwtDvHo6Qri8MB+GaKjZ X-Received: by 2002:a17:903:25c4:b0:174:4311:bf17 with SMTP id jc4-20020a17090325c400b001744311bf17mr17310661plb.103.1661828003895; Mon, 29 Aug 2022 19:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661828003; cv=none; d=google.com; s=arc-20160816; b=xc1PYEOMD0kXLbtLd9Z7wtv4a1PuvH1LR8q/XfmbyFlL1icn5nKSTLVoMPIaKBqtAM 8jAAYJ0Eko9x4vUY3HVMs0nG0Egps53e15jHucZvWTUu+IXSvUL5r7H2Zbi5mbjJG/j3 uGGf1ATnxGYnGIsxAPCIOe4njyChil/1aosUltEDJhcC1K932SycBU7FEVnbnlEPqQXf qdyYwgBnDFuP0YMLp6Qmy5xhK/0LN+SAccnYSQLl1qfz/+ki+g1js148j7Ve3OQS8xtL 4YJgaI868aaS/JCPQ1kAS0dcSiyffN+izgYcCEYXZ5zfdNjN5efPch7OOSkIetuzpbzl KEZg== 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=p1rCUVVOx3EtRRRfoxbwmNUBHiId3GOW3+wZvEDaYcY=; b=IagTUCSC8u4vN8Htjx8XWej9bjJ1L24//zsPmjHMD7y8O/MXonuVg1mwrrDipgPXDy oG5Dg7abuB0m1cp4dRc8ZoeiT/XLP4aEpNJRBGPQ8Ix7qGZjq4f/kjt/r19iborUy6eS MGgZW7XjsOyeZC/haExVMK9QC4h4HgYHU7PfZ0HRTb+qocxtLQoppCgC3Lb5sekp14xx Rj3Dx2y2fJ710jXqjGwDYxpEUTgAl/MUOawUcurVLQ3K/tiSRZn6vPP1PGihgi4DqldI iZ9inl9faR+GKs5zN1hPY/1CejqgqVOW3EEbtyuM2fZDzEMkqZmWftXAUF49aEvTkee7 o2qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TYlpK7Cd; 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 d10-20020a056a00198a00b0052e57ed915asi12284024pfl.233.2022.08.29.19.53.12; Mon, 29 Aug 2022 19:53:23 -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=TYlpK7Cd; 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 S229982AbiH3CmP (ORCPT + 99 others); Mon, 29 Aug 2022 22:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbiH3CmO (ORCPT ); Mon, 29 Aug 2022 22:42:14 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F7F7A74F for ; Mon, 29 Aug 2022 19:42:13 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id p7so2556186lfu.3 for ; Mon, 29 Aug 2022 19:42:12 -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; bh=p1rCUVVOx3EtRRRfoxbwmNUBHiId3GOW3+wZvEDaYcY=; b=TYlpK7Cdl6vprclxB7keOnBZeV1p1z/gL/XVk9MveYIetBsLqBLhQStTg7EblQLiik k1Ml9TiGc0fd3etLqxNriyETRIg5IVd+bS+zXwVnj2aRpIekJX96LwX34HT3RcA4BTuw JHdOvwPRA1qnqGoxL1pH7pyqNT3bgG88I5C0zT87Cn86oJKhzdd7XQEsVS4mpZ2vRTRC umOYmytqjl91gpEABkiabJkC9Luz8jltpl9ulang/vonNqfxT6kgadCNoj83yTXVj3Tf 1S3/sUvi2uSKMod9Jw20vtL5I/sj6+Z8LZRf2fpJNFUJwGQqbooK+6bcZscs0IwLXl0s 5+Jw== 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; bh=p1rCUVVOx3EtRRRfoxbwmNUBHiId3GOW3+wZvEDaYcY=; b=hAlNgjKucyynxgRmCxCaH0bqjGhDhsWF84Y+PXBoymUxnpG4d3mtRLMZ9OcOnQQddz GuvAltjqu6yO3fTV3+gnLySYhYeJ20AugC8Mmc3RIrHnAj9gn4LDzQWBKeSrIMQ7jiM2 6v+t+NORvZ8vbZBGArgHD/0PwAht+ogaGJcjszwtf+GN9JSb6qmcKehCwEVOMF/fXq+g f45OZpjVW+Hu28qanUAPuug509fdbVaALgjQwIYYaHCfkkHSRUXDJHbGVFtR03nrG3AY Tnp0dyYzu/rG2Ki1B1t0A57x76qaSI+YyPF/765C8NUrfDVoL6wmcUukO91MERbsvMlc 5sxw== X-Gm-Message-State: ACgBeo1Uql02SLDIQhYuJSIuDGY+Ct2vAI1vRAa72qKqIxYwCROE200p cHAIsfm48em1YqxfUEl0fdmmg0OssIOlnb3+Rfx7DTWJ4fU= X-Received: by 2002:a05:6512:e99:b0:492:db20:efd7 with SMTP id bi25-20020a0565120e9900b00492db20efd7mr6675342lfb.468.1661827331338; Mon, 29 Aug 2022 19:42:11 -0700 (PDT) MIME-Version: 1.0 References: <1661483530-11308-1-git-send-email-zhaoyang.huang@unisoc.com> <12759ac7-4a6c-89fa-5fd0-914728f6415e@redhat.com> In-Reply-To: <12759ac7-4a6c-89fa-5fd0-914728f6415e@redhat.com> From: Zhaoyang Huang Date: Tue, 30 Aug 2022 10:41:43 +0800 Message-ID: Subject: Re: [PATCH] mm: skip reserved page for kmem leak scanning To: David Hildenbrand Cc: "zhaoyang.huang" , Andrew Morton , Catalin Marinas , "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 Mon, Aug 29, 2022 at 8:19 PM David Hildenbrand wrote: > > On 26.08.22 05:23, Zhaoyang Huang wrote: > > On Fri, Aug 26, 2022 at 11:13 AM zhaoyang.huang > > wrote: > >> > >> From: Zhaoyang Huang > >> > >> It is no need to scan reserved page, skip it. > >> > >> Signed-off-by: Zhaoyang Huang > >> --- > >> mm/kmemleak.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/mm/kmemleak.c b/mm/kmemleak.c > >> index a182f5d..c546250 100644 > >> --- a/mm/kmemleak.c > >> +++ b/mm/kmemleak.c > >> @@ -1471,7 +1471,7 @@ static void kmemleak_scan(void) > >> if (page_zone(page) != zone) > >> continue; > >> /* only scan if page is in use */ > >> - if (page_count(page) == 0) > >> + if (page_count(page) == 0 || PageReserved(page)) > > Sorry for previous stupid code by my faint, correct it here > > Did you even test the initial patch? > > I wonder why we should consider this change > > (a) I doubt it's a performance issue. If it is, please provide numbers > before/after. For Android-like SOC systems where AP(cpu runs linux) are one of the memory consumers which are composed of other processors such as modem, isp,wcn etc. The reserved memory occupies a certain number of memory(could be 30% of MemTotal) which makes scan reserved pages pointless. > (b) We'll stop scanning early allocations. As the memmap is usually > allocated early during boot ... we'll stop scanning essentially the > whole mmap and that whole loop would be dead code? What am i > missing? memmap refers to pages here? If we can surpass these as it exist permanently during life period. Besides, I wonder if PageLRU should also be skipped? - if (page_count(page) == 0) + if (page_count(page) == 0 || PageReserved(page) || PageLRU(page)) > > -- > Thanks, > > David / dhildenb >