All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Matthew Wilcox <willy@infradead.org>, Qian Cai <cai@lca.pw>
Subject: Re: [PATCH v2] mm: kmemleak: Use mempool allocations for kmemleak objects
Date: Sat, 3 Aug 2019 11:48:31 +0100	[thread overview]
Message-ID: <20190803104830.GB58477@iMac.local> (raw)
In-Reply-To: <20190801064153.GD11627@dhcp22.suse.cz>

On Thu, Aug 01, 2019 at 08:41:53AM +0200, Michal Hocko wrote:
> On Wed 31-07-19 16:44:50, Catalin Marinas wrote:
> > On Tue, Jul 30, 2019 at 01:02:15PM -0700, Andrew Morton wrote:
> > > On Sat, 27 Jul 2019 14:23:33 +0100 Catalin Marinas <catalin.marinas@arm.com> 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.
> 
> If you really want/need to make this configurable then the command line
> parameter makes more sense - think of distribution kernel users for
> example.

I doubt you'd have pre-built distribution kernels with kmemleak enabled.

> But I am still not sure why this is really needed. The initial
> size is a "made up" number of course. There is no good estimation to
> make (without a crystal ball). The value might be increased based on
> real life usage.

We had a similar situation with the early log buffer (before slab is
initialised), initially 400 which was good enough for my needs (embedded
systems) but others had entirely different requirements. A configurable
(cmdline, Kconfig) option would make it easier for people to change,
especially if coupled with a meaningful suggestion in dmesg.

Another option is to use the early log as an emergency pool after
initialisation instead of freeing it (it's currently __initdata) and
drop the mempool idea. I may give this a go, at least we only have a
single Kconfig option.

-- 
Catalin

  reply	other threads:[~2019-08-03 10:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-27 13:23 [PATCH v2] mm: kmemleak: Use mempool allocations for kmemleak objects Catalin Marinas
2019-07-30 19:57 ` Andrew Morton
2019-07-30 20:22   ` Qian Cai
2019-07-30 20:39     ` Andrew Morton
2019-07-31  9:53     ` Catalin Marinas
2019-07-31 12:02       ` Qian Cai
2019-07-31 14:48         ` Catalin Marinas
2019-07-31 14:54           ` Qian Cai
2019-07-31 14:54             ` Qian Cai
2019-07-31  9:06   ` Michal Hocko
2019-07-31  9:17     ` Catalin Marinas
2019-07-30 20:02 ` Andrew Morton
2019-07-31 15:44   ` Catalin Marinas
2019-08-01  6:41     ` Michal Hocko
2019-08-03 10:48       ` Catalin Marinas [this message]
2019-07-31  9:10 ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190803104830.GB58477@iMac.local \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=cai@lca.pw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.