public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.20-rc1 00/10] Kernel memory leak detector 0.13
Date: Thu, 28 Dec 2006 10:44:31 +0100	[thread overview]
Message-ID: <20061228094431.GE24765@elte.hu> (raw)
In-Reply-To: <b0943d9e0612271615r42c7f6abt38f36bbd9c94319f@mail.gmail.com>


* Catalin Marinas <catalin.marinas@gmail.com> wrote:

> >memleak info is at a negative offset from the allocated pointer. I.e.
> >that if kmalloc() returns 'ptr', the memleak info could be at
> >ptr-sizeof(memleak_info). That way you dont have to know the size of the
> >object beforehand and there's absolutely no need for a global hash of
> >any sort.
> 
> It would probably need to be just a pointer embedded in the allocated 
> block. With the current design, the memleak objects have a lifetime 
> longer than the tracked block. This is mainly to avoid long locking 
> during memory scanning and reporting.

this thing has to be /fast/ in the common path. I dont really see the 
point in spreading out allocations like that for small objects. Access 
to the object has to be refcounted /anyway/ due to scanning. Just move 
that refcounting to the object freeing stage. Keep freed-but-used 
buffers in some sort of per-CPU list that the scanning code flushes 
after it's done. (Also maybe hold the cache_chain_mutex to prevent slab 
caches from being destroyed during scanning.)

> > (it gets a bit more complex for page aligned allocations for the 
> > buddy and for vmalloc - but that could be solved by adding one extra 
> > pointer into struct page. [...]
> 
> This still leaves the issue of marking objects as not being leaks or 
> being of a different type. This is done by calling memleak_* functions 
> at the allocation point (outside allocator) where only the pointer is 
> known. [...]

i dont see the problem. By having the pointer we have access to the 
memleak descriptor too.

> [...] In the vmalloc case, it would need to call find_vm_area. This 
> might not be a big problem, only that memory resources are no longer 
> treated in a unified way by kmemleak (and might not be trivial to add 
> support for new allocators).

the pretty horrible locking dependencies in the current one are just as 
bad. (which could be softened by a simplified allocator - but that 
brings in other problems, which problems can only be solved via 
allocator complexity ...)

If 'unification' means global locking and bad overhead and leak 
descriptor maintainance complexity then yes, we very much dont want to 
treat them in a unified way. Unless there's some killer counter-argument 
against embedding the memleak descriptor in the object that we allocate 
it is pretty much a must.

btw., you made the argument before that what matters most is the SLAB 
allocator. (when i argued that we might want to extend this to other 
allocators as well) You cant have it both ways :)

> > [...] That is a far more preferable cost than the locking/cache 
> > overhead of a global hash.)
> 
> A global hash would need to be re-built for every scan (and destroyed 
> afterwards), making this operation longer since the pointer values 
> together with their aliases (resulted from using container_of) are 
> added to the hash.

by 'global hash' i mean the current code.

> I understand the benefits but I personally favor simplicity over 
> performance, [...]

i think you are trying to clinge to a bad design detail. You spent time 
on it, and that time was still worthwile, believe me. I often change 
design details dozens of times before a patch hits lkml. It doesnt 
matter, really - it's the path you walk that matters. This thing /has/ 
to be fast/scalable to be used in distributions.

> [...] Global structures are indeed a scalability problem but for a 
> reasonable number of CPUs their overhead might not be that big.

lets forget you ever said this, ok? ;-)

	Ingo

  reply	other threads:[~2006-12-28  9:46 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-16 15:34 [PATCH 2.6.20-rc1 00/10] Kernel memory leak detector 0.13 Catalin Marinas
2006-12-16 15:34 ` [PATCH 2.6.20-rc1 01/10] Base support for kmemleak Catalin Marinas
2006-12-16 15:34 ` [PATCH 2.6.20-rc1 02/10] Kmemleak documentation Catalin Marinas
2006-12-16 15:34 ` [PATCH 2.6.20-rc1 03/10] Add the memory allocation/freeing hooks for kmemleak Catalin Marinas
2006-12-16 15:34 ` [PATCH 2.6.20-rc1 04/10] Modules support " Catalin Marinas
2006-12-16 15:35 ` [PATCH 2.6.20-rc1 05/10] Add kmemleak support for i386 Catalin Marinas
2006-12-16 15:35 ` [PATCH 2.6.20-rc1 06/10] Add kmemleak support for ARM Catalin Marinas
2006-12-16 15:35 ` [PATCH 2.6.20-rc1 07/10] Remove some of the kmemleak false positives Catalin Marinas
2006-12-16 15:35 ` [PATCH 2.6.20-rc1 08/10] Keep the __init functions after initialization Catalin Marinas
2006-12-16 15:35 ` [PATCH 2.6.20-rc1 09/10] Testing module for kmemleak Catalin Marinas
2006-12-16 15:36 ` [PATCH 2.6.20-rc1 10/10] Update the MAINTAINERS file " Catalin Marinas
2006-12-16 16:57 ` [PATCH 2.6.20-rc1 00/10] Kernel memory leak detector 0.13 Ingo Molnar
2006-12-16 23:39   ` Catalin Marinas
2006-12-17  8:58     ` Ingo Molnar
2006-12-17  9:09       ` Ingo Molnar
2006-12-17  9:28         ` Ingo Molnar
2006-12-17  9:41           ` Ingo Molnar
2006-12-17  9:49             ` Ingo Molnar
2006-12-17 12:05             ` Catalin Marinas
2006-12-27 16:14             ` Catalin Marinas
2006-12-27 16:23               ` Arjan van de Ven
2006-12-27 16:30                 ` Catalin Marinas
2006-12-27 16:47               ` Ingo Molnar
2006-12-27 16:56                 ` Ingo Molnar
2006-12-27 17:02                 ` Catalin Marinas
2006-12-17 11:58           ` Catalin Marinas
2006-12-17 13:28             ` Ingo Molnar
2006-12-17 11:09       ` Mike Galbraith
2006-12-17 23:05       ` Catalin Marinas
2006-12-18  7:29         ` Ingo Molnar
2006-12-18 10:28           ` Catalin Marinas
2006-12-18 11:21             ` Ingo Molnar
2006-12-18 12:26               ` Catalin Marinas
2006-12-18 19:56                 ` Ingo Molnar
2006-12-19  9:36                   ` Catalin Marinas
2006-12-27 13:52           ` Catalin Marinas
2006-12-27 15:08             ` Ingo Molnar
2006-12-27 17:30               ` Ingo Molnar
2006-12-28  0:15                 ` Catalin Marinas
2006-12-28  9:44                   ` Ingo Molnar [this message]
2006-12-28 11:50                     ` Catalin Marinas

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=20061228094431.GE24765@elte.hu \
    --to=mingo@elte.hu \
    --cc=catalin.marinas@gmail.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox