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 EDB17ECAAA1 for ; Tue, 30 Aug 2022 08:52:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62E32940007; Tue, 30 Aug 2022 04:52:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B6D36B0074; Tue, 30 Aug 2022 04:52:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40969940007; Tue, 30 Aug 2022 04:52:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2B4BD6B0073 for ; Tue, 30 Aug 2022 04:52:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 007B7AAF67 for ; Tue, 30 Aug 2022 08:52:38 +0000 (UTC) X-FDA: 79855643196.18.5E611E5 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf31.hostedemail.com (Postfix) with ESMTP id BBEBD20007 for ; Tue, 30 Aug 2022 08:52:38 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id z6so14562302lfu.9 for ; Tue, 30 Aug 2022 01:52:38 -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=kguPy3wkAys/EGwS8Nyv4zZp1jqQK2hNEkzoKqRl47o=; b=TPRi+MgkWEfe3wDbg7GpgpypRM62/orWgjZwhLwTwvxq1Q6qUQULhI+lr/OfIiCbig mVS9Wz9Z21/SKULBKaJmLRRZh1XMTJYc1nAdH1LRy8AWmR6QG0ORxf7wdw5IEunn3BhX lXrtUE8LW9tLPtehwHw6hyXxCkOFUgMDEmApEJ9rqt8W1LfE9pMO0vDJ5I/3GYX8vJNL GgXWZF55qFA4EUV4v3X1vfhDnRqw4gDDQUNQAMeqzsDwi6PNbVch6UVPrmQys4PTeDrA mfuLEm59fejkvqK8Bzu0nP3yayb2AKOK7GADH2GWhhkEsQ+0lfoCmAXDuWjig3ttKePR Ty2w== 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=kguPy3wkAys/EGwS8Nyv4zZp1jqQK2hNEkzoKqRl47o=; b=QrZSt4prw9vxTuW2jF50ry8pkglmuEdeCr1dggFKfVg4TzXVq58XKEVYD/8EKKDemf PjHAHDbCwulLG823KE6Mfoi/pMPGstNfA/qf1JMw8X74jOI/KTEvWoU4k2ALQK42JNI7 Go7DwgmFldk83GN8NNJtZsaF8LXbq360sqENi3FdBpuBTE4ul4GfP+iwwDWaWbiaNe+Y GArAnIS1GIQE412aud9OiUoK2gykEBDrBsqn8JSwOAvxKVKHZD0JU/oi/Pm2zE6Sc8m8 QSsrTQxmvZ1sOQ4RSD0jsf+jCyiuxln5ZyJ5+6hHqvrVKyJfUKAcXRORYNe/OnL5mQVf TLeg== X-Gm-Message-State: ACgBeo0DMx6mXC8Y7HppDf3Vf5IbmQKCGCmNBgt+INaZ1iPIhbDDuOcf Za2vtWj1blkXfN6AZgo+Z8rgrm0YEtkW3HOdGMk= X-Google-Smtp-Source: AA6agR5Saf7AnuJL9SY2My7MlZXUw7DF+aC3twmdn8zwmRrKs39J2HhW1ZcErvKGBWL/ZO/X1LFI2OxzDCBVAvRHEhY= X-Received: by 2002:a05:6512:12c5:b0:48c:df54:a41a with SMTP id p5-20020a05651212c500b0048cdf54a41amr7049124lfg.464.1661849557114; Tue, 30 Aug 2022 01:52:37 -0700 (PDT) MIME-Version: 1.0 References: <1661483530-11308-1-git-send-email-zhaoyang.huang@unisoc.com> <12759ac7-4a6c-89fa-5fd0-914728f6415e@redhat.com> <29503bc0-441e-359e-29d0-37ac3c5dff04@redhat.com> In-Reply-To: <29503bc0-441e-359e-29d0-37ac3c5dff04@redhat.com> From: Zhaoyang Huang Date: Tue, 30 Aug 2022 16:52:09 +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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661849558; a=rsa-sha256; cv=none; b=DMhNYVs7RhKecwsHqHHCRlrip27ZJO8D3X6f9i5Rb5RbnlkRVHX/bHhqf0WbTzR8butrDP 53+nkPJfE7guaAKOkW0a1sC8RknuIKvgINur5U4ZnC/co6pLHL+x/BuYq6HSyxcUX3iDx7 W6GUxmqd93y25jvUpc8cnm4UE7wIiJQ= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=TPRi+Mgk; spf=pass (imf31.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661849558; 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:dkim-signature; bh=kguPy3wkAys/EGwS8Nyv4zZp1jqQK2hNEkzoKqRl47o=; b=VcoVef1sqLP0NPuh5GQJvu4KLvmzaEkeCpK7kerNWv3OQs+R6xHouxpMvo8JJ4RdtFvBKw zYA9TWpEmlo0A8mLa5w/kRuR1vIiypirf8tm5ZXJ1rjZp2yX57qZfdwAqh4xHLRM/RBmRn iokW47/0zQSL44Vtvy2P6csfNAv0Lrg= Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=TPRi+Mgk; spf=pass (imf31.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Stat-Signature: mwc8xsociagykyww9ph6ub19o7hoeo3c X-Rspamd-Queue-Id: BBEBD20007 X-Rspam-User: X-HE-Tag: 1661849558-342385 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 Tue, Aug 30, 2022 at 4:03 PM David Hildenbrand wrote: > > On 30.08.22 04:41, Zhaoyang Huang wrote: > > 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. > > But we only scan the memmap (struct page) here and not the actual > memory. Do you have any performance numbers showing that there is even > an observable change? > > >> (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)) > > I think we need a really good justification to start poking holes into > the memmap scanner. I'm no expert on this code (and under which > circumstances we actually might find referenced objects in a memmap), > though. > > But we should be careful with that. Agree. It may be helpless as kmemleak is for debugging purposes. Nack this patch by myself. Sorry for interrupt. > > -- > Thanks, > > David / dhildenb >