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 X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A9AAC433FF for ; Wed, 31 Jul 2019 15:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBC59206B8 for ; Wed, 31 Jul 2019 15:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729173AbfGaPoy (ORCPT ); Wed, 31 Jul 2019 11:44:54 -0400 Received: from foss.arm.com ([217.140.110.172]:49430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbfGaPoy (ORCPT ); Wed, 31 Jul 2019 11:44:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD136344; Wed, 31 Jul 2019 08:44:53 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A9F223F694; Wed, 31 Jul 2019 08:44:52 -0700 (PDT) Date: Wed, 31 Jul 2019 16:44:50 +0100 From: Catalin Marinas To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Matthew Wilcox , Qian Cai Subject: Re: [PATCH v2] mm: kmemleak: Use mempool allocations for kmemleak objects Message-ID: <20190731154450.GB17773@arrakis.emea.arm.com> References: <20190727132334.9184-1-catalin.marinas@arm.com> <20190730130215.919b31c19df935cc5f1483e6@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190730130215.919b31c19df935cc5f1483e6@linux-foundation.org> 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 Tue, Jul 30, 2019 at 01:02:15PM -0700, Andrew Morton wrote: > On Sat, 27 Jul 2019 14:23:33 +0100 Catalin Marinas wrote: > > > Add mempool allocations for struct kmemleak_object and > > kmemleak_scan_area as slightly more resilient than kmem_cache_alloc() > > under memory pressure. Additionally, mask out all the gfp flags passed > > to kmemleak other than GFP_KERNEL|GFP_ATOMIC. > > > > A boot-time tuning parameter (kmemleak.mempool) is added to allow a > > different minimum pool size (defaulting to NR_CPUS * 4). > > btw, the checkpatch warnings are valid: > > WARNING: usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc > #70: FILE: mm/kmemleak.c:197: > +static int min_object_pool = NR_CPUS * 4; > > WARNING: usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc > #71: FILE: mm/kmemleak.c:198: > +static int min_scan_area_pool = NR_CPUS * 1; > > There can be situations where NR_CPUS is much larger than > num_possible_cpus(). Can we initialize these tunables within > kmemleak_init()? We could and, at least on arm64, cpu_possible_mask is already initialised at that point. However, that's a totally made up number. I think we would better go for a Kconfig option (defaulting to, say, 1024) similar to the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE and we grow it if people report better values in the future. -- Catalin