Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp338772imu; Fri, 7 Dec 2018 01:51:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xtf0MOy+XwUFhhOO8SRg6GvlyAZJVgetGjlCR/VrwXdvnuyUFtbLOCz3wGCmhuqvhdapQ+ X-Received: by 2002:a17:902:f81:: with SMTP id 1mr1456128plz.174.1544176266099; Fri, 07 Dec 2018 01:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544176266; cv=none; d=google.com; s=arc-20160816; b=dzmtJUPpBS1chlyHgi1bY7L9How20C2Ic/6xJ2Hz0nrxtJbZ/UrRd6sfM3Wq8VD3q8 YlOcdsdCC0p6VKKN/HJTUeMGYgHLY/EdgacXArjcgFcZEkDe6dcMg2pFsDYtMS/t1T2z q9L9kd/NpTFu63talrpEntauWnCFcagwmLb+3x9frQYfiAvPANoRqUiTjzkzyMx91N5A 8iH9vSBjzEBcNuP63gDQuUySQiIlFI9+L51r9gEbt0hKPjnNBQdlUZNinWxwvJF3zAXk Fw9yLygHPT0PqHMVP097rRBAYJRRShMxFbfPud1E99PmxoTG/KOO41pePaGIrKCeFqf6 S3UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/gGNaXsQveEXrZCxgHFTR1o4Lg4OcShTDVzQKXR87Sc=; b=Xuo9GQpEzQZpnKiLOQl1N8xF7PlDBrZlZykUmrsN6Y2qpIxleldPdZFFjrDU6V30ZJ YwLpQ6Kno/cP2bc+QHMzFvXNwMicpoP7bzDNPD80zJA5kcy6nX4H0YftDtxDTovZtS5A t/Q3IbFmYHC24UPI+GyMAl1J7sVixgnYwoKK3Q3wgRIeCgi2O975QExyVUVXElLTGXQg emyOb0QpOaUlW+x9tk8hnppurFlg9vbGoiaNsIQGp18u6kS04LjPQsKsyy40bBieCG9b yyA/L3KsJVbhngaAIhRDKTQzzJRogwnOYS9iLVVLnEljCeIYPQlbsa437w7AyIoJFdgG 8qMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si2481677pgh.422.2018.12.07.01.50.51; Fri, 07 Dec 2018 01:51:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726029AbeLGJsX (ORCPT + 99 others); Fri, 7 Dec 2018 04:48:23 -0500 Received: from foss.arm.com ([217.140.101.70]:40476 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbeLGJsX (ORCPT ); Fri, 7 Dec 2018 04:48:23 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D6A7EBD; Fri, 7 Dec 2018 01:48:23 -0800 (PST) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.113]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1DD693F59C; Fri, 7 Dec 2018 01:48:21 -0800 (PST) Date: Fri, 7 Dec 2018 09:48:19 +0000 From: Catalin Marinas To: Oscar Salvador Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, kmemleak: Little optimization while scanning Message-ID: <20181207094819.GA23085@arrakis.emea.arm.com> References: <20181206131918.25099-1-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181206131918.25099-1-osalvador@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 06, 2018 at 02:19:18PM +0100, Oscar Salvador wrote: > kmemleak_scan() goes through all online nodes and tries > to scan all used pages. > We can do better and use pfn_to_online_page(), so in case we have > CONFIG_MEMORY_HOTPLUG, offlined pages will be skiped automatically. > For boxes where CONFIG_MEMORY_HOTPLUG is not present, pfn_to_online_page() > will fallback to pfn_valid(). > > Another little optimization is to check if the page belongs to the node > we are currently checking, so in case we have nodes interleaved we will > not check the same pfn multiple times. > > I ran some tests: > > Add some memory to node1 and node2 making it interleaved: > > (qemu) object_add memory-backend-ram,id=ram0,size=1G > (qemu) device_add pc-dimm,id=dimm0,memdev=ram0,node=1 > (qemu) object_add memory-backend-ram,id=ram1,size=1G > (qemu) device_add pc-dimm,id=dimm1,memdev=ram1,node=2 > (qemu) object_add memory-backend-ram,id=ram2,size=1G > (qemu) device_add pc-dimm,id=dimm2,memdev=ram2,node=1 > > Then, we offline that memory: > # for i in {32..39} ; do echo "offline" > /sys/devices/system/node/node1/memory$i/state;done > # for i in {48..55} ; do echo "offline" > /sys/devices/system/node/node1/memory$i/state;don > # for i in {40..47} ; do echo "offline" > /sys/devices/system/node/node2/memory$i/state;done > > And we run kmemleak_scan: > > # echo "scan" > /sys/kernel/debug/kmemleak > > before the patch: > > kmemleak: time spend: 41596 us > > after the patch: > > kmemleak: time spend: 34899 us > > Signed-off-by: Oscar Salvador Acked-by: Catalin Marinas