03 Dec, 2011

5 commits

  • Ensure that memory hotplug can co-exist with kmemleak
    by taking the hotplug lock before scanning the memory
    banks.

    Signed-off-by: Laura Abbott
    Signed-off-by: Catalin Marinas

    Laura Abbott
     
  • This patch adds kmemleak callbacks from the percpu allocator, reducing a
    number of false positives caused by kmemleak not scanning such memory
    blocks. The percpu chunks are never reported as leaks because of current
    kmemleak limitations with the __percpu pointer not pointing directly to
    the actual chunks.

    Reported-by: Huajun Li
    Acked-by: Christoph Lameter
    Acked-by: Tejun Heo
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • If an error fatal to kmemleak (like memory allocation failure) happens,
    kmemleak disables itself but it also removes the access to any
    previously found memory leaks. This patch allows read-only access to the
    kmemleak debugfs interface but disables any other action.

    Reported-by: Nick Bowler
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Just telling that the early log buffer has been exceeded doesn't mean
    much. This patch moves the error printing to the kmemleak_init()
    function and displays the actual calls to the kmemleak API during early
    logging.

    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Based on initial patch by Steven Rostedt.

    Early kmemleak warnings did not show where the actual kmemleak API had
    been called from but rather just a backtrace to the kmemleak_init()
    function. By having all early kmemleak logs record the stack_trace, we
    can have kmemleak_init() write exactly where the problem occurred. This
    patch adds the setting of the kmemleak_warning variable every time a
    kmemleak warning is issued. The kmemleak_init() function checks this
    variable during early log replaying and prints the log trace if there
    was any warning.

    Reported-by: Steven Rostedt
    Cc: Andrew Morton
    Signed-off-by: Catalin Marinas
    Acked-by: Steven Rostedt

    Catalin Marinas
     

31 Oct, 2011

1 commit


27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

20 May, 2011

1 commit


31 Mar, 2011

1 commit


28 Jan, 2011

1 commit

  • This patch adds __GFP_NORETRY and __GFP_NOMEMALLOC flags to the kmemleak
    metadata allocations so that it has a smaller effect on the users of the
    kernel slab allocator. Since kmemleak allocations can now fail more
    often, this patch also reduces the verbosity by passing __GFP_NOWARN and
    not dumping the stack trace when a kmemleak allocation fails.

    Signed-off-by: Catalin Marinas
    Reported-by: Toralf Förster
    Acked-by: Pekka Enberg
    Acked-by: David Rientjes
    Cc: Ted Ts'o

    Catalin Marinas
     

09 Aug, 2010

1 commit


19 Jul, 2010

3 commits


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

18 Dec, 2009

1 commit

  • * 'kmemleak' of git://linux-arm.org/linux-2.6:
    kmemleak: fix kconfig for crc32 build error
    kmemleak: Reduce the false positives by checking for modified objects
    kmemleak: Show the age of an unreferenced object
    kmemleak: Release the object lock before calling put_object()
    kmemleak: Scan the _ftrace_events section in modules
    kmemleak: Simplify the kmemleak_scan_area() function prototype
    kmemleak: Do not use off-slab management with SLAB_NOLEAKTRACE

    Linus Torvalds
     

09 Nov, 2009

1 commit


29 Oct, 2009

3 commits


28 Oct, 2009

1 commit


10 Oct, 2009

2 commits


11 Sep, 2009

1 commit


09 Sep, 2009

3 commits


08 Sep, 2009

3 commits

  • In an ideal world your kmemleak output will be small, when its
    not (usually during initial bootup) you can use the clear command
    to ingore previously reported and unreferenced kmemleak objects. We
    do this by painting all currently reported unreferenced objects grey.
    We paint them grey instead of black to allow future scans on the same
    objects as such objects could still potentially reference newly
    allocated objects in the future.

    To test a critical section on demand with a clean
    /sys/kernel/debug/kmemleak you can do:

    echo clear > /sys/kernel/debug/kmemleak
    test your kernel or modules
    echo scan > /sys/kernel/debug/kmemleak

    Then as usual to get your report with:

    cat /sys/kernel/debug/kmemleak

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Catalin Marinas

    Luis R. Rodriguez
     
  • Acked-by: Pekka Enberg
    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Catalin Marinas

    Luis R. Rodriguez
     
  • The kmemleak_disable() function could be called from various contexts
    including IRQ. It creates a clean-up thread but the kthread_create()
    function has restrictions on which contexts it can be called from,
    mainly because of the kthread_create_lock. The patch changes the
    kmemleak clean-up thread to a workqueue.

    Signed-off-by: Catalin Marinas
    Reported-by: Eric Paris

    Catalin Marinas
     

04 Sep, 2009

2 commits

  • This patch changes the for_each_process() loop with the
    do_each_thread()/while_each_thread() pair.

    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Ingo Molnar reported the following kmemcheck warning when running both
    kmemleak and kmemcheck enabled:

    PM: Adding info for No Bus:vcsa7
    WARNING: kmemcheck: Caught 32-bit read from uninitialized memory
    (f6f6e1a4)
    d873f9f600000000c42ae4c1005c87f70000000070665f666978656400000000
    i i i i u u u u i i i i i i i i i i i i i i i i i i i i i u u u
    ^

    Pid: 3091, comm: kmemleak Not tainted (2.6.31-rc7-tip #1303) P4DC6
    EIP: 0060:[] EFLAGS: 00010006 CPU: 0
    EIP is at scan_block+0x3f/0xe0
    EAX: f40bd700 EBX: f40bd780 ECX: f16b46c0 EDX: 00000001
    ESI: f6f6e1a4 EDI: 00000000 EBP: f10f3f4c ESP: c2605fcc
    DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    CR0: 8005003b CR2: e89a4844 CR3: 30ff1000 CR4: 000006f0
    DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
    DR6: ffff4ff0 DR7: 00000400
    [] scan_object+0x7c/0xf0
    [] kmemleak_scan+0x1d9/0x400
    [] kmemleak_scan_thread+0x4c/0xb0
    [] kthread+0x74/0x80
    [] kernel_thread_helper+0x7/0x3c
    [] 0xffffffff
    kmemleak: 515 new suspected memory leaks (see
    /sys/kernel/debug/kmemleak)
    kmemleak: 42 new suspected memory leaks (see /sys/kernel/debug/kmemleak)

    The problem here is that kmemleak will scan partially initialized
    objects that makes kmemcheck complain. Fix that up by skipping
    uninitialized memory regions when kmemcheck is enabled.

    Reported-by: Ingo Molnar
    Acked-by: Ingo Molnar
    Acked-by: Catalin Marinas
    Signed-off-by: Pekka Enberg

    Pekka Enberg
     

27 Aug, 2009

5 commits


30 Jul, 2009

1 commit


08 Jul, 2009

2 commits

  • Functions like free_bootmem() are allowed to free only part of a memory
    block. This patch adds support for this via the kmemleak_free_part()
    callback which removes the original object and creates one or two
    additional objects as a result of the memory block split.

    Signed-off-by: Catalin Marinas
    Cc: Ingo Molnar
    Acked-by: Pekka Enberg

    Catalin Marinas
     
  • Many of the false positives in kmemleak happen on busy systems where
    objects are allocated during a kmemleak scanning episode. These objects
    aren't scanned by default until the next memory scan. When such object
    is added, for example, at the head of a list, it is possible that all
    the other objects in the list become unreferenced until the next scan.

    This patch adds checking for newly allocated objects at the end of the
    scan and repeats the scanning on these objects. If Linux allocates
    new objects at a higher rate than their scanning, it stops after a
    predefined number of passes.

    Signed-off-by: Catalin Marinas

    Catalin Marinas